@@ -5,7 +5,7 @@ use MooseX::Types::Common::String qw/ NonEmptySimpleStr /;
55use DateTime;
66use DateTime::Format::XSD;
77use Net::SAML2::XML::Util qw/ no_comments / ;
8- use XML::XPath ;
8+ use XML::LibXML ;
99
1010with ' Net::SAML2::Role::ProtocolMessage' ;
1111
@@ -27,7 +27,7 @@ has 'nameid' => (isa => 'Str', is => 'ro', required =>
2727has ' not_before' => (isa => DateTime, is => ' ro' , required => 1);
2828has ' not_after' => (isa => DateTime, is => ' ro' , required => 1);
2929has ' 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);
3131has ' in_response_to' => (isa => ' Str' , is => ' ro' , required => 1);
3232has ' response_status' => (isa => ' Str' , is => ' ro' , required => 1);
3333
@@ -55,10 +55,15 @@ XML data
5555sub new_from_xml {
5656 my ($class , %args ) = @_ ;
5757
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 );
5963
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' );
6267
6368 my $attributes = {};
6469 for my $node (
@@ -73,7 +78,7 @@ sub new_from_xml {
7378 my $not_before ;
7479 if ($xpath -> findvalue(' //saml:Conditions/@NotBefore' )) {
7580 $not_before = DateTime::Format::XSD-> parse_datetime(
76- $xpath -> findvalue(' //saml:Conditions/@NotBefore' )-> value );
81+ $xpath -> findvalue(' //saml:Conditions/@NotBefore' ));
7782 }
7883 else {
7984 $not_before = DateTime-> now();
@@ -82,24 +87,24 @@ sub new_from_xml {
8287 my $not_after ;
8388 if ($xpath -> findvalue(' //saml:Conditions/@NotOnOrAfter' )) {
8489 $not_after = DateTime::Format::XSD-> parse_datetime(
85- $xpath -> findvalue(' //saml:Conditions/@NotOnOrAfter' )-> value );
90+ $xpath -> findvalue(' //saml:Conditions/@NotOnOrAfter' ));
8691 }
8792 else {
8893 $not_after = DateTime-> from_epoch(epoch => time () + 1000);
8994 }
9095
9196 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' ),
9499 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' ),
98103 not_before => $not_before ,
99104 not_after => $not_after ,
100105 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' ),
103108 );
104109
105110 return $self ;
0 commit comments