summaryrefslogtreecommitdiff
path: root/metadata/xslt/normalize.xsl
diff options
context:
space:
mode:
Diffstat (limited to 'metadata/xslt/normalize.xsl')
-rw-r--r--metadata/xslt/normalize.xsl118
1 files changed, 118 insertions, 0 deletions
diff --git a/metadata/xslt/normalize.xsl b/metadata/xslt/normalize.xsl
new file mode 100644
index 00000000..f3c086ac
--- /dev/null
+++ b/metadata/xslt/normalize.xsl
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ xmlns:exsl="http://exslt.org/common"
+ xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
+ extension-element-prefixes="exsl"
+ xmlns:shibmd="urn:mace:shibboleth:metadata:1.0">
+
+ <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
+
+ <xsl:template match="/md:EntitiesDescriptor">
+ <xsl:if test="$tou='true'"><xsl:comment>
+
+ IMPORTANT NOTICE: READ CAREFULLY
+
+You are reading this because You wish to use the technical information (the “Metadata”)
+published on behalf of the Registrars. These Terms of Access and Use (these “Terms”) govern
+the use of the Metadata. By accessing or using the Metadata You accept that the access and
+use will be on and subject to these Terms. These Terms will be binding and enforceable on
+You as contractual obligations.
+
+The SWAMID Metadata Terms of Access and Use can be found here:
+
+- http://mds.swamid.se/md/swamid-tou-sv.txt Swedish version - Legally Binding!
+- http://mds.swamid.se/md/swamid-tou-en.txt English version - Non-normative translation
+
+If You do not accept these Terms, then You must not continue to use this Metadata.
+
+ </xsl:comment></xsl:if>
+ <md:EntitiesDescriptor>
+ <xsl:attribute name="ID"><xsl:value-of select="$ID"/></xsl:attribute>
+ <xsl:attribute name="Name">
+ <xsl:choose>
+ <xsl:when test="$target"><xsl:value-of select="$target"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="@Name"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:if test="@cacheDuration">
+ <xsl:attribute name="cacheDuration"><xsl:value-of select="@cacheDuration"/></xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@validUntil">
+ <xsl:attribute name="validUntil"><xsl:value-of select="$date"/></xsl:attribute>
+ </xsl:if>
+ <xsl:if test="$target">
+ <md:Extensions><xsl:call-template name="add-swamid-pi"/></md:Extensions>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </md:EntitiesDescriptor>
+ </xsl:template>
+
+ <xsl:template match="md:EntityDescriptor">
+ <xsl:variable name="path"><xsl:value-of select="substring-after(@entityID,'://')"/></xsl:variable>
+ <xsl:variable name="host">
+ <xsl:if test="contains($path,'/')">
+ <xsl:value-of select="substring-before($path,'/')"/>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'/'))">
+ <xsl:value-of select="$path"/>
+ </xsl:if>
+ </xsl:variable>
+ <xsl:variable name="domain">
+ <xsl:value-of select="substring-after($host,'.')"/>
+ </xsl:variable>
+ <md:EntityDescriptor>
+ <xsl:apply-templates select="@*"/>
+ <xsl:if test="$rpi='true' and not(md:Extensions)">
+ <md:Extensions><xsl:call-template name="add-swamid-ri"/></md:Extensions>
+ </xsl:if>
+ <xsl:apply-templates select="text()|comment()|md:Extensions|md:RoleDescriptor|md:IDPSSODescriptor|md:SPSSODescriptor|md:AuthnAuthorityDescriptor|md:AttributeAuthorityDescriptor|md:PDPDescriptor|md:AffiliationDescriptor"/>
+ <xsl:apply-templates select="md:Organization"/>
+ <xsl:if test="$defaultContact='true' and not(md:ContactPerson)">
+ <md:ContactPerson contactType="technical"><md:EmailAddress>operations@swamid.se</md:EmailAddress></md:ContactPerson>
+ </xsl:if>
+ <xsl:apply-templates select="md:ContactPerson"/>
+ <xsl:apply-templates select="md:AdditionalMetadataLocation"/>
+ </md:EntityDescriptor>
+ </xsl:template>
+
+ <xsl:template match="md:EntityDescriptor/md:Extensions">
+ <md:Extensions>
+ <xsl:call-template name="add-swamid-ri"/>
+ <xsl:apply-templates select="text()|comment()|node()"/>
+ </md:Extensions>
+ </xsl:template>
+
+ <xsl:template name="add-swamid-ri">
+ <xsl:if test="$rpi='true' and not(mdrpi:RegistrationInfo[@registrationAuthority])">
+ <mdrpi:RegistrationInfo registrationAuthority="http://www.swamid.se/">
+ <mdrpi:RegistrationPolicy xml:lang="en">http://swamid.se/policy/mdrps</mdrpi:RegistrationPolicy>
+ </mdrpi:RegistrationInfo>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="add-swamid-pi">
+ <mdrpi:PublicationInfo>
+ <xsl:attribute name="creationInstant"><xsl:value-of select="$now"/></xsl:attribute>
+ <xsl:attribute name="publisher"><xsl:value-of select="$target"/></xsl:attribute>
+ <mdrpi:UsagePolicy xml:lang="en">https://mds.swamid.se/md/swamid-tou-en.txt</mdrpi:UsagePolicy>
+ </mdrpi:PublicationInfo>
+ </xsl:template>
+
+ <xsl:template match="@xml:base|@ID|@validUntil|@cacheDuration"/>
+
+ <xsl:template match="text()|comment()|@*">
+ <xsl:copy/>
+ </xsl:template>
+
+ <xsl:template match="*">
+ <xsl:copy>
+ <xsl:apply-templates select="node()|@*"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>