SAML2\Message::toUnsignedXML PHP Method

toUnsignedXML() public method

This method does not sign the resulting XML document.
public toUnsignedXML ( ) : DOMElement
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;
    }

Usage Example

コード例 #1
0
ファイル: HTTPArtifact.php プロジェクト: SysBind/saml2
 /**
  * Create the redirect URL for a message.
  *
  * @param  \SAML2\Message $message The message.
  * @return string        The URL the user should be redirected to in order to send a message.
  * @throws \Exception
  */
 public function getRedirectURL(Message $message)
 {
     $store = SimpleSAML_Store::getInstance();
     if ($store === false) {
         throw new \Exception('Unable to send artifact without a datastore configured.');
     }
     $generatedId = pack('H*', (string) SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(20)));
     $artifact = base64_encode("" . sha1($message->getIssuer(), true) . $generatedId);
     $artifactData = $message->toUnsignedXML();
     $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData);
     $store->set('artifact', $artifact, $artifactDataString, Temporal::getTime() + 15 * 60);
     $params = array('SAMLart' => $artifact);
     $relayState = $message->getRelayState();
     if ($relayState !== null) {
         $params['RelayState'] = $relayState;
     }
     return SimpleSAML_Utilities::addURLparameter($message->getDestination(), $params);
 }
All Usage Examples Of SAML2\Message::toUnsignedXML