Skip to content

Commit

Permalink
Add a common XSLT transform for cleaning imported metadata from other…
Browse files Browse the repository at this point in the history
… metadata sources.
  • Loading branch information
iay committed Apr 9, 2011
1 parent fb3f305 commit f53fe34
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
48 changes: 48 additions & 0 deletions feds/clean_import.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
clean_import.xsl
Clean up imported metadata from a metadata exchange channel.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:elab="http://eduserv.org.uk/labels"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:wayf="http://sdss.ac.uk/2006/06/WAYF"
xmlns:ukfedlabel="http://ukfederation.org.uk/2006/11/label"

xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
exclude-result-prefixes="elab ukfedlabel wayf">

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

<!-- strip everything from certain namespaces -->
<xsl:template match="elab:*"/>
<xsl:template match="ukfedlabel:*"/>
<xsl:template match="wayf:*"/>

<!-- strip redundant attributes from EntityDescriptor elements -->
<xsl:template match="md:EntityDescriptor/@ID"/>
<xsl:template match="md:EntityDescriptor/@cacheDuration"/>
<xsl:template match="md:EntityDescriptor/@validUntil"/>

<!-- strip xml:base entirely -->
<xsl:template match="@xml:base"/>

<!--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>
16 changes: 16 additions & 0 deletions feds/common_beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@
</property>
</bean>

<!--
cleanImport
A pipeline stage that can be used in an import pipeline to clean up the metadata
presented, for example by removing redundant attributes or elements which only have
meaning when added by the UK federation registrar.
-->
<bean id="cleanImport" class="net.shibboleth.metadata.dom.stage.XSLTStage">
<property name="id" value="cleanImport"/>
<property name="xslResource">
<bean class="org.opensaml.util.resource.FilesystemResource">
<constructor-arg value="#{ systemProperties['basedir'] }/feds/clean_import.xsl"/>
</bean>
</property>
</bean>

<!--
<bean id="members" class="uk.org.ukfederation.members.Members">
<constructor-arg>
Expand Down
1 change: 1 addition & 0 deletions feds/edugain/import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<list>
<ref bean="fetchEduGainExportAggregate"/>
<ref bean="checkEdugainSignature"/>
<ref bean="cleanImport"/>
<ref bean="disassemble"/>
<ref bean="checkSchemas"/>
<ref bean="assemble"/>
Expand Down
1 change: 1 addition & 0 deletions feds/edugate/import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<list>
<ref bean="fetchEdugateExportAggregate"/>
<ref bean="checkEdugateSignature"/>
<ref bean="cleanImport"/>
<ref bean="disassemble"/>
<ref bean="checkSchemas"/>
<ref bean="assemble"/>
Expand Down

0 comments on commit f53fe34

Please sign in to comment.