Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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 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) {
printf "Account ID=%s; password=%s; sp_entityid=%s; account_profile=%s; creation_date=%s; expiration_date=%s\n",
$test_account->id, $test_account->user_password, $test_account->sp_entityid, $test_account->account_profile,
&POSIX::strftime('%Y:%m:%d', localtime($test_account->creation_date)), &POSIX::strftime('%Y:%m:%d', localtime($test_account->expiration_date));
}
}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) {
printf "\tAccount ID=%s; password=%s; sp_entityid=%s; account_profile=%s; creation_date=%s; expiration_date=%s\n",
$test_account->id, $test_account->user_password, $test_account->sp_entityid, $test_account->account_profile,
&POSIX::strftime('%Y:%m:%d', localtime($test_account->creation_date)), &POSIX::strftime('%Y:%m:%d', localtime($test_account->expiration_date));
$test_account->delete || die;
}
printf "%d accounts removed\n", $#{$all}+1;
#&IdPAccountManager::Tools::dump_var(\%IdPAccountManager::Conf::global, 0, \*STDOUT);
## Update simpleSamlPhp configuration file
printf "Update simpleSamlPhp configuration file...\n";
IdPAccountManager::Tools::update_ssp_authsources();
}