-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate statistics for SPs with RequestedAttribute elements
See ukf/ukf-meta#276 for details
- Loading branch information
Alex Stuart
committed
Nov 8, 2020
1 parent
d8d058d
commit b30d65d
Showing
2 changed files
with
80 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,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; | ||
} | ||
|
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,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>	</xsl:text> | ||
<xsl:value-of select="$ACS"/> | ||
<xsl:text> </xsl:text> | ||
|
||
</xsl:template> | ||
|
||
</xsl:stylesheet> |