Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
List all R&S IdPs and SPs
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
*.csv | ||
*.xlsx | ||
*.xml.* | ||
~* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2018 Internet2 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<!-- | ||
list_all_RandS_IdPs_csv.xsl | ||
This XSL transform takes a SAML metadata aggregate, matches on every | ||
entity descriptor with an R&S IdP or SP entity attribute, and produces a | ||
CSV file with the following fields: | ||
1. Entity ID: @entityID | ||
2. Entity Type: "IdP" or "SP" | ||
3. R&S Support Level: "global" or "local" | ||
4. Registrar ID: @registrationAuthority | ||
Note that either of the last two fields may be blank, in which case | ||
the word "NONE" is output. | ||
--> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
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"> | ||
|
||
<!-- search-and-replace constants --> | ||
<xsl:variable name="double_quote" select="'"'"/> | ||
<xsl:variable name="double_double_quote" select="'""'"/> | ||
|
||
<!-- output is plain text --> | ||
<xsl:output method="text"/> | ||
|
||
<!-- output the heading line --> | ||
<xsl:template match="/"> | ||
<xsl:text>Entity ID	Entity Type	Support Level	Registrar ID</xsl:text> | ||
<xsl:text>
</xsl:text> | ||
<xsl:apply-templates/> | ||
</xsl:template> | ||
|
||
<!-- match all entity descriptors with an RandS IdP entity attribute --> | ||
<xsl:template match="//md:EntityDescriptor[md:Extensions/mdattr:EntityAttributes/saml:Attribute[@Name='http://macedir.org/entity-category-support']/saml:AttributeValue[text()='http://refeds.org/category/research-and-scholarship' or text()='http://id.incommon.org/category/research-and-scholarship']]"> | ||
|
||
<!-- output the entityID --> | ||
<xsl:value-of select="@entityID"/> | ||
|
||
<xsl:text>	IdP</xsl:text> | ||
|
||
<!-- output "global" or "local" depending on the value of the entity attribute --> | ||
<xsl:text>	</xsl:text> | ||
<xsl:choose> | ||
<xsl:when test="md:Extensions/mdattr:EntityAttributes/saml:Attribute[@Name='http://macedir.org/entity-category-support']/saml:AttributeValue[text()='http://refeds.org/category/research-and-scholarship']"> | ||
<xsl:text>global</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>local</xsl:text> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
|
||
<!-- output the registrar ID --> | ||
<xsl:text>	</xsl:text> | ||
<xsl:value-of select="md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority"/> | ||
|
||
<xsl:text>
</xsl:text> | ||
</xsl:template> | ||
|
||
<!-- match all entity descriptors with the RandS SP entity attribute --> | ||
<xsl:template match="//md:EntityDescriptor[md:Extensions/mdattr:EntityAttributes/saml:Attribute[@Name='http://macedir.org/entity-category']/saml:AttributeValue[text()='http://refeds.org/category/research-and-scholarship']]"> | ||
|
||
<!-- output the entityID --> | ||
<xsl:value-of select="@entityID"/> | ||
|
||
<xsl:text>	SP</xsl:text> | ||
|
||
<!-- output "global" or "local" depending on the value of the entity attribute --> | ||
<xsl:text>	</xsl:text> | ||
<xsl:choose> | ||
<xsl:when test="md:Extensions/mdattr:EntityAttributes/saml:Attribute[@Name='http://macedir.org/entity-category']/saml:AttributeValue[text()='http://refeds.org/category/research-and-scholarship']"> | ||
<xsl:text>global</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>local</xsl:text> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
|
||
<!-- output the registrar ID --> | ||
<xsl:text>	</xsl:text> | ||
<xsl:value-of select="md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority"/> | ||
|
||
<xsl:text>
</xsl:text> | ||
</xsl:template> | ||
|
||
<!-- | ||
A named template that performs global (recursive) search-and-replace on a string | ||
(similar to fn:replace(string, pattern, replace) in XSLT 2.0). | ||
See: http://stackoverflow.com/questions/3067113/xslt-string-replace/3067130#3067130 | ||
--> | ||
<xsl:template name="string-replace-all"> | ||
<xsl:param name="string"/> | ||
<xsl:param name="search"/> | ||
<xsl:param name="replace"/> | ||
<xsl:choose> | ||
<xsl:when test="$string = '' or $search = '' or not($search)"> | ||
<!-- Prevent this routine from hanging --> | ||
<xsl:value-of select="$string"/> | ||
</xsl:when> | ||
<xsl:when test="contains($string, $search)"> | ||
<xsl:value-of select="substring-before($string, $search)"/> | ||
<xsl:value-of select="$replace"/> | ||
<xsl:call-template name="string-replace-all"> | ||
<xsl:with-param name="string" select="substring-after($string, $search)"/> | ||
<xsl:with-param name="search" select="$search"/> | ||
<xsl:with-param name="replace" select="$replace"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$string"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<xsl:template match="text()"> | ||
<!-- do nothing --> | ||
</xsl:template> | ||
</xsl:stylesheet> |