コード例 #1
0
 /**
  * Convert this element to XML.
  *
  * @param  DOMElement $parent The parent element we should append this element to.
  * @return DOMElement This element, as XML.
  */
 public function toXML(DOMElement $parent)
 {
     assert('is_string($this->Method)');
     assert('is_null($this->NameID) || $this->NameID instanceof SAML2_XML_saml_NameID');
     assert('is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SAML2_XML_saml_SubjectConfirmationData');
     $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:SubjectConfirmation');
     $parent->appendChild($e);
     $e->setAttribute('Method', $this->Method);
     if (isset($this->NameID)) {
         $this->NameID->toXML($e);
     }
     if (isset($this->SubjectConfirmationData)) {
         $this->SubjectConfirmationData->toXML($e);
     }
     return $e;
 }
コード例 #2
0
 public function testMarshalling()
 {
     $subjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData();
     $subjectConfirmationData->NotBefore = 987654321;
     $subjectConfirmationData->NotOnOrAfter = 1234567890;
     $subjectConfirmationData->Recipient = 'https://sp.example.org/asdf';
     $subjectConfirmationData->InResponseTo = 'SomeRequestID';
     $subjectConfirmationData->Address = '127.0.0.1';
     $document = SAML2_DOMDocumentFactory::fromString('<root />');
     $subjectConfirmationDataElement = $subjectConfirmationData->toXML($document->firstChild);
     $subjectConfirmationDataElements = SAML2_Utils::xpQuery($subjectConfirmationDataElement, '//saml_assertion:SubjectConfirmationData');
     $this->assertCount(1, $subjectConfirmationDataElements);
     $subjectConfirmationDataElement = $subjectConfirmationDataElements[0];
     $this->assertEquals('2001-04-19T04:25:21Z', $subjectConfirmationDataElement->getAttribute("NotBefore"));
     $this->assertEquals('2009-02-13T23:31:30Z', $subjectConfirmationDataElement->getAttribute("NotOnOrAfter"));
     $this->assertEquals('https://sp.example.org/asdf', $subjectConfirmationDataElement->getAttribute("Recipient"));
     $this->assertEquals('SomeRequestID', $subjectConfirmationDataElement->getAttribute("InResponseTo"));
     $this->assertEquals('127.0.0.1', $subjectConfirmationDataElement->getAttribute("Address"));
 }