$Net::SAML2::Protocol::LogoutResponse::VERSION
=
'0.10'
;
has
'status'
=> (
isa
=> Str,
is
=>
'ro'
,
required
=> 1);
has
'substatus'
=> (
isa
=> Str,
is
=>
'ro'
,
required
=> 0);
has
'response_to'
=> (
isa
=> Str,
is
=>
'ro'
,
required
=> 1);
sub
new_from_xml {
my
(
$class
,
%args
) =
@_
;
my
$xpath
= XML::XPath->new(
xml
=>
$args
{xml} );
$xpath
->set_namespace(
'saml'
,
'urn:oasis:names:tc:SAML:2.0:assertion'
);
$xpath
->set_namespace(
'samlp'
,
'urn:oasis:names:tc:SAML:2.0:protocol'
);
my
$self
=
$class
->new(
id
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/@ID'
)->value,
response_to
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/@InResponseTo'
)->value,
destination
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/@Destination'
)->value,
session
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/samlp:SessionIndex'
)->value,
issuer
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/saml:Issuer'
)->value,
status
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/@Value'
)->value,
substatus
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/samlp:StatusCode/@Value'
)->value,
);
return
$self
;
}
sub
as_xml {
my
(
$self
) =
@_
;
my
$x
= XML::Generator->new(
':pretty'
);
my
$saml
= [
'saml'
=>
'urn:oasis:names:tc:SAML:2.0:assertion'
];
my
$samlp
= [
'samlp'
=>
'urn:oasis:names:tc:SAML:2.0:protocol'
];
$x
->xml(
$x
->LogoutResponse(
$samlp
,
{
ID
=>
$self
->id,
Version
=>
'2.0'
,
IssueInstant
=>
$self
->issue_instant,
Destination
=>
$self
->destination,
InResponseTo
=>
$self
->response_to },
$x
->Issuer(
$saml
,
$self
->issuer,
),
$x
->Status(
$samlp
,
$x
->StatusCode(
$samlp
,
{
Value
=>
$self
->status },
)
)
)
);
}
sub
success {
my
(
$self
) =
@_
;
return
1
if
$self
->status eq
$self
->status_uri(
'success'
);
return
0;
}
sub
valid {
my
(
$self
,
$in_response_to
) =
@_
;
return
0
unless
!
defined
$in_response_to
or
$in_response_to
eq
$self
->response_to;
return
1;
}
__PACKAGE__->meta->make_immutable;