summaryrefslogtreecommitdiff
path: root/xslt/add-rpi.xsl
blob: 687ba626e0cf7afe91abbcd7fa10dd7471d995c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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:exsl="http://exslt.org/common"
                xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
		xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport"
                xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
		xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
                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:EntityDescriptor">
    <md:EntityDescriptor>
       <xsl:apply-templates select="@*"/>
       <xsl:if test="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: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="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 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>