Skip to content
Snippets Groups Projects
Commit 95aef9bb authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

more explicit usage syntax

parent e709ff8c
No related branches found
No related tags found
No related merge requests found
...@@ -23,29 +23,30 @@ use IdPAccountManager::AuthenticationToken; ...@@ -23,29 +23,30 @@ use IdPAccountManager::AuthenticationToken;
use IdPAccountManager::Logger; use IdPAccountManager::Logger;
my %options; my %options;
unless ( GetOptions(
GetOptions( \%options,
\%options, 'add_test_account', 'account_profile=s',
'account_profile=s', 'sp_entityid=s', 'contacts=s',
'list_test_accounts', 'parse_federation_metadata', 'delete',
'list_service_providers', 'list_authentication_tokens', 'displayname=s',
'get_authentication_token', 'add_authentication_token', 'email_address=s',
'email_address=s', 'token=s', 'filter_expired',
'send_notice', 'filter_expired', 'sp_entityid=s',
'delete', 'add_service_provider', 'token=s',
'contacts=s', 'displayname=s' ) or pod2usage(
) -message => "unknown option, aborting\n",
) -verbose => 0
{ );
pod2usage(
-message => "unknown option, aborting\n", my $action = $ARGV[0];
-verbose => 0
); pod2usage(
} -message => "no action given, aborting\n",
-verbose => 0
) unless $action;
if ($options{'add_test_account'}) {
if ($action eq 'add_test_account') {
pod2usage( pod2usage(
-message => "missing account_profile option, aborting\n", -message => "missing account_profile option, aborting\n",
...@@ -71,7 +72,7 @@ if ($options{'add_test_account'}) { ...@@ -71,7 +72,7 @@ if ($options{'add_test_account'}) {
printf "Account created:\n\tuserid: user%d\n\tpassword: %s\n", printf "Account created:\n\tuserid: user%d\n\tpassword: %s\n",
$test_account->get('id'), $test_account->get('user_password'); $test_account->get('id'), $test_account->get('user_password');
} elsif ($options{'list_test_accounts'}) { } elsif ($action eq 'list_test_accounts') {
my %args; my %args;
if ($options{'sp_entityid'}) { if ($options{'sp_entityid'}) {
...@@ -109,7 +110,7 @@ if ($options{'add_test_account'}) { ...@@ -109,7 +110,7 @@ if ($options{'add_test_account'}) {
printf "Update simpleSamlPhp configuration file...\n"; printf "Update simpleSamlPhp configuration file...\n";
} }
} elsif ($options{'parse_federation_metadata'}) { } elsif ($action eq 'parse_federation_metadata') {
my $federation_metadata = IdPAccountManager::SAMLMetadata->new(); my $federation_metadata = IdPAccountManager::SAMLMetadata->new();
die "unable to load federation metadata\n" die "unable to load federation metadata\n"
...@@ -135,7 +136,7 @@ if ($options{'add_test_account'}) { ...@@ -135,7 +136,7 @@ if ($options{'add_test_account'}) {
$federation_metadata->{'federation_metadata_as_hashref'}, $federation_metadata->{'federation_metadata_as_hashref'},
0, \*STDOUT); 0, \*STDOUT);
} elsif ($options{'add_service_provider'}) { } elsif ($action eq 'add_service_provider') {
pod2usage( pod2usage(
-message => "missing sp_entityid option, aborting\n", -message => "missing sp_entityid option, aborting\n",
...@@ -174,7 +175,7 @@ if ($options{'add_test_account'}) { ...@@ -174,7 +175,7 @@ if ($options{'add_test_account'}) {
printf "Service Provider created\n"; printf "Service Provider created\n";
} elsif ($options{'list_service_providers'}) { } elsif ($action eq 'list_service_providers') {
my %args; my %args;
...@@ -188,7 +189,7 @@ if ($options{'add_test_account'}) { ...@@ -188,7 +189,7 @@ if ($options{'add_test_account'}) {
$service_provider->print(); $service_provider->print();
} }
} elsif ($options{'list_authentication_tokens'}) { } elsif ($action eq 'list_authentication_tokens') {
my %args; my %args;
if ($options{'sp_entityid'}) { if ($options{'sp_entityid'}) {
...@@ -221,7 +222,7 @@ if ($options{'add_test_account'}) { ...@@ -221,7 +222,7 @@ if ($options{'add_test_account'}) {
} }
} elsif ($options{'get_authentication_token'}) { } elsif ($action eq 'get_authentication_token') {
my %args; my %args;
if ($options{'token'}) { if ($options{'token'}) {
...@@ -242,8 +243,7 @@ if ($options{'add_test_account'}) { ...@@ -242,8 +243,7 @@ if ($options{'add_test_account'}) {
$authentication_token->print(); $authentication_token->print();
} elsif ($options{'add_authentication_token'}) { } elsif ($action eq 'add_authentication_token') {
pod2usage( pod2usage(
-message => "missing email_address option, aborting\n", -message => "missing email_address option, aborting\n",
...@@ -281,7 +281,7 @@ if ($options{'add_test_account'}) { ...@@ -281,7 +281,7 @@ if ($options{'add_test_account'}) {
$authentication_token->print(); $authentication_token->print();
} elsif ($options{'send_notice'}) { } elsif ($action eq 'send_notice') {
pod2usage( pod2usage(
-message => "missing email_address option, aborting\n", -message => "missing email_address option, aborting\n",
...@@ -305,10 +305,9 @@ if ($options{'add_test_account'}) { ...@@ -305,10 +305,9 @@ if ($options{'add_test_account'}) {
} else { } else {
pod2usage( pod2usage(
-message => "missing argument, aborting\n", -message => "invalid action '$action', aborting\n",
-verbose => 0 -verbose => 0
); );
} }
__END__ __END__
...@@ -319,41 +318,41 @@ account-manager-client.pl - Command line client to the Test Account manager ...@@ -319,41 +318,41 @@ account-manager-client.pl - Command line client to the Test Account manager
=head1 SYNOPSIS =head1 SYNOPSIS
B<account-manager-client.pl> B<--add_test_account> B<account-manager-client.pl> B<add_test_account>
S<B<--account_profile> I<string>> S<B<--account_profile> I<string>>
S<B<--sp_entityid> I<string>> S<B<--sp_entityid> I<string>>
B<account-manager-client.pl> B<--list_test_accounts> B<account-manager-client.pl> B<list_test_accounts>
S<[B<--account_profile> I<string>]> S<[B<--account_profile> I<string>]>
S<[B<--sp_entityid> I<string>]> S<[B<--sp_entityid> I<string>]>
[B<--filter_expired>] [B<--filter_expired>]
[B<--delete>] [B<--delete>]
B<account-manager-client.pl> B<--parse_federation_metadata> B<account-manager-client.pl> B<parse_federation_metadata>
S<[B<--sp_entityid> I<string>]> S<[B<--sp_entityid> I<string>]>
B<account-manager-client.pl> B<--add_service_provider> B<account-manager-client.pl> B<add_service_provider>
S<B<--sp_entityid> I<string>> S<B<--sp_entityid> I<string>>
S<B<--contact> I<string>> S<B<--contact> I<string>>
S<[B<--displayname> I<string>]> S<[B<--displayname> I<string>]>
B<account-manager-client.pl> B<--list_service_providers> B<account-manager-client.pl> B<list_service_providers>
B<account-manager-client.pl> B<--list_authentication_tokens> B<account-manager-client.pl> B<list_authentication_tokens>
S<B<--sp_entityid> I<string>> S<B<--sp_entityid> I<string>>
S<[B<--token> I<string>]> S<[B<--token> I<string>]>
[B<--filter_expired>] [B<--filter_expired>]
[B<--delete>] [B<--delete>]
B<account-manager-client.pl> B<--get_authentication_token> B<account-manager-client.pl> B<get_authentication_token>
S<B<--sp_entityid> I<string>> S<B<--sp_entityid> I<string>>
S<[B<--token> I<string>]> S<[B<--token> I<string>]>
B<account-manager-client.pl> B<--add_authentication_token> B<account-manager-client.pl> B<add_authentication_token>
S<B<--sp_entityid> I<string>> S<B<--sp_entityid> I<string>>
S<B<--email_address> I<string>> S<B<--email_address> I<string>>
B<account-manager-client.pl> B<--send_notice> B<account-manager-client.pl> B<send_notice>
S<B<--email_address> I<string>> S<B<--email_address> I<string>>
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -364,64 +363,64 @@ functions. ...@@ -364,64 +363,64 @@ functions.
=head1 EXAMPLES =head1 EXAMPLES
$> account-manager-client.pl --add_test_account \ $> account-manager-client.pl add_test_account \
--sp_entityid=https://test.federation.renater.fr/test/ressource --sp_entityid=https://test.federation.renater.fr/test/ressource
--account_profile=student1 \ --account_profile=student1 \
Adds a new test account. Adds a new test account.
$> account-manager-client.pl --list_test_accounts \ $> account-manager-client.pl list_test_accounts \
--sp_entityid=https://test.federation.renater.fr/test/ressource \ --sp_entityid=https://test.federation.renater.fr/test/ressource \
--account_profile=student1 --account_profile=student1
List all test accounts. Criterias can be added to filter test accounts. List all test accounts. Criterias can be added to filter test accounts.
$> account-manager-client.pl --list_test_accounts --filter_expired $> account-manager-client.pl list_test_accounts --filter_expired
List all expired test accounts. List all expired test accounts.
$> account-manager-client.pl --list_test_accounts --filter_expired \ $> account-manager-client.pl list_test_accounts --filter_expired \
--delete --delete
Remove all expired test accounts from DB. Remove all expired test accounts from DB.
$> account-manager-client.pl --parse_federation_metadata $> account-manager-client.pl parse_federation_metadata
Parses the SAML metadata file, as defined by the Parses the SAML metadata file, as defined by the
C<federation_metadata_file_path> configuration parameter. C<federation_metadata_file_path> configuration parameter.
$> account-manager-client.pl --list_authentication_tokens \ $> account-manager-client.pl list_authentication_tokens \
--sp_entityid=https://test.federation.renater.fr/test/ressource \ --sp_entityid=https://test.federation.renater.fr/test/ressource \
--token=dhj67sjJ --token=dhj67sjJ
List all authentication tokens. Criterias can be added to filter tokens. List all authentication tokens. Criterias can be added to filter tokens.
$> account-manager-client.pl --list_authentication_tokens \ $> account-manager-client.pl list_authentication_tokens \
--filter_expired --filter_expired
List all expired authentication tokens. List all expired authentication tokens.
$> account-manager-client.pl --list_authentication_tokens \ $> account-manager-client.pl list_authentication_tokens \
--filter_expired --delete --filter_expired --delete
Remove all expired authentication tokens from DB. Remove all expired authentication tokens from DB.
$> account-manager-client.pl --get_authentication_token \ $> account-manager-client.pl get_authentication_token \
--token=dhj67sjJ --token=dhj67sjJ
Get informations on a token. Get informations on a token.
$> account-manager-client.pl --add_authentication_token \ $> account-manager-client.pl add_authentication_token \
--email_address=john@my.fqdn \ --email_address=john@my.fqdn \
--sp_entityid=https://test.federation.renater.fr/test/ressource --sp_entityid=https://test.federation.renater.fr/test/ressource
Adds a new test account. Adds a new test account.
$> account-manager-client.pl --send_notice --email_address=john@my.fqdn $> account-manager-client.pl send_notice --email_address=john@my.fqdn
Sends a mail notice to the specified email address. Sends a mail notice to the specified email address.
$> account-manager-client.pl --add_service_provider \ $> account-manager-client.pl add_service_provider \
--sp_entityid=='https://test.federation.renater.fr/test/ressource _ --sp_entityid=='https://test.federation.renater.fr/test/ressource _
--displayname='Test SP' --contacts=email1@dom,email2@dom --displayname='Test SP' --contacts=email1@dom,email2@dom
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment