From 71814e31270abcb0cc650155aab9b3eaf4f3a658 Mon Sep 17 00:00:00 2001 From: Alex Stuart Date: Tue, 28 Jan 2014 18:07:37 +0000 Subject: [PATCH] Bugfixes: don't fail when reading metadata without MDRPI information; and fix option for outputting entityID only (it is now --idonly) --- build/query-entities.pl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/build/query-entities.pl b/build/query-entities.pl index e54f85f6..917d4b35 100755 --- a/build/query-entities.pl +++ b/build/query-entities.pl @@ -14,15 +14,15 @@ sub help { print<<'EOF'; -usage: query-entities.pl [--help] [--head] [--entityID] [--idp] [--sp] [--reg ] [--notreg ] +usage: query-entities.pl [--help] [--head] [--idonly] [--idp] [--sp] [--reg ] [--notreg ] Outputs the entityID, display name(s) and other information about entities in the given SAML metadata aggregate file. --help - prints this help and exits --head - prints out a header for the CSV file ---entityID - outputs a list of entityIDs only - (can only have one of --head and --entityID specified) +--idonly - outputs a list of entityIDs only + (can only have one of --head and --idonly specified) --idp - only outputs IdPs --sp - only outputs SPs @@ -51,7 +51,7 @@ sub help { my $notreg; my $help; my $head; -my $entityID; +my $idonly; my $result = GetOptions( "idp" => \$idp, @@ -60,7 +60,7 @@ sub help { "notreg=s" => \$notreg, "help" => \$help, "head" => \$head, - "entityID" => \$entityID + "idonly" => \$idonly ); if ($help) { @@ -97,8 +97,8 @@ sub help { } # Can only have one of --head and --entityID -if ( $head && $entityID ) { - print "\nError: can only have one of --head and --entityID set at the same time\n"; +if ( $head && $idonly ) { + print "\nError: can only have one of --head and --idonly set at the same time\n"; help(); exit 3 } @@ -167,8 +167,15 @@ () } $registrationAuthority = "No registrationAuthority found"; - if ( $temp = $section->first_child('Extensions')->first_child('mdrpi:RegistrationInfo')->{'att'}->{'registrationAuthority'} ) { - $registrationAuthority = $temp; + # Even though eduGAIN Metadata profile says entities MUST have MDRPI, turns out the eduGAIN aggregate does not enforce this rule. However, the eduGAIN site allows people to validate federations' incoming aggregates. See http://www.edugain.org/technical/status.php and go to countries' entry 'validate this metadata set' + if ( $section->first_child('Extensions')) { + if ( $section->first_child('Extensions')->first_child('mdrpi:RegistrationInfo') ) { + if ( $section->first_child('Extensions')->first_child('mdrpi:RegistrationInfo')->{'att'} ) { + if ( $section->first_child('Extensions')->first_child('mdrpi:RegistrationInfo')->{'att'}->{'registrationAuthority'} ) { + $registrationAuthority = $section->first_child('Extensions')->first_child('mdrpi:RegistrationInfo')->{'att'}->{'registrationAuthority'}; + } + } + } } if ( $notreg && $notreg eq $registrationAuthority ) { return; } @@ -179,7 +186,7 @@ () if ( $section->first_child('SPSSODescriptor') ) { $type = "SP"; } if ( ($sp && $type eq "SP") || ($idp && $type eq "IdP") ) { - if ($entityID) { + if ($idonly) { print "$entityID\n"; } else { print "$type, $entityID, $registrationAuthority, \"$ODN\", $URL\n"