Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Encapsulate status URIs

  • Loading branch information...
commit 6e0b369ebc870afc6b9e442053497c10cf87f833 1 parent c5e9cfd
Chris Andrews authored
2  lib/Net/SAML2/Protocol/LogoutResponse.pm
View
@@ -98,7 +98,7 @@ Returns true if the Response's status is Success.
sub success {
my ($self) = @_;
- return 1 if $self->status eq 'urn:oasis:names:tc:SAML:2.0:status:Success';
+ return 1 if $self->status eq $self->status_uri('success');
return 0;
}
29 lib/Net/SAML2/Role/ProtocolMessage.pm
View
@@ -6,12 +6,15 @@ use Crypt::OpenSSL::Random;
=head1 NAME
-Net::SAML2::Role::Templater - defaults for Protocol classes
+Net::SAML2::Role::ProtocolMessage - common behaviour for Protocol messages
=head1 DESCRIPTION
Provides default ID and timestamp arguments for Protocol classes.
+Provides a status-URI lookup method for the statuses used by this
+implementation.
+
=cut
has 'id' => (isa => Str, is => 'ro', required => 1);
@@ -32,4 +35,28 @@ around 'BUILDARGS' => sub {
return \%args;
};
+=head1 METHODS
+
+=head2 status_uri($status)
+
+Provides a mapping from short names for statuses to the full status URIs.
+
+=cut
+
+sub status_uri {
+ my ($self, $status) = @_;
+
+ my $statuses = {
+ success => 'urn:oasis:names:tc:SAML:2.0:status:Success',
+ requester => 'urn:oasis:names:tc:SAML:2.0:status:Requester',
+ responder => 'urn:oasis:names:tc:SAML:2.0:status:Responder',
+ };
+
+ if (exists $statuses->{$status}) {
+ return $statuses->{$status};
+ }
+
+ return;
+}
+
1;
3  lib/Net/SAML2/SP.pm
View
@@ -116,10 +116,11 @@ LogoutRequest.
sub logout_response {
my ($self, $destination, $status, $response_to) = @_;
+ my $status_uri = Net::SAML2::Protocol::LogoutResponse->status_uri($status);
my $logout_req = Net::SAML2::Protocol::LogoutResponse->new(
issuer => $self->id,
destination => $destination,
- status => $status,
+ status => $status_uri,
response_to => $response_to,
);
4 t/08-logout-response.t
View
@@ -4,9 +4,9 @@ use warnings;
use Net::SAML2;
my $lor = Net::SAML2::Protocol::LogoutResponse->new(
- issuer => 'http://some/sp',
+ issuer => 'http://some/sp',
destination => 'http://some/idp',
- status => 'urn:oasis:names:tc:SAML:2.0:status:Success',
+ status => 'success',
response_to => 'randomID',
);
ok($lor);
Please sign in to comment.
Something went wrong with that request. Please try again.