diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index 220bcd588f30e94f7ecda3b7a6d14f87084832de..e01e110b7b54701f99639e117a55ee7f3b0826da 100755 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -270,7 +270,7 @@ sub req_select_sp { if (!@$sps) { push @{ $self->{out}->{errors} }, "no_such_entity"; $self->{logger}->errorf( - "No such entity %s in metadata", $self->{in}->{sp_entityid} + "No such SP '%s' in metadata", $self->{in}->{sp_entityid} ); return undef; } @@ -319,22 +319,26 @@ sub req_generate_token { return undef; } - ## Create a serviceprovider object to load parameters for this SP from DB - my $service_provider = IdPAccountManager::Data::ServiceProvider->new( - db => $self->{db}, - entityid => $self->{in}->{sp_entityid}, - dev_sp_contact => $self->{configuration}->{dev_sp_contact} + my $provider = IdPAccountManager::Data::ServiceProvider->new( + db => $self->{db}, + entityid => $self->{in}->{sp_entityid}, ); - # Try loading DB object first - unless ($service_provider->load(speculative => 1)) { - push @{ $self->{out}->{errors} }, "internal"; - $self->{logger}->errorf("Failed to load SP with entityid '%s'", $self->{in}->{sp_entityid}); + unless ($provider->load(speculative => 1)) { + push @{ $self->{out}->{errors} }, "no_such_entity"; + $self->{logger}->errorf("No such SP '%s' in database", $self->{in}->{sp_entityid}); return undef; } + if ($self->{configuration}->{dev_sp_contact}) { + # replace SP contacts + $provider->contacts( + split(/, */, $self->{configuration}->{dev_sp_contact}) + ); + } + ## Check that email_address is a known contact for this SP - unless ($service_provider->is_contact($self->{in}->{email_address})) + unless ($provider->is_contact($self->{in}->{email_address})) { push @{ $self->{out}->{errors} }, "internal"; $self->{logger}->errorf(