Skip to content

Commit

Permalink
Move date arithmetic out of final_tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
iay committed Dec 2, 2024
1 parent 21c5d53 commit f709d62
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 11 deletions.
4 changes: 4 additions & 0 deletions mdx/incommon/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<property name="transformParameters">
<map>
<entry key="publisher" value-ref="us_incommon_registrar"/>
<entry key="validityDays" value="${validUntil.aggregate.days}"/>
<entry key="now_ISO" value-ref="now_ISO"/>
<entry key="now_local_ISO" value-ref="now_local_ISO"/>
<entry key="valid_until_ISO" value-ref="validUntil_aggregate_ISO"/>
</map>
</property>
</bean>
Expand Down
4 changes: 4 additions & 0 deletions mdx/incommon/export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
<map>
<entry key="extraText" value="eduGAIN export metadata"/>
<entry key="publisher" value-ref="us_incommon_registrar"/>
<entry key="validityDays" value="${validUntil.aggregate.days}"/>
<entry key="now_ISO" value-ref="now_ISO"/>
<entry key="now_local_ISO" value-ref="now_local_ISO"/>
<entry key="valid_until_ISO" value-ref="validUntil_aggregate_ISO"/>
</map>
</property>
</bean>
Expand Down
43 changes: 32 additions & 11 deletions mdx/incommon/final_tweak.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"

xmlns:date="http://exslt.org/dates-and-times"
xmlns:mdxDates="xalan://uk.ac.sdss.xalan.md.Dates"
extension-element-prefixes="date mdxDates"

xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Expand Down Expand Up @@ -44,10 +40,36 @@
This parameter determines the number of days between the aggregation instant and the
end of validity of the signed metadata.
-->
<xsl:param name="validityDays" select="14"/>
<xsl:param name="validityDays"/>

<!--
now_ISO
This parameter is an ISO8601 representation of the UTC instant
at which the aggregate generation started.
Example: 2019-10-23T10:25:11Z
-->
<xsl:param name="now_ISO"/>

<!--
now_local_ISO
This parameter is an ISO8601 representation of the local time
at which the aggregate generation started.
Example: 2019-10-23T11:25:11
-->
<xsl:param name="now_local_ISO"/>

<xsl:variable name="now" select="date:date-time()"/>
<xsl:variable name="validUntil" select="mdxDates:dateAdd($now, $validityDays)"/>
<!--
valid_until_ISO
This parameter is an ISO8601 representation of the UTC instant
at which the aggregate will become invalid. This has been computed
by the caller as now_ISO + validityDays days.
-->
<xsl:param name="valid_until_ISO"/>

<!--
documentID
Expand All @@ -59,9 +81,8 @@
that the signature explicitly references an identifier attribute in the element
being signed, in this case the document element.
-->
<xsl:variable name="normalisedNow" select="mdxDates:dateAdd($now, 0)"/>
<xsl:variable name="documentID"
select="concat('INC', translate($normalisedNow, ':-Z', ''))"/>
select="concat('INC', translate($now_ISO, ':-Z', ''))"/>

<!--
Document root.
Expand All @@ -76,7 +97,7 @@
<xsl:template match="/md:EntitiesDescriptor">
<EntitiesDescriptor>
<xsl:attribute name="validUntil">
<xsl:value-of select="$validUntil"/>
<xsl:value-of select="$valid_until_ISO"/>
</xsl:attribute>
<xsl:attribute name="ID">
<xsl:value-of select="$documentID"/>
Expand Down Expand Up @@ -128,7 +149,7 @@
<xsl:value-of select="$publisher"/>
</xsl:attribute>
<xsl:attribute name="creationInstant">
<xsl:value-of select="$normalisedNow"/>
<xsl:value-of select="$now_ISO"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
Expand Down
4 changes: 4 additions & 0 deletions mdx/incommon/import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<map>
<entry key="extraText" value="Contains InCommon and eduGAIN metadata"/>
<entry key="publisher" value-ref="us_incommon_registrar"/>
<entry key="validityDays" value="${validUntil.aggregate.days}"/>
<entry key="now_ISO" value-ref="now_ISO"/>
<entry key="now_local_ISO" value-ref="now_local_ISO"/>
<entry key="valid_until_ISO" value-ref="validUntil_aggregate_ISO"/>
</map>
</property>
</bean>
Expand Down
4 changes: 4 additions & 0 deletions mdx/incommon/import_sign.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<map>
<entry key="extraText" value="Contains InCommon and eduGAIN metadata"/>
<entry key="publisher" value-ref="us_incommon_registrar"/>
<entry key="validityDays" value="${validUntil.aggregate.days}"/>
<entry key="now_ISO" value-ref="now_ISO"/>
<entry key="now_local_ISO" value-ref="now_local_ISO"/>
<entry key="valid_until_ISO" value-ref="validUntil_aggregate_ISO"/>
</map>
</property>
</bean>
Expand Down
4 changes: 4 additions & 0 deletions mdx/incommon/mdq-all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
<map>
<entry key="extraText" value="Contains InCommon and eduGAIN metadata" />
<entry key="publisher" value-ref="us_incommon_registrar" />
<entry key="validityDays" value="${validUntil.aggregate.days}"/>
<entry key="now_ISO" value-ref="now_ISO"/>
<entry key="now_local_ISO" value-ref="now_local_ISO"/>
<entry key="valid_until_ISO" value-ref="validUntil_aggregate_ISO"/>
</map>
</property>
</bean>
Expand Down
4 changes: 4 additions & 0 deletions mdx/incommon/sign.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<map>
<entry key="extraText" value="Contains InCommon and eduGAIN metadata"/>
<entry key="publisher" value-ref="us_incommon_registrar"/>
<entry key="validityDays" value="${validUntil.aggregate.days}"/>
<entry key="now_ISO" value-ref="now_ISO"/>
<entry key="now_local_ISO" value-ref="now_local_ISO"/>
<entry key="valid_until_ISO" value-ref="validUntil_aggregate_ISO"/>
</map>
</property>
</bean>
Expand Down

0 comments on commit f709d62

Please sign in to comment.