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

switch to Syntax::Keyword::Try

parent 3dde0041
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ use DateTime;
use English qw(-no_match_vars);
use Getopt::Long qw(:config auto_help);
use Pod::Usage;
use Syntax::Keyword::Try;
use AccountManager::Data::Account;
use AccountManager::Data::Entity;
......@@ -151,15 +152,15 @@ sub list_accounts {
db => $db
);
eval {
try {
AccountManager::Tools::update_ssp_authsources(
$configuration->{setup}->{templates_dir},
$configuration->{setup}->{accounts_file},
$accounts
);
};
die "failed to update simpleSAMLphp configuration file: $EVAL_ERROR"
if $EVAL_ERROR;
} catch ($error) {
die "failed to update simpleSAMLphp configuration file: $error"
}
printf "Update simpleSamlPhp configuration file...\n";
}
......@@ -169,12 +170,13 @@ sub list_accounts {
sub parse_metadata {
my $federation_metadata;
eval {
try {
$federation_metadata = AccountManager::Metadata->new(
file => $configuration->{setup}->{federation_metadata_file}
);
};
die "unable to load federation metadata: $EVAL_ERROR" if $EVAL_ERROR;
} catch ($error) {
die "unable to load federation metadata: $error";
}
my $data = $federation_metadata->parse(id => $options{entityid});
......
......@@ -13,6 +13,7 @@ use Getopt::Long qw(:config auto_help);
use List::MoreUtils qw(uniq);
use Mojo::UserAgent;
use Pod::Usage;
use Syntax::Keyword::Try;
use AccountManager::Data::DB;
use AccountManager::Data::Entity;
......@@ -82,24 +83,22 @@ foreach my $id (keys %{$configuration->{federations}}) {
$result->save_to($file->filename());
my $metadata;
eval {
try {
$metadata = AccountManager::Metadata->new(
file => $file
);
};
if ($EVAL_ERROR) {
} catch ($error) {
$db->rollback();
die "failed to load federation metadata: $EVAL_ERROR";
die "failed to load federation metadata: $error";
}
print "parsing metadata from file $file\n" if $options{verbose};
my $entities;
eval {
try {
$entities = $metadata->parse();
};
if ($EVAL_ERROR) {
} catch ($error) {
$db->rollback();
die "failed to parse federation metadata: $EVAL_ERROR";
die "failed to parse federation metadata: $error";
}
foreach my $entry (@$entities) {
......@@ -118,28 +117,28 @@ foreach my $id (keys %{$configuration->{federations}}) {
);
$entity->update();
} else {
eval {
$entity = AccountManager::Data::Entity->new(
db => $db,
type => $entry->{type},
entityid => $entry->{entityid},
display_name => $entry->{display_name},
information_url => $entry->{information_url},
organization_url => $entry->{organization_url},
);
if ($entry->{contacts}) {
my @contacts =
uniq
grep { $_ }
map { $_->{EmailAddress} }
@{$entry->{contacts}};
$entity->contacts(@contacts);
}
$entity->federations($id);
$entity = AccountManager::Data::Entity->new(
db => $db,
type => $entry->{type},
entityid => $entry->{entityid},
display_name => $entry->{display_name},
information_url => $entry->{information_url},
organization_url => $entry->{organization_url},
);
if ($entry->{contacts}) {
my @contacts =
uniq
grep { $_ }
map { $_->{EmailAddress} }
@{$entry->{contacts}};
$entity->contacts(@contacts);
}
$entity->federations($id);
try {
$entity->save();
};
if ($EVAL_ERROR) {
warn "error while processing entity $entry->{entityid}: $EVAL_ERROR";
} catch ($error) {
warn "error while processing entity $entry->{entityid}: $error";
}
}
......
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