summaryrefslogtreecommitdiff
path: root/xslt/sp-summary.xslt
blob: e630c9540424048e35d00a93ad72533e7ce35486 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:shibmeta="urn:mace:shibboleth:metadata:1.0"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
                xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
		xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
		xmlns:samla="urn:oasis:names:tc:SAML:2.0:assertion"
                xmlns:exsl="http://exslt.org/common"
                extension-element-prefixes="exsl"
		xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
                xmlns:shibmd="urn:mace:shibboleth:metadata:1.0">

  <xsl:output method="text"/>
  <xsl:variable name="eol">
<xsl:text>|</xsl:text><xsl:text>
</xsl:text>
  </xsl:variable>
  
  <xsl:template name="entity-name">
    <xsl:variable name="h"><xsl:value-of select="substring-after(@entityID,'://')"/></xsl:variable>
    <xsl:if test="contains($h,'/')">
      <xsl:value-of select="substring-before($h,'/')"/>
    </xsl:if>
    <xsl:if test="not(contains($h,'/'))">
      <xsl:value-of select="$h"/>
    </xsl:if> 
  </xsl:template>

  <xsl:template match="/md:EntitiesDescriptor">
    <xsl:text>||EntityID||Service Name||Organization||Contacts||Entity Categories||Assurance Certification||Registration Authority||
</xsl:text>
    <xsl:apply-templates select="md:EntityDescriptor[md:SPSSODescriptor]"/>
  </xsl:template>

  <xsl:template match="md:EntityDescriptor">
     <xsl:text> | </xsl:text><xsl:value-of select="@entityID"/>
     <xsl:text> | </xsl:text>
     	<xsl:apply-templates select="md:SPSSODescriptor/md:AttributeConsumingService/md:ServiceName"/><xsl:text> \\ </xsl:text>
        <xsl:apply-templates select="md:SPSSODescriptor/md:AttributeConsumingService/md:ServiceDescription"/>
     <xsl:text> | </xsl:text><xsl:apply-templates select="md:Organization"/>
     <xsl:text> | </xsl:text>
     	<xsl:apply-templates select="md:ContactPerson[@contactType='technical']"/>
     	<xsl:apply-templates select="md:ContactPerson[@contactType='administrative']"/>
     	<xsl:apply-templates select="md:ContactPerson[@contactType='support']"/>
     	<xsl:apply-templates select="md:ContactPerson[@contactType='other']"/>
     <xsl:text> | </xsl:text><xsl:apply-templates select="md:Extensions/mdattr:EntityAttributes/samla:Attribute[@Name='http://macedir.org/entity-category']/samla:AttributeValue"/>
     <xsl:text> | </xsl:text><xsl:apply-templates select="md:Extensions/mdattr:EntityAttributes/samla:Attribute[@Name='urn:oasis:names:tc:SAML:attribute:assurance-certification']/samla:AttributeValue"/><xsl:text> </xsl:text>
     <xsl:text> | </xsl:text><xsl:apply-templates select="md:Extensions/mdrpi:RegistrationInfo"/>
     <xsl:text> |
</xsl:text>
  </xsl:template>

  <xsl:template match="mdrpi:RegistrationInfo">
    <xsl:value-of select="@registrationAuthority"/><xsl:text> </xsl:text>
  </xsl:template>

  <xsl:template match="md:AttributeConsumingService">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="md:ServiceName|md:ServiceDescription">
     <xsl:call-template name="string-replace-all">
       <xsl:with-param name="text" select="text()" />
       <xsl:with-param name="replace" select="'|'" />
       <xsl:with-param name="by" select="'\|'" />
     </xsl:call-template>
  </xsl:template>

  <xsl:template match="samla:AttributeValue">
     <xsl:call-template name="string-replace-all">
       <xsl:with-param name="text" select="text()" />
       <xsl:with-param name="replace" select="'-'" />
       <xsl:with-param name="by" select="'-'" />
     </xsl:call-template>
     <xsl:text> \\</xsl:text>
  </xsl:template> 

  <xsl:template match="md:ContactPerson">
    <xsl:value-of select="@contactType"/><xsl:text>: </xsl:text><xsl:apply-templates select="md:EmailAddress"/>
  </xsl:template> 

  <xsl:template match="md:Organization">
    <xsl:text>[</xsl:text>
    <xsl:apply-templates select="md:OrganizationDisplayName[1]"/><xsl:text>|</xsl:text>
    <xsl:apply-templates select="md:OrganizationURL[1]"/><xsl:text>]</xsl:text>
  </xsl:template>

  <xsl:template match="md:SPPSSODescriptor">
    <xsl:apply-templates select="md:Extensions/shibmd:Scope"/>
  </xsl:template>

  <xsl:template match="md:EmailAddress">
     <xsl:text>[</xsl:text><xsl:value-of select="text()"/><xsl:text>] \\</xsl:text>
  </xsl:template>

  <xsl:template match="md:OrganizationDisplayName">
     <xsl:value-of select="normalize-space(text())"/>
  </xsl:template>

  <xsl:template match="md:OrganizationURL">
     <xsl:value-of select="normalize-space(text())"/>
  </xsl:template>

  <xsl:template match="shibmd:Scope">
     <xsl:value-of select="text()"/><xsl:text> </xsl:text>
  </xsl:template>


  <xsl:template match="*"/>
  <xsl:template match="text()"/>

  <xsl:template name="string-replace-all">
    <xsl:param name="text" />
    <xsl:param name="replace" />
    <xsl:param name="by" />
    <xsl:choose>
      <xsl:when test="contains($text, $replace)">
        <xsl:value-of select="substring-before($text,$replace)" />
        <xsl:value-of select="$by" />
        <xsl:call-template name="string-replace-all">
          <xsl:with-param name="text" select="substring-after($text,$replace)" />
          <xsl:with-param name="replace" select="$replace" />
          <xsl:with-param name="by" select="$by" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>