our
$VERSION
=
'0.66'
;
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
$dom
= no_comments(
$args
{xml});
my
$xpath
= XML::LibXML::XPathContext->new(
$dom
);
$xpath
->registerNs(
'saml'
,
'urn:oasis:names:tc:SAML:2.0:assertion'
);
$xpath
->registerNs(
'samlp'
,
'urn:oasis:names:tc:SAML:2.0:protocol'
);
my
$self
=
$class
->new(
id
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/@ID'
),
response_to
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/@InResponseTo'
),
destination
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/@Destination'
),
session
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/samlp:SessionIndex'
),
issuer
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/saml:Issuer'
),
status
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/@Value'
),
substatus
=>
$xpath
->findvalue(
'/samlp:LogoutResponse/samlp:Status/samlp:StatusCode/samlp:StatusCode/@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;
}
__PACKAGE__->meta->make_immutable;