File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -688,11 +688,31 @@ sub metadata {
688688 sig_hash => ' sha256' ,
689689 digest_hash => ' sha256' ,
690690 x509 => 1,
691- ns => { md => ' urn:oasis:names:tc:SAML:2.0:metadata ' },
691+ ns => { md => URN_METADATA },
692692 id_attr => ' /md:EntityDescriptor[@ID]' ,
693693 }
694694 );
695- return $signer -> sign($metadata );
695+ my $md = $signer -> sign($metadata );
696+
697+ my $xp = XML::LibXML::XPathContext-> new(
698+ XML::LibXML-> load_xml(string => $md )
699+ );
700+ $xp -> registerNs(' md' , URN_METADATA);
701+ $xp -> registerNs(' dsig' , URN_SIGNATURE);
702+
703+ my $nodes = $xp -> findnodes(' /md:EntityDescriptor[@ID]' );
704+ my $rootnode = $nodes -> get_node(1);
705+
706+ my $child = $rootnode -> firstChild;
707+ return $md if $child -> nodeName() eq ' dsig:Signature' ;
708+
709+ $nodes = $xp -> findnodes(' //dsig:Signature' );
710+ my $signode = $nodes -> get_node(1);
711+
712+ $signode -> unbindNode;
713+ $rootnode -> insertBefore($signode , $child );
714+
715+ return ' <?xml version="1.0" encoding="UTF-8"?>' . $rootnode -> toString;
696716}
697717
698718=head2 get_default_assertion_service
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ use URN::OASIS::SAML2 qw(:bindings :urn);
7070 }
7171
7272
73- get_single_node_ok($xpath , ' //ds:Signature' );
73+ my $root_node = get_single_node_ok($xpath , ' /md:EntityDescriptor' );
74+ my $signature_node = $root_node -> firstChild;
75+ is($signature_node -> nodeName(),
76+ ' dsig:Signature' , " First node is the signature" );
7477
7578 is(
7679 ' e73560b0e23602121aedc55bcb1ca637' ,
You can’t perform that action at this time.
0 commit comments