Jump to content

Help with XML Doms


slimm609

Recommended Posts

I am trying to add a xmlns namespace attribute to an Assertion tag inside before signing it but i can't figure out why it wont add.

Php Code: http://snipt.org/zfEf3[1]

Full Output: http://snipt.org/zfEg2[2]

The part in question is adding xmlns="urn:oasis:names:tc:SAML:1.0:assertion" to the tag below

<Assertion IssueInstant="2013-02-21T05:02:46Z" Issuer="urn:client:comsec:1.0" MajorVersion="1" MinorVersion="1" AssertionID="_56319a08ed26ab103077"> 

needs to be

<Assertion xmlns="urn:oasis:names:tc:SAML:1.0:assertion" IssueInstant="2013-02-21T05:02:46Z" Issuer="urn:client:comsec:1.0" MajorVersion="1" MinorVersion="1" AssertionID="_56319a08ed26ab103077">

but whatever I do it wont add the xmlns tag in there. here is the section of php that pertains to it.

$assertion = $xml->createElementNS('urn:oasis:names:tc:SAML:1.0:protocol', 'Assertion');
$assertion->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:saml', 'urn:oasis:names:tc:SAML:1.0:assertion');
$assertion->setAttribute('IssueInstant', gmdate('Y-m-d\\TH:i:s\\Z', $now));
$assertion->setAttribute('Issuer', 'urn:client:comsec:1.0');
$assertion->setAttribute('MajorVersion', '1');
$assertion->setAttribute('MinorVersion', '1');
$resp->appendChild($assertion);

I have tried changeing the

 $assertion = $xml->createElementNS('urn:oasis:names:tc:SAML:1.0:protocol', 'Assertion');

to

 $assertion = $xml->createElementNS('urn:oasis:names:tc:SAML:1.0:assertion', 'Assertion');

but that doesn't add it. It changes the main tag from <Assertion .... /> to <saml:Assertion ..../>.

Any help would be wonderful.

Link to comment
https://forums.phpfreaks.com/topic/274758-help-with-xml-doms/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.