Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Bugfixes: don't fail when reading metadata without MDRPI information;…
Browse files Browse the repository at this point in the history
… and fix option for outputting entityID only (it is now --idonly)
  • Loading branch information
Alex Stuart authored and Alex Stuart committed Jan 28, 2014
1 parent 7e6bf6b commit 71814e3
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions build/query-entities.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
sub help {
print<<'EOF';
usage: query-entities.pl [--help] [--head] [--entityID] [--idp] [--sp] [--reg <registrationAuthority>] [--notreg <registrationAuthority>] <file>
usage: query-entities.pl [--help] [--head] [--idonly] [--idp] [--sp] [--reg <registrationAuthority>] [--notreg <registrationAuthority>] <file>
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
Expand Down Expand Up @@ -51,7 +51,7 @@ sub help {
my $notreg;
my $help;
my $head;
my $entityID;
my $idonly;

my $result = GetOptions(
"idp" => \$idp,
Expand All @@ -60,7 +60,7 @@ sub help {
"notreg=s" => \$notreg,
"help" => \$help,
"head" => \$head,
"entityID" => \$entityID
"idonly" => \$idonly
);

if ($help) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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; }
Expand All @@ -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"
Expand Down

0 comments on commit 71814e3

Please sign in to comment.