Skip to content

Commit

Permalink
Rework production of test aggregate by moving namespace normalisation…
Browse files Browse the repository at this point in the history
… out into a second XSLT transform which we can then apply to anything we're about to sign and publish.
  • Loading branch information
iay committed May 17, 2011
1 parent 82d4785 commit 58c43eb
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 48 deletions.
10 changes: 8 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,14 @@
<CHECK.publishable i="${xml.dir}/${md.prod.unsigned}"/>

<!-- [27] -->
<XALAN.xmldir x="uk_master_test.xsl" i="${uk.master.file}"
o="${md.test.unsigned}" />
<XALAN
x="${build.dir}/uk_master_test.xsl"
i="${xml.dir}/${uk.master.file}"
o="${temp.xml}" />
<XALAN
x="${build.dir}/ns_norm_uk.xsl"
i="${temp.xml}"
o="${xml.dir}/${md.test.unsigned}"/>
<MDNORM i="${md.test.unsigned}"/>
<CHECK.publishable i="${xml.dir}/${md.test.unsigned}"/>

Expand Down
117 changes: 117 additions & 0 deletions build/ns_norm_uk.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
ns_norm_fragment.xsl
Normalise the namespaces in a metadata file for publication to UK federation members.
The main constraint on the output of this transform is that it should minimise the size
of the output file while not having "too many" namespace prefix definitions in scope
at any point in the document. "Too many" is more than about ten, as a result of a bug
in the metadatatool application used by Shibboleth 1.3 IdPs to download and verify
metadata.
The strategy is to define the most commonly-used prefixes in the document element.
Prefixes which are less often used, but which may be used by container elements
(e.g., mdui:) or for attributes are normalised to use a prefix, but not declared
on the document element.
Prefixes which are less often used and are only used for non-containers can be
normalised to non-prefix use (i.e., to redefine the default namespace) if required
to cut the numbers down.
Author: Ian A. Young <ian@iay.org.uk>
-->
<xsl:stylesheet version="1.0"
xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:elab="http://eduserv.org.uk/labels"
xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol"
xmlns:init="urn:oasis:names:tc:SAML:profiles:SSO:request-init"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
xmlns:ukfedlabel="http://ukfederation.org.uk/2006/11/label"
xmlns:wayf="http://sdss.ac.uk/2006/06/WAYF"

exclude-result-prefixes="alg md mdattr mdrpi saml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:oasis:names:tc:SAML:2.0:metadata">


<!--
Import templates for basic normalisation.
-->
<xsl:import href="ns_norm.xsl"/>


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


<!--
*******************************************
*** ***
*** D O C U M E N T E L E M E N T ***
*** ***
*******************************************
-->


<!--
We need to handle the document element specially in order to arrange
for all appropriate namespace prefix definitions to appear on it.
There are only two possible document elements in SAML metadata.
-->


<!--
Document element is <EntityDescriptor>.
-->
<xsl:template match="/md:EntityDescriptor">
<EntityDescriptor>
<xsl:apply-templates select="node()|@*"/>
</EntityDescriptor>
</xsl:template>

<!--
Document element is <EntitiesDescriptor>.
-->
<xsl:template match="/md:EntitiesDescriptor">
<EntitiesDescriptor>
<xsl:apply-templates select="node()|@*"/>
</EntitiesDescriptor>
</xsl:template>


<!--
*************************************
*** ***
*** A L G N A M E S P A C E ***
*** ***
*************************************
-->


<!--
alg:*
Normalise namespace to not use a prefix.
-->
<xsl:template match="alg:*">
<xsl:element name="{local-name()}" namespace="urn:oasis:names:tc:SAML:metadata:algsupport">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>


</xsl:stylesheet>
50 changes: 4 additions & 46 deletions build/uk_master_test.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -155,64 +155,22 @@


<!--
Normalise and pass through certain ukfedlabel namespace elements.
Pass through certain ukfedlabel namespace elements.
-->

<xsl:template match="ukfedlabel:UKFederationMember">
<xsl:element name="ukfedlabel:UKFederationMember">
<xsl:template match="ukfedlabel:UKFederationMember | ukfedlabel:AccountableUsers">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:copy>
</xsl:template>

<xsl:template match="ukfedlabel:AccountableUsers">
<xsl:element name="ukfedlabel:AccountableUsers">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>

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

<!--
Normalise namespace on IdP discovery elements.
-->

<xsl:template match="idpdisc:DiscoveryResponse">
<idpdisc:DiscoveryResponse>
<xsl:apply-templates select="node()|@*"/>
</idpdisc:DiscoveryResponse>
</xsl:template>

<!--
Normalise namespace on Athens PUID elements.
-->

<xsl:template match="elab:AthensPUIDAuthority">
<elab:AthensPUIDAuthority>
<xsl:apply-templates select="node()|@*"/>
</elab:AthensPUIDAuthority>
</xsl:template>

<!--
Normalise namespace on Shibboleth metadata elements.
-->

<xsl:template match="shibmd:Scope">
<shibmd:Scope>
<xsl:apply-templates select="node()|@*"/>
</shibmd:Scope>
</xsl:template>

<xsl:template match="shibmd:KeyAuthority">
<shibmd:KeyAuthority>
<xsl:apply-templates select="node()|@*"/>
</shibmd:KeyAuthority>
</xsl:template>

<!--
Remove administrative contacts.
-->
Expand Down

0 comments on commit 58c43eb

Please sign in to comment.