diff --git a/bin/access-check-manager.pl b/bin/access-check-manager.pl index a0a1f53901b292d6c368d7581d5e46a23f7e5756..cbeb419df2e1a209ea2e0c3baad02a4c9ec7768c 100755 --- a/bin/access-check-manager.pl +++ b/bin/access-check-manager.pl @@ -14,10 +14,10 @@ use English qw(-no_match_vars); use Getopt::Long qw(:config auto_help); use Pod::Usage; -use AccountManager::Account; +use AccountManager::Data::Account; +use AccountManager::Data::Entity; +use AccountManager::Data::Token; use AccountManager::Metadata; -use AccountManager::Entity; -use AccountManager::Token; use AccountManager::Tools; my %options; @@ -97,7 +97,7 @@ sub add_account { $configuration->{service}->{account_validity_period}; my $password = AccountManager::Tools::generate_password(); - my $account = AccountManager::Account->new( + my $account = AccountManager::Data::Account->new( db => $db, profile => $options{profile}, entityid => $options{entityid}, @@ -131,7 +131,7 @@ sub list_accounts { } my $accounts = - AccountManager::Account->get_accounts(db => $db, %args); + AccountManager::Data::Account->get_accounts(db => $db, %args); if (! @$accounts) { printf "No matching test account in DB\n"; @@ -147,7 +147,7 @@ sub list_accounts { } printf "%d accounts removed\n", scalar @$accounts; - $accounts = AccountManager::Account->get_accounts( + $accounts = AccountManager::Data::Account->get_accounts( db => $db ); @@ -199,7 +199,7 @@ sub add_service { ) unless $options{contacts}; ## Check if entry already exists in DB first - my $provider = AccountManager::Entity->new( + my $provider = AccountManager::Data::Entity->new( db => $db, entityid => $options{entityid} ); @@ -210,7 +210,7 @@ sub add_service { $provider->contacts($options{contacts}); $provider->displayname($options{displayname}) if $options{displayname}; } else { - $provider = AccountManager::Entity->new( + $provider = AccountManager::Data::Entity->new( db => $db, entityid => $options{entityid}, contacts => $options{contacts}, @@ -227,7 +227,7 @@ sub add_service { sub list_services { my %args; - my $providers = AccountManager::Entity->get_entities(db => $db, %args); + my $providers = AccountManager::Data::Entity->get_entities(db => $db, %args); if (! @$providers) { printf "No service provider in DB\n"; @@ -258,7 +258,7 @@ sub list_tokens { push @{ $args{query} }, expiration_date => { lt => DateTime->now() }; } - my $tokens = AccountManager::Token->get_tokens(db => $db, %args); + my $tokens = AccountManager::Data::Token->get_tokens(db => $db, %args); if (!@$tokens) { printf "No corresponding token found in DB\n"; @@ -285,7 +285,7 @@ sub get_token { $args{token} = $options{token}; } - my $token = AccountManager::Token->new(db => $db, %args); + my $token = AccountManager::Data::Token->new(db => $db, %args); die "No corresponding token found in DB\n" unless $token->load(); @@ -312,7 +312,7 @@ sub add_token { ) unless $options{entityid}; # delete any previous token for the same email/service couple - my $old_token = AccountManager::Token->new( + my $old_token = AccountManager::Data::Token->new( db => $db, email_address => $options{email_address}, entityid => $options{entityid} @@ -324,7 +324,7 @@ sub add_token { # compute a new token my $validity_period = $configuration->{service}->{tokens_validity_period}; - my $token = AccountManager::Token->new( + my $token = AccountManager::Data::Token->new( db => $db, email_address => $options{email_address}, entityid => $options{entityid}, diff --git a/bin/update-metadata b/bin/update-metadata index a14d0c8266e73d56fb78855f97d8f02d294026c7..7ae0e590830916b7c69b1e5b804025172695e16e 100755 --- a/bin/update-metadata +++ b/bin/update-metadata @@ -14,9 +14,9 @@ use List::MoreUtils qw(uniq); use Mojo::UserAgent; use Pod::Usage; -use AccountManager::DB; +use AccountManager::Data::DB; +use AccountManager::Data::Entity; use AccountManager::Metadata; -use AccountManager::Entity; my %options; GetOptions( @@ -40,7 +40,7 @@ die "no database defined in configuration, aborting\n" die "no federation defined in configuration, aborting\n" if !$configuration->{federations}; -AccountManager::DB->register_db( +AccountManager::Data::DB->register_db( driver => $configuration->{database}->{type}, database => $configuration->{database}->{name}, host => $configuration->{database}->{host}, @@ -53,7 +53,7 @@ AccountManager::DB->register_db( ] ); -my $db = AccountManager::DB->new(); +my $db = AccountManager::Data::DB->new(); my $ua = Mojo::UserAgent->new( max_redirect => 3 @@ -61,7 +61,7 @@ my $ua = Mojo::UserAgent->new( $db->begin_work(); -AccountManager::Entity->delete_entities(all => 1); +AccountManager::Data::Entity->delete_entities(all => 1); $db->dbh()->do('ALTER TABLE entities AUTO_INCREMENT = 1'); @@ -108,7 +108,7 @@ foreach my $id (keys %{$configuration->{federations}}) { my $entity; if ($seen{$entry->{entityid}}++) { - $entity = AccountManager::Entity->new( + $entity = AccountManager::Data::Entity->new( db => $db, entityid => $entry->{entityid}, ); @@ -119,7 +119,7 @@ foreach my $id (keys %{$configuration->{federations}}) { $entity->update(); } else { eval { - $entity = AccountManager::Entity->new( + $entity = AccountManager::Data::Entity->new( db => $db, type => $entry->{type}, entityid => $entry->{entityid}, diff --git a/lib/AccountManager/App/Controller.pm b/lib/AccountManager/App/Controller.pm index aaeef6faca280d92045f0b391adb60a54f80bfce..daac09b65f19b0f9c378c3d9fdd7ea71e037eacd 100644 --- a/lib/AccountManager/App/Controller.pm +++ b/lib/AccountManager/App/Controller.pm @@ -5,10 +5,10 @@ use Mojo::Base qw(Mojolicious::Controller); use English qw(-no_match_vars); use Syntax::Keyword::Try; -use AccountManager::DB; -use AccountManager::Entity; +use AccountManager::Data::DB; +use AccountManager::Data::Entity; +use AccountManager::Data::Token; use AccountManager::L10N; -use AccountManager::Token; sub init_l10n { my $self = shift; @@ -46,7 +46,7 @@ sub init_db { my $config = $self->app()->config(); - AccountManager::DB->register_db( + AccountManager::Data::DB->register_db( driver => $config->{database}->{type}, database => $config->{database}->{name}, host => $config->{database}->{host}, @@ -57,7 +57,7 @@ sub init_db { my $db; try { - $db = AccountManager::DB->new(); + $db = AccountManager::Data::DB->new(); } catch { } @@ -106,7 +106,7 @@ sub check_token { my $secret = $args{token}; - my $token = AccountManager::Token->new( + my $token = AccountManager::Data::Token->new( db => $self->{db}, secret => $secret ); @@ -162,7 +162,7 @@ sub get_sp { my $db = $self->stash('db'); - my $sp = AccountManager::Entity->new( + my $sp = AccountManager::Data::Entity->new( db => $db, entityid => $entityid ); diff --git a/lib/AccountManager/App/Step1.pm b/lib/AccountManager/App/Step1.pm index 75ea4f2534fb391c8fe95cd7b7dfa91a89efe966..2aed9e4085658d1aa36849e35a7e28b5dcc28913 100644 --- a/lib/AccountManager/App/Step1.pm +++ b/lib/AccountManager/App/Step1.pm @@ -5,7 +5,7 @@ use Mojo::Base qw(AccountManager::App::Controller); use English qw(-no_match_vars); use Syntax::Keyword::Try; -use AccountManager::Entity; +use AccountManager::Data::Entity; sub run { my $self = shift; @@ -24,7 +24,7 @@ sub run { my $db = $self->stash('db'); my $user = $self->stash('user'); - my $sps = AccountManager::Entity->get_entities( + my $sps = AccountManager::Data::Entity->get_entities( db => $db, query => [ type => 'sp', @@ -34,7 +34,7 @@ sub run { my $idp; if ($user) { - my $idps = AccountManager::Entity->get_entities( + my $idps = AccountManager::Data::Entity->get_entities( db => $db, query => [ type => 'idp', diff --git a/lib/AccountManager/App/Step3.pm b/lib/AccountManager/App/Step3.pm index b4983ef903766ecdb85dc0c9f2ef15232e22f8b1..9130748348820217da9084b4049658a3128a2e0e 100644 --- a/lib/AccountManager/App/Step3.pm +++ b/lib/AccountManager/App/Step3.pm @@ -9,7 +9,7 @@ use English qw(-no_match_vars); use Syntax::Keyword::Try; use Template::Constants qw(:chomp); -use AccountManager::Token; +use AccountManager::Data::Token; use AccountManager::Tools; sub run { @@ -45,7 +45,7 @@ sub run { ) if !$sp->is_contact($email); # delete any previous token for the same email/service couple - my $old_token = AccountManager::Token->new( + my $old_token = AccountManager::Data::Token->new( db => $db, email_address => $email, entityid => $entityid, @@ -65,7 +65,7 @@ sub run { # compute a new token my $validity_period = $config->{service}->{tokens_validity_period}; - my $token = AccountManager::Token->new( + my $token = AccountManager::Data::Token->new( db => $db, email_address => $email, entityid => $entityid, diff --git a/lib/AccountManager/App/Step4.pm b/lib/AccountManager/App/Step4.pm index b6d50a6e065b506b840927f8d0abe57bcb65ce9a..a35f805865281394269d224067062add7193e1f8 100644 --- a/lib/AccountManager/App/Step4.pm +++ b/lib/AccountManager/App/Step4.pm @@ -9,8 +9,8 @@ use English qw(-no_match_vars); use Syntax::Keyword::Try; use Template::Constants qw(:chomp); -use AccountManager::Account; -use AccountManager::Token; +use AccountManager::Data::Account; +use AccountManager::Data::Token; use AccountManager::Tools; sub run { @@ -51,7 +51,7 @@ sub run { days => $validity ); - my $download_token = AccountManager::Token->new( + my $download_token = AccountManager::Data::Token->new( db => $db, email_address => $email, entityid => $entityid, @@ -73,7 +73,7 @@ sub run { foreach my $profile (@$profiles) { my $password = AccountManager::Tools::generate_password(10); - my $account = AccountManager::Account->new( + my $account = AccountManager::Data::Account->new( db => $db, profile => $profile, entityid => $entityid, @@ -95,7 +95,7 @@ sub run { ) if !@accounts; ## Update simpleSAMLphp configuration to enable test accounts - my $accounts = AccountManager::Account->get_accounts(db => $db); + my $accounts = AccountManager::Data::Account->get_accounts(db => $db); try { AccountManager::Tools::update_ssp_authsources( diff --git a/lib/AccountManager/App/Step5.pm b/lib/AccountManager/App/Step5.pm index bec8dd08f52a194458f60b71bc604ab724b27f2e..15ecd602dab4ceeff0cc01e7a121240f37b496ff 100644 --- a/lib/AccountManager/App/Step5.pm +++ b/lib/AccountManager/App/Step5.pm @@ -9,7 +9,7 @@ use English qw(-no_match_vars); use Syntax::Keyword::Try; use Template::Constants qw(:chomp); -use AccountManager::Account; +use AccountManager::Data::Account; use AccountManager::Tools; sub run { @@ -35,7 +35,7 @@ sub run { return if !$self->check_token(token => $token, entityid => $entityid); # load accounts from database - my $accounts = AccountManager::Account->get_accounts( + my $accounts = AccountManager::Data::Account->get_accounts( db => $db, query => [ token => $token diff --git a/lib/AccountManager/DB/Object.pm b/lib/AccountManager/DB/Object.pm deleted file mode 100644 index fc7315def868f6ca38ced041f0b7266b68de92b4..0000000000000000000000000000000000000000 --- a/lib/AccountManager/DB/Object.pm +++ /dev/null @@ -1,11 +0,0 @@ -package AccountManager::DB::Object; - -use Mojo::Base 'Rose::DB::Object'; - -use AccountManager::DB; - -sub init_db { - AccountManager::DB->new(); -} - -1; diff --git a/lib/AccountManager/Account.pm b/lib/AccountManager/Data/Account.pm similarity index 94% rename from lib/AccountManager/Account.pm rename to lib/AccountManager/Data/Account.pm index 080b2f497eacebb581bf0191fba13fac745731db..da836d9b5423b8351be470b7b22ba3e7eb6b0275 100644 --- a/lib/AccountManager/Account.pm +++ b/lib/AccountManager/Data/Account.pm @@ -1,6 +1,6 @@ -package AccountManager::Account; +package AccountManager::Data::Account; -use Mojo::Base 'AccountManager::DB::Object'; +use Mojo::Base 'AccountManager::Data::Object'; use Rose::DB::Object::Manager; diff --git a/lib/AccountManager/DB.pm b/lib/AccountManager/Data/DB.pm similarity index 95% rename from lib/AccountManager/DB.pm rename to lib/AccountManager/Data/DB.pm index 50798156e958865e713ee5dab1fb5b9bd12387ed..923d43df49625ef366fade4c24df05fc72eff382 100644 --- a/lib/AccountManager/DB.pm +++ b/lib/AccountManager/Data/DB.pm @@ -1,4 +1,4 @@ -package AccountManager::DB; +package AccountManager::Data::DB; use Mojo::Base 'Rose::DB'; diff --git a/lib/AccountManager/Entity.pm b/lib/AccountManager/Data/Entity.pm similarity index 94% rename from lib/AccountManager/Entity.pm rename to lib/AccountManager/Data/Entity.pm index 5723f30196e2921789d107951aa4d01c9143c704..20c85f77e53ad1d000137e02b13f166df4c61293 100644 --- a/lib/AccountManager/Entity.pm +++ b/lib/AccountManager/Data/Entity.pm @@ -1,6 +1,6 @@ -package AccountManager::Entity; +package AccountManager::Data::Entity; -use Mojo::Base 'AccountManager::DB::Object'; +use Mojo::Base 'AccountManager::Data::Object'; use List::MoreUtils qw(any); use Rose::DB::Object::Manager; diff --git a/lib/AccountManager/Data/Object.pm b/lib/AccountManager/Data/Object.pm new file mode 100644 index 0000000000000000000000000000000000000000..d39b28adae7f94995fe950e576baa94257d212e4 --- /dev/null +++ b/lib/AccountManager/Data/Object.pm @@ -0,0 +1,11 @@ +package AccountManager::Data::Object; + +use Mojo::Base 'Rose::DB::Object'; + +use AccountManager::Data::DB; + +sub init_db { + AccountManager::Data::DB->new(); +} + +1; diff --git a/lib/AccountManager/Token.pm b/lib/AccountManager/Data/Token.pm similarity index 93% rename from lib/AccountManager/Token.pm rename to lib/AccountManager/Data/Token.pm index 95e2673f8f6e0a40f536b767cd72f3e02e964751..d4d6f6110e9bf99a4aafe3ac48e683c09a8ac670 100644 --- a/lib/AccountManager/Token.pm +++ b/lib/AccountManager/Data/Token.pm @@ -1,6 +1,6 @@ -package AccountManager::Token; +package AccountManager::Data::Token; -use Mojo::Base 'AccountManager::DB::Object'; +use Mojo::Base 'AccountManager::Data::Object'; use Rose::DB::Object::Manager; diff --git a/lib/Makefile.am b/lib/Makefile.am index b41a76165675c857743cb99f6332d4e38b1a0449..2094cd861265988d8c0c5684e8de8dc98d815e32 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,12 +1,12 @@ applibdir = $(pkgdatadir)/lib nobase_applib_DATA = \ - AccountManager/Token.pm \ - AccountManager/DB.pm \ - AccountManager/DB/Object.pm \ + AccountManager/Data/Account.pm \ + AccountManager/Data/DB.pm \ + AccountManager/Data/Entity.pm \ + AccountManager/Data/Object.pm \ + AccountManager/Data/Token.pm \ AccountManager/Metadata.pm \ - AccountManager/Entity.pm \ - AccountManager/Account.pm \ AccountManager/Tools.pm \ AccountManager/L10N.pm \ AccountManager/L10N/en.pm \