Ejemplo n.º 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(Constants::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;
 }
Ejemplo n.º 2
0
 public function testMarshalling()
 {
     $nameId = new NameID();
     $nameId->NameQualifier = 'TheNameQualifier';
     $nameId->SPNameQualifier = 'TheSPNameQualifier';
     $nameId->Format = 'TheFormat';
     $nameId->SPProvidedID = 'TheSPProvidedID';
     $nameId->value = 'TheNameIDValue';
     $nameIdElement = $nameId->toXML();
     $nameIdElements = Utils::xpQuery($nameIdElement, '/saml_assertion:NameID');
     $this->assertCount(1, $nameIdElements);
     $nameIdElement = $nameIdElements[0];
     $this->assertEquals('TheNameQualifier', $nameIdElement->getAttribute("NameQualifier"));
     $this->assertEquals('TheSPNameQualifier', $nameIdElement->getAttribute("SPNameQualifier"));
     $this->assertEquals('TheFormat', $nameIdElement->getAttribute("Format"));
     $this->assertEquals('TheSPProvidedID', $nameIdElement->getAttribute("SPProvidedID"));
     $this->assertEquals('TheNameIDValue', $nameIdElement->textContent);
 }