Skip to content

Commit

Permalink
Add a framework for experimenting with revised trust fabrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
iay committed Oct 27, 2009
1 parent 2e75e80 commit c3c6958
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 0 deletions.
46 changes: 46 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,52 @@
o="${md.wayf.unsigned}"/>
</target>

<!--
***********************************************************
*** ***
*** T E S T M E T A D A T A G E N E R A T I O N ***
*** ***
***********************************************************
-->

<property name="test.master.file" value="test-metadata-master.xml"/>
<property name="test.prod.unsigned" value="test-metadata.xml"/>

<!--
Generates a set of test metadata based on the same trust roots
(plus any local modifications) and a set of designated test
entities.
-->
<target name="gen.test">
<!--
Concatenate the entity fragment files named testNNNNNN.xml into
an entities list.
-->
<echo>Composing entity fragment files.</echo>
<concat destfile="${entities.file}" append="no" force="yes" fixlastline="no">
<header filtering="no">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#10;&lt;Entities&gt;&#10;</header>
<fileset dir="${entities.dir}" includes="test*.xml"/>
<footer>&lt;/Entities&gt;&#10;</footer>
<filterchain>
<replaceregex pattern="&lt;\?[xX][mM][lL] .*&gt;" />
</filterchain>
</concat>

<!--
Combine the entity list with the trust roots.
-->
<echo>Generating test federation master file.</echo>
<XALAN x="master_ukfederation.xsl" i="${master.file.name}"
o="${test.master.file}" />
<CHECK i="${xml.dir}/${test.master.file}" s="check.xsl"/>

<!--
Process through to final form.
-->
<XALAN x="test_master_unsigned.xsl" i="${test.master.file}"
o="${test.prod.unsigned}" />
</target>

<!--
*********************************************
*** ***
Expand Down
128 changes: 128 additions & 0 deletions build/test_master_unsigned.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
test_master_unsigned.xsl
XSL stylesheet that takes the test federation master file containing all information
about federation entities and removes information not destined to be published.
Author: Ian A. Young <ian@iay.org.uk>
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:shibmeta="urn:mace:shibboleth:metadata:1.0"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wayf="http://sdss.ac.uk/2006/06/WAYF"
xmlns:uklabel="http://ukfederation.org.uk/2006/11/label"

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"
exclude-result-prefixes="wayf">

<!--Force UTF-8 encoding for the output.-->
<xsl:output omit-xml-declaration="no" method="xml" encoding="UTF-8" indent="yes"/>

<!--
validityDays
This parameter determines the number of days between the aggregation instant and the
end of validity of the signed metadata.
-->
<xsl:variable name="validityDays" select="14"/>

<xsl:variable name="now" select="date:date-time()"/>
<xsl:variable name="validUntil" select="mdxDates:dateAdd($now, $validityDays)"/>

<!--
Document root.
-->
<xsl:template match="/">
<xsl:call-template name="document.comment"/>
<xsl:apply-templates/>
</xsl:template>

<!--
Document element.
-->
<xsl:template match="/md:EntitiesDescriptor">
<xsl:copy>
<xsl:attribute name="validUntil">
<xsl:value-of select="$validUntil"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:call-template name="document.comment"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

<!--
Replace the aggregate Name with one making it distinct from the
main UK federation metadata aggregates.
-->
<xsl:template match="/md:EntitiesDescriptor/@Name">
<xsl:attribute name="Name">http://ukfederation.org.uk/test</xsl:attribute>
</xsl:template>

<!--
Comment to be added to the top of the document, and just inside the document element.
-->
<xsl:template name="document.comment">
<xsl:comment>
<xsl:text>&#10;&#9;T E S T F E D E R A T I O N M E T A D A T A&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#9;Aggregate built </xsl:text>
<xsl:value-of select="$now"/>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#9;Aggregate valid for </xsl:text>
<xsl:value-of select="$validityDays"/>
<xsl:text> days, until </xsl:text>
<xsl:value-of select="$validUntil"/>
<xsl:text>&#10;</xsl:text>
</xsl:comment>
</xsl:template>

<!--
Pass through certain uklabel namespace elements.
-->
<xsl:template match="uklabel:UKFederationMember |
uklabel:SDSSPolicy |
uklabel:AccountableUsers">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<!--
Strip all other uklabel namespace elements entirely.
-->
<xsl:template match="uklabel:*">
<!-- do nothing -->
</xsl:template>

<!--
Remove administrative contacts.
-->
<xsl:template match="md:ContactPerson[@contactType='administrative']">
<!-- do nothing -->
</xsl:template>

<!--By default, copy text blocks, comments and attributes unchanged.-->
<xsl:template match="text()|comment()|@*">
<xsl:copy/>
</xsl:template>

<!--By default, copy all elements from the input to the output, along with their attributes and contents.-->
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

0 comments on commit c3c6958

Please sign in to comment.