| 1 | package Net::SAML2::Protocol::LogoutResponse; | ||||||||||
| 2 | 32 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 32 | our $VERSION = '0.89'; # VERSION | |||||||||
| 4 | |||||||||||
| 5 | 32 | ▶ | use MooseX::Types::URI qw/ Uri /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 32 | ▶ | use Net::SAML2::XML::Util qw/ no_comments /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 32 | ▶ | use Net::SAML2::Util qw/ deprecation_warning /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 32 | ▶ | use XML::LibXML::XPathContext; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 32 | with 'Net::SAML2::Role::ProtocolMessage'; | |||||||||
| 11 | |||||||||||
| 12 | # ABSTRACT: SAML2 LogoutResponse Protocol object | ||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 32 | has 'status' => (isa => 'Str', is => 'ro', required => 1); | |||||||||
| 16 | 32 | has 'substatus' => (isa => 'Str', is => 'ro', required => 0); | |||||||||
| 17 | 32 | has '+in_response_to' => (required => 1); | |||||||||
| 18 | |||||||||||
| 19 | # Remove response_to/substatus after 6 months from now (april 18th 2024) | ||||||||||
| 20 | 3 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||
| 21 | 3 | my $orig = shift; | |||||||||
| 22 | 3 | my $self = shift; | |||||||||
| 23 | 3 | my %args = @_; | |||||||||
| 24 | |||||||||||
| 25 | 3 | ▶ | if (my $irt = delete $args{response_to}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | $args{in_response_to} = $irt; | |||||||||
| 27 | 0 | deprecation_warning( | |||||||||
| 28 | "Please use in_response_to instead of response_to"); | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 3 | return $self->$orig(%args); | |||||||||
| 32 | 32 | }; | |||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | sub response_to { | ||||||||
|
Subroutine
response_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 1 | my $self = shift; | |||||||||
| 37 | 1 | deprecation_warning("Please use in_response_to instead of response_to"); | |||||||||
| 38 | 1 | return $self->in_response_to; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | sub new_from_xml { | ||||||||
|
Subroutine
new_from_xml: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 2 | my ($class, %args) = @_; | |||||||||
| 44 | |||||||||||
| 45 | 2 | my $dom = no_comments($args{xml}); | |||||||||
| 46 | |||||||||||
| 47 | 2 | my $xpath = XML::LibXML::XPathContext->new($dom); | |||||||||
| 48 | 2 | $xpath->registerNs('saml', 'urn:oasis:names:tc:SAML:2.0:assertion'); | |||||||||
| 49 | 2 | $xpath->registerNs('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol'); | |||||||||
| 50 | |||||||||||
| 51 | 2 | my $self = $class->new( | |||||||||
| 52 | id => $xpath->findvalue('/samlp:LogoutResponse/@ID'), | ||||||||||
| 53 | in_response_to => $xpath->findvalue('/samlp:LogoutResponse/@InResponseTo'), | ||||||||||
| 54 | destination => $xpath->findvalue('/samlp:LogoutResponse/@Destination'), | ||||||||||
| 55 | session => $xpath->findvalue('/samlp:LogoutResponse/samlp:SessionIndex'), | ||||||||||
| 56 | issuer => $xpath->findvalue('/samlp:LogoutResponse/saml:Issuer'), | ||||||||||
| 57 | status => $xpath->findvalue('/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/@Value'), | ||||||||||
| 58 | substatus => $xpath->findvalue('/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/samlp:StatusCode/@Value'), | ||||||||||
| 59 | ); | ||||||||||
| 60 | |||||||||||
| 61 | 2 | return $self; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | |||||||||||
| 65 | 1 | ▶ | sub as_xml { | ||||||||
|
Subroutine
as_xml: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 66 | 1 | my ($self) = @_; | |||||||||
| 67 | |||||||||||
| 68 | 1 | my $x = XML::Generator->new(':pretty'); | |||||||||
| 69 | 1 | my $saml = ['saml' => 'urn:oasis:names:tc:SAML:2.0:assertion']; | |||||||||
| 70 | 1 | my $samlp = ['samlp' => 'urn:oasis:names:tc:SAML:2.0:protocol']; | |||||||||
| 71 | |||||||||||
| 72 | 1 | $x->xml( | |||||||||
| 73 | $x->LogoutResponse( | ||||||||||
| 74 | $samlp, | ||||||||||
| 75 | { ID => $self->id, | ||||||||||
| 76 | Version => '2.0', | ||||||||||
| 77 | IssueInstant => $self->issue_instant, | ||||||||||
| 78 | Destination => $self->destination, | ||||||||||
| 79 | InResponseTo => $self->in_response_to }, | ||||||||||
| 80 | $x->Issuer( | ||||||||||
| 81 | $saml, | ||||||||||
| 82 | $self->issuer, | ||||||||||
| 83 | ), | ||||||||||
| 84 | $x->Status( | ||||||||||
| 85 | $samlp, | ||||||||||
| 86 | $x->StatusCode( | ||||||||||
| 87 | $samlp, | ||||||||||
| 88 | { Value => $self->status }, | ||||||||||
| 89 | ) | ||||||||||
| 90 | ) | ||||||||||
| 91 | ) | ||||||||||
| 92 | ); | ||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 32 | __PACKAGE__->meta->make_immutable; | |||||||||
| 96 | |||||||||||
| 97 | __END__ | ||||||||||