@@ -5,7 +5,7 @@ use MooseX::Types::Common::String qw/ NonEmptySimpleStr /;
5
5
use DateTime;
6
6
use DateTime::Format::XSD;
7
7
use Net::SAML2::XML::Util qw/ no_comments / ;
8
- use XML::XPath ;
8
+ use XML::LibXML ;
9
9
10
10
with ' Net::SAML2::Role::ProtocolMessage' ;
11
11
@@ -27,7 +27,7 @@ has 'nameid' => (isa => 'Str', is => 'ro', required =>
27
27
has ' not_before' => (isa => DateTime, is => ' ro' , required => 1);
28
28
has ' not_after' => (isa => DateTime, is => ' ro' , required => 1);
29
29
has ' audience' => (isa => NonEmptySimpleStr, is => ' ro' , required => 1);
30
- has ' xpath' => (isa => ' XML::XPath ' , is => ' ro' , required => 1);
30
+ has ' xpath' => (isa => ' XML::LibXML::XPathContext ' , is => ' ro' , required => 1);
31
31
has ' in_response_to' => (isa => ' Str' , is => ' ro' , required => 1);
32
32
has ' response_status' => (isa => ' Str' , is => ' ro' , required => 1);
33
33
@@ -55,10 +55,15 @@ XML data
55
55
sub new_from_xml {
56
56
my ($class , %args ) = @_ ;
57
57
58
- my $xpath = XML::XPath-> new(xml => no_comments($args {xml }));
58
+ my $dom = XML::LibXML-> load_xml(
59
+ string => no_comments($args {xml }),
60
+ no_network => 1,
61
+ load_ext_dtd => 0,
62
+ expand_entities => 0 );
59
63
60
- $xpath -> set_namespace(' saml' , ' urn:oasis:names:tc:SAML:2.0:assertion' );
61
- $xpath -> set_namespace(' samlp' , ' urn:oasis:names:tc:SAML:2.0:protocol' );
64
+ my $xpath = XML::LibXML::XPathContext-> new($dom );
65
+ $xpath -> registerNs(' saml' , ' urn:oasis:names:tc:SAML:2.0:assertion' );
66
+ $xpath -> registerNs(' samlp' , ' urn:oasis:names:tc:SAML:2.0:protocol' );
62
67
63
68
my $attributes = {};
64
69
for my $node (
@@ -73,7 +78,7 @@ sub new_from_xml {
73
78
my $not_before ;
74
79
if ($xpath -> findvalue(' //saml:Conditions/@NotBefore' )) {
75
80
$not_before = DateTime::Format::XSD-> parse_datetime(
76
- $xpath -> findvalue(' //saml:Conditions/@NotBefore' )-> value );
81
+ $xpath -> findvalue(' //saml:Conditions/@NotBefore' ));
77
82
}
78
83
else {
79
84
$not_before = DateTime-> now();
@@ -82,24 +87,24 @@ sub new_from_xml {
82
87
my $not_after ;
83
88
if ($xpath -> findvalue(' //saml:Conditions/@NotOnOrAfter' )) {
84
89
$not_after = DateTime::Format::XSD-> parse_datetime(
85
- $xpath -> findvalue(' //saml:Conditions/@NotOnOrAfter' )-> value );
90
+ $xpath -> findvalue(' //saml:Conditions/@NotOnOrAfter' ));
86
91
}
87
92
else {
88
93
$not_after = DateTime-> from_epoch(epoch => time () + 1000);
89
94
}
90
95
91
96
my $self = $class -> new(
92
- issuer => $xpath -> findvalue(' //saml:Assertion/saml:Issuer' )-> value ,
93
- destination => $xpath -> findvalue(' /samlp:Response/@Destination' )-> value ,
97
+ issuer => $xpath -> findvalue(' //saml:Assertion/saml:Issuer' ),
98
+ destination => $xpath -> findvalue(' /samlp:Response/@Destination' ),
94
99
attributes => $attributes ,
95
- session => $xpath -> findvalue(' //saml:AuthnStatement/@SessionIndex' )-> value ,
96
- nameid => $xpath -> findvalue(' //saml:Subject/saml:NameID' )-> value ,
97
- audience => $xpath -> findvalue(' //saml:Conditions/saml:AudienceRestriction/saml:Audience' )-> value ,
100
+ session => $xpath -> findvalue(' //saml:AuthnStatement/@SessionIndex' ),
101
+ nameid => $xpath -> findvalue(' //saml:Subject/saml:NameID' ),
102
+ audience => $xpath -> findvalue(' //saml:Conditions/saml:AudienceRestriction/saml:Audience' ),
98
103
not_before => $not_before ,
99
104
not_after => $not_after ,
100
105
xpath => $xpath ,
101
- in_response_to => $xpath -> findvalue(' //saml:Subject/saml:SubjectConfirmation/saml:SubjectConfirmationData/@InResponseTo' )-> value ,
102
- response_status => $xpath -> findvalue(' //saml2p :Response/saml2p :Status/saml2p :StatusCode/@Value' )-> value ,
106
+ in_response_to => $xpath -> findvalue(' //saml:Subject/saml:SubjectConfirmation/saml:SubjectConfirmationData/@InResponseTo' ),
107
+ response_status => $xpath -> findvalue(' //samlp :Response/samlp :Status/samlp :StatusCode/@Value' ),
103
108
);
104
109
105
110
return $self ;
0 commit comments