Created
October 9, 2016 14:24
-
-
Save trscavo/f766a88ff5feb5937e5be5a16a1ff0c0 to your computer and use it in GitHub Desktop.
Count the SAML entities in a SAML V2.0 metadata file
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
count_entity_roles.xsl | |
An XSL transform that takes a SAML V2.0 metadata file and | |
counts entities with various roles and characteristics. | |
Usage: | |
$ MD_PATH=/path/to/saml/metadata.xml | |
$ LIB_DIR=/path/to/source/lib/dir | |
$ cat $MD_PATH | xsltproc $LIB_DIR/count_entity_roles.xsl - | |
5703,3713,2784,1991,424 | |
The output may be interpreted as follows: | |
1. # of entities | |
2. # of entities with an SP role | |
3. # of entities with an SP role that were registered by InCommon | |
4. # of entities with an IdP role | |
5. # of entities with an IdP role that were registered by InCommon | |
Note: An entity may have both an IdP role and an SP role. | |
--> | |
<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:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<!-- Output is plain text --> | |
<xsl:output method="text"/> | |
<xsl:template match="/"> | |
<xsl:value-of select="count(//md:EntityDescriptor)"/> | |
<xsl:text>,</xsl:text> | |
<xsl:value-of select="count(//md:EntityDescriptor[md:SPSSODescriptor])"/> | |
<xsl:text>,</xsl:text> | |
<xsl:value-of select="count(//md:EntityDescriptor[md:SPSSODescriptor and (not(md:Extensions/mdrpi:RegistrationInfo) or md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority = 'https://incommon.org')])"/> | |
<xsl:text>,</xsl:text> | |
<xsl:value-of select="count(//md:EntityDescriptor[md:IDPSSODescriptor])"/> | |
<xsl:text>,</xsl:text> | |
<xsl:value-of select="count(//md:EntityDescriptor[md:IDPSSODescriptor and (not(md:Extensions/mdrpi:RegistrationInfo) or md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority = 'https://incommon.org')])"/> | |
<xsl:text> </xsl:text> | |
</xsl:template> | |
<xsl:template match="text()"> | |
<!-- do nothing --> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment