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

First version of code to create tokens and service providers in DB

git-svn-id: https://svn.geant.net/GEANT/edugain_testidp_account_manager/trunk@17 047e039d-479c-447e-8a29-aa6bf4a09bab
parent cdae3b65
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
use strict;
use utf8;
use lib "/opt/testidp/IdPAccountManager/lib";
use lib "/opt/testidp/IdPAccountManager/lib", ;
use lib "/opt/testidp/IdPAccountManager/conf";
use Getopt::Long;
......@@ -14,17 +14,18 @@ use POSIX;
use IdPAccountManager::TestAccount;
use IdPAccountManager::SAMLMetadata;
use IdPAccountManager::ServiceProvider;
use IdPAccountManager::AuthenticationToken;
my %options;
unless (&GetOptions(\%options, 'help', 'create_test_account', 'account_profile=s', 'sp_entityid=s', 'list_test_accounts', 'parse_federation_metadata', 'list_service_providers')) {
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', 'add_authentication_token','email_address=s')) {
die "Unknown options.";
}
if ($options{'help'}) {
printf "$0 --create_test_account --account_profile=<profile_id> --sp_entityid=<entityid>\n";
printf "$0 --add_test_account --account_profile=<profile_id> --sp_entityid=<entityid>\n";
}
if ($options{'create_test_account'}) {
if ($options{'add_test_account'}) {
unless ($options{'account_profile'}) {
die "Missing account_profile option";
......@@ -62,6 +63,10 @@ if ($options{'create_test_account'}) {
my $all = IdPAccountManager::TestAccount::list_test_accounts(%args);
if ($#{$all} < 0) {
printf "No test account in DB\n";
}
foreach my $test_account (@$all) {
$test_account->print();
}
......@@ -92,10 +97,55 @@ if ($options{'create_test_account'}) {
my $all = IdPAccountManager::ServiceProvider::list_service_providers(%args);
if ($#{$all} < 0) {
printf "No service provider in DB\n";
}
foreach my $service_provider (@$all) {
$service_provider->print();
}
}elsif ($options{'list_authentication_tokens'}) {
my %args;
my $all = IdPAccountManager::AuthenticationToken::list_authentication_tokens(%args);
if ($#{$all} < 0) {
printf "No token in DB\n";
}
foreach my $authentication_token (@$all) {
$authentication_token->print();
}
}elsif ($options{'add_authentication_token'}) {
unless ($options{'email_address'}) {
die "Missing email_address option";
}
unless ($options{'sp_entityid'}) {
die "Missing sp_entityid option";
}
my $authentication_token = new IdPAccountManager::AuthenticationToken();
unless (defined $authentication_token) {
IdPAccountManager::Tools::do_log('error',"Failed to create token object");
exit -1;
}
unless ($authentication_token->set('email_address' => $options{'email_address'})) {
IdPAccountManager::Tools::do_log('error',"Failed to set token value");
exit -1;
}
unless ($authentication_token->save()) {
IdPAccountManager::Tools::do_log('error',"Failed to create token");
exit -1;
}
$authentication_token->print();
}else {
die "Missing arguments";
......
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