Convert this Issuer to XML.
public toXML ( DOMElement $parent = null ) : DOMElement | ||
$parent | DOMElement | The element we should append to. |
return | DOMElement | The current Issuer object converted into a \DOMElement. |
/** * Convert this message to an unsigned XML document. * * This method does not sign the resulting XML document. * * @return \DOMElement The root element of the DOM tree */ public function toUnsignedXML() { $this->document = DOMDocumentFactory::create(); $root = $this->document->createElementNS(Constants::NS_SAMLP, 'samlp:' . $this->tagName); $this->document->appendChild($root); /* Ugly hack to add another namespace declaration to the root element. */ $root->setAttributeNS(Constants::NS_SAML, 'saml:tmp', 'tmp'); $root->removeAttributeNS(Constants::NS_SAML, 'tmp'); $root->setAttribute('ID', $this->id); $root->setAttribute('Version', '2.0'); $root->setAttribute('IssueInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->issueInstant)); if ($this->destination !== null) { $root->setAttribute('Destination', $this->destination); } if ($this->consent !== null && $this->consent !== Constants::CONSENT_UNSPECIFIED) { $root->setAttribute('Consent', $this->consent); } if ($this->issuer !== null) { if (is_string($this->issuer)) { Utils::addString($root, \SAML2_Const::NS_SAML, 'saml:Issuer', $this->issuer); } elseif ($this->issuer instanceof XML\saml\Issuer) { $this->issuer->toXML($root); } } if (!empty($this->extensions)) { Extensions::addList($root, $this->extensions); } return $root; }
/** * Convert this assertion to an XML element. * * @param \DOMNode|null $parentElement The DOM node the assertion should be created in. * @return \DOMElement This assertion. */ public function toXML(\DOMNode $parentElement = null) { if ($parentElement === null) { $document = DOMDocumentFactory::create(); $parentElement = $document; } else { $document = $parentElement->ownerDocument; } $root = $document->createElementNS(Constants::NS_SAML, 'saml:' . 'Assertion'); $parentElement->appendChild($root); /* Ugly hack to add another namespace declaration to the root element. */ $root->setAttributeNS(Constants::NS_SAMLP, 'samlp:tmp', 'tmp'); $root->removeAttributeNS(Constants::NS_SAMLP, 'tmp'); $root->setAttributeNS(Constants::NS_XSI, 'xsi:tmp', 'tmp'); $root->removeAttributeNS(Constants::NS_XSI, 'tmp'); $root->setAttributeNS(Constants::NS_XS, 'xs:tmp', 'tmp'); $root->removeAttributeNS(Constants::NS_XS, 'tmp'); $root->setAttribute('ID', $this->id); $root->setAttribute('Version', '2.0'); $root->setAttribute('IssueInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->issueInstant)); if (is_string($this->issuer)) { $issuer = Utils::addString($root, Constants::NS_SAML, 'saml:Issuer', $this->issuer); } elseif ($this->issuer instanceof \SAML2\XML\saml\Issuer) { $issuer = $this->issuer->toXML($root); } $this->addSubject($root); $this->addConditions($root); $this->addAuthnStatement($root); if ($this->requiredEncAttributes == false) { $this->addAttributeStatement($root); } else { $this->addEncryptedAttributeStatement($root); } if ($this->signatureKey !== null) { Utils::insertSignature($this->signatureKey, $this->certificates, $root, $issuer->nextSibling); } return $root; }