Skip to content

Commit

Permalink
Generate statistics for SPs with RequestedAttribute elements
Browse files Browse the repository at this point in the history
See ukf/ukf-meta#276 for details
  • Loading branch information
Alex Stuart committed Nov 8, 2020
1 parent d8d058d commit b30d65d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
43 changes: 43 additions & 0 deletions charting/requestedattribute.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env perl

#
# requestedattribute.pl
#
# Extracts statistics about SPs with RequestedAttribute elements from the published metadata.
#
use warnings;
use lib ".";
use Months;

# Parse command line arguments
use Getopt::Long;
my $allMonths;
my $oneYear;
GetOptions('all' => \$allMonths, 'year' => \$oneYear);

# By default, only show results for the most recent month
if ($allMonths) {
# leave table intact
} elsif ($oneYear) {
# reduce months table to just the last 12 entries
@months = @months[-12..-1];
} else {
# reduce months table to one element
@months = @months[-1..-1];
}

# print header. must be kept in sync with what comes out of requestedattribute.xsl
print "# month, number of SPs, number with AttributeConsumingService, percent with ACS\n";

# ingest files
foreach $month (@months) {
my $fn = "cache/$month.xml";
open(TXT, "xsltproc requestedattribute.xsl $fn|") || die "could not open input file";
($sps, $acs) = split /\t/, <TXT>;
chomp $acs;
$proportion = 0;
if ( $sps > 0 ) { $proportion = int (100 * $acs / $sps) ; }
print "${month}\t${sps}\t${acs}\t${proportion}\n";
close TXT;
}

37 changes: 37 additions & 0 deletions charting/requestedattribute.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
requestedattribute.xsl
Takes a metadata aggregate and gives statistics about RequestedAttribute
elements in UKf-registered SPs.
Note that UKf metadata started using mdrpi:RegistrationInfo in 2012-09
so statistics before that date cannot be generated by this script.
-->
<xsl:stylesheet
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"
version="1.0">

<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:template match="/md:EntitiesDescriptor">

<xsl:variable name="sps" select="//md:EntityDescriptor
[descendant::mdrpi:RegistrationInfo/@registrationAuthority='http://ukfederation.org.uk']
[md:SPSSODescriptor]
"/>
<xsl:variable name="ACS" select="count($sps[md:SPSSODescriptor/md:AttributeConsumingService])"/>

<xsl:value-of select="count($sps)"/>
<xsl:text>&#09;</xsl:text>
<xsl:value-of select="$ACS"/>
<xsl:text>&#10;</xsl:text>

</xsl:template>

</xsl:stylesheet>

0 comments on commit b30d65d

Please sign in to comment.