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

Commit

Permalink
Added option to output entityID only of selected entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Stuart authored and Alex Stuart committed Jan 22, 2014
1 parent 7d52087 commit 60717f3
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions build/query-entities.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
sub help {
print<<'EOF';
usage: query-entities.pl [--help] [--head] [--idp] [--sp] [--reg <registrationAuthority>] [--notreg <registrationAuthority>] <file>
usage: query-entities.pl [--help] [--head] [--entityID] [--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)
--idp - only outputs IdPs
--sp - only outputs SPs
(By default the script outputs all IdP and SP entities)
--reg <registrationAuthority> - outputs entities registered by registrationAuthority
--notreg <registrationAuthority> - outputs those entities NOT registered by registrationAuthority
(By default the script outputs all entities; can only have one of -reg or -notreg)
(By default the script outputs all entities; can only have one of --reg or --notreg)
Example 1:
To output all SPs in the UK federation metadata which have been imported (i.e. are not registered by the UKAMF registrationAuthority http://ukfederation.org.uk), and to include a header on the CSV file:
Expand All @@ -49,14 +51,16 @@ sub help {
my $notreg;
my $help;
my $head;
my $entityID;

my $result = GetOptions(
"idp" => \$idp,
"sp" => \$sp,
"reg=s" => \$reg,
"notreg=s" => \$notreg,
"help" => \$help,
"head" => \$head
"head" => \$head,
"entityID" => \$entityID
);

if ($help) {
Expand Down Expand Up @@ -92,6 +96,13 @@ sub help {
exit 3;
}

# 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";
help();
exit 3
}

#
# Debug printing of input flags
#
Expand Down Expand Up @@ -168,6 +179,10 @@ ()
if ( $section->first_child('SPSSODescriptor') ) { $type = "SP"; }

if ( ($sp && $type eq "SP") || ($idp && $type eq "IdP") ) {
print "$type, $entityID, $registrationAuthority, \"$ODN\", $URL\n"
if ($entityID) {
print "$entityID\n";
} else {
print "$type, $entityID, $registrationAuthority, \"$ODN\", $URL\n"
}
}
}

0 comments on commit 60717f3

Please sign in to comment.