Skip to content
Snippets Groups Projects
Commit ef9f66ed authored by renater.salaun's avatar renater.salaun
Browse files

Moved account expiration code to account-manager-client.pl

git-svn-id: https://svn.geant.net/GEANT/edugain_testidp_account_manager/trunk@58 047e039d-479c-447e-8a29-aa6bf4a09bab
parent 74af7a92
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ use IdPAccountManager::AuthenticationToken;
my %options;
unless (&GetOptions(\%options, 'help', 'add_test_account', 'account_profile=s', 'sp_entityid=s', 'list_test_accounts', 'parse_federation_metadata',
'list_service_providers','list_authentication_tokens', 'get_authentication_token', 'add_authentication_token','email_address=s',
'token=s','send_notice')) {
'token=s','send_notice','filter_expired','delete')) {
die "Unknown options.";
}
......@@ -62,16 +62,30 @@ if ($options{'add_test_account'}) {
push @{$args{'query'}}, 'account_profile' => $options{'account_profile'};
}
if ($options{'filter_expired'}) {
push @{$args{'query'}}, 'expiration_date' => {lt => time};
}
my $all = IdPAccountManager::TestAccount::list_test_accounts(%args);
if ($#{$all} < 0) {
printf "No test account in DB\n";
printf "No matching test account in DB\n";
}
foreach my $test_account (@$all) {
$test_account->print();
$test_account->delete || die if ($options{'delete'});
}
if ($options{'delete'}) {
printf "%d accounts removed\n", $#{$all}+1;
## Update simpleSamlPhp configuration file
printf "Update simpleSamlPhp configuration file...\n";
IdPAccountManager::Tools::update_ssp_authsources();
}
}elsif ($options{'parse_federation_metadata'}) {
my $federation_metadata = new IdPAccountManager::SAMLMetadata;
unless ($federation_metadata->load(federation_metadata_file_path => $Conf::global{'federation_metadata_file_path'})) {
......@@ -222,6 +236,14 @@ Adds a new test account.
List all test accounts. Criterias can be added to filter test accounts.
=item C<account-manager-client.pl --list_test_accounts --filter_expired>
List all expired test accounts.
=item C<account-manager-client.pl --list_test_accounts --filter_expired --delete>
Remove all expired test accounts from DB.
=item C<account-manager-client.pl --parse_federation_metadata>
Parses the SAML metadata file, as defined by the C<federation_metadata_file_path> configuration parameter.
......
#!/usr/bin/perl
## 09/09/2014, Olivier Salaün
## Command-line script to remove expired test accounts
## The script also updates the simpleSamlPhp config file
use strict;
use utf8;
use lib "/opt/testidp/IdPAccountManager/lib";
use lib "/opt/testidp/IdPAccountManager/conf";
use Getopt::Long;
use POSIX;
use IdPAccountManager::TestAccount;
my %options;
unless (&GetOptions(\%options, 'help', 'list_only')) {
die "Unknown options.";
}
if ($options{'help'}) {
printf "$0 --list_only\n";
}
if ($options {'list_only'}) {
my $all = IdPAccountManager::TestAccount::list_test_accounts('query' => ['expiration_date' => {lt => time}]);
foreach my $test_account (@$all) {
$test_account->print();
}
}else {
## Remove expired test accounts
my $all = IdPAccountManager::TestAccount::list_test_accounts('query' => ['expiration_date' => {lt => time}]);
printf "Removing expired test accounts...\n";
foreach my $test_account (@$all) {
$test_account->print();
$test_account->delete || die;
}
printf "%d accounts removed\n", $#{$all}+1;
#&IdPAccountManager::Tools::dump_var(\%Conf::global, 0, \*STDOUT);
## Update simpleSamlPhp configuration file
printf "Update simpleSamlPhp configuration file...\n";
IdPAccountManager::Tools::update_ssp_authsources();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment