Example #1
0
 /**
  * Convert the response message to an XML element.
  *
  * @return \DOMElement This response.
  */
 public function toUnsignedXML()
 {
     $root = parent::toUnsignedXML();
     $artifactelement = $this->document->createElementNS(Constants::NS_SAMLP, 'Artifact', $this->artifact);
     $root->appendChild($artifactelement);
     return $root;
 }
Example #2
0
 /**
  * Convert this authentication request to an XML element.
  *
  * @return \DOMElement This authentication request.
  */
 public function toUnsignedXML()
 {
     $root = parent::toUnsignedXML();
     if ($this->forceAuthn) {
         $root->setAttribute('ForceAuthn', 'true');
     }
     if ($this->ProviderName !== null) {
         $root->setAttribute('ProviderName', $this->ProviderName);
     }
     if ($this->isPassive) {
         $root->setAttribute('IsPassive', 'true');
     }
     if ($this->assertionConsumerServiceIndex !== null) {
         $root->setAttribute('AssertionConsumerServiceIndex', $this->assertionConsumerServiceIndex);
     } else {
         if ($this->assertionConsumerServiceURL !== null) {
             $root->setAttribute('AssertionConsumerServiceURL', $this->assertionConsumerServiceURL);
         }
         if ($this->protocolBinding !== null) {
             $root->setAttribute('ProtocolBinding', $this->protocolBinding);
         }
     }
     if ($this->attributeConsumingServiceIndex !== null) {
         $root->setAttribute('AttributeConsumingServiceIndex', $this->attributeConsumingServiceIndex);
     }
     $this->addSubject($root);
     if (!empty($this->nameIdPolicy)) {
         $nameIdPolicy = $this->document->createElementNS(Constants::NS_SAMLP, 'NameIDPolicy');
         if (array_key_exists('Format', $this->nameIdPolicy)) {
             $nameIdPolicy->setAttribute('Format', $this->nameIdPolicy['Format']);
         }
         if (array_key_exists('SPNameQualifier', $this->nameIdPolicy)) {
             $nameIdPolicy->setAttribute('SPNameQualifier', $this->nameIdPolicy['SPNameQualifier']);
         }
         if (array_key_exists('AllowCreate', $this->nameIdPolicy) && is_bool($this->nameIdPolicy['AllowCreate'])) {
             $nameIdPolicy->setAttribute('AllowCreate', $this->nameIdPolicy['AllowCreate'] ? 'true' : 'false');
         }
         $root->appendChild($nameIdPolicy);
     }
     $rac = $this->requestedAuthnContext;
     if (!empty($rac) && !empty($rac['AuthnContextClassRef'])) {
         $e = $this->document->createElementNS(Constants::NS_SAMLP, 'RequestedAuthnContext');
         $root->appendChild($e);
         if (isset($rac['Comparison']) && $rac['Comparison'] !== Constants::COMPARISON_EXACT) {
             $e->setAttribute('Comparison', $rac['Comparison']);
         }
         foreach ($rac['AuthnContextClassRef'] as $accr) {
             Utils::addString($e, Constants::NS_SAML, 'AuthnContextClassRef', $accr);
         }
     }
     if ($this->ProxyCount !== null || count($this->IDPList) > 0 || count($this->RequesterID) > 0) {
         $scoping = $this->document->createElementNS(Constants::NS_SAMLP, 'Scoping');
         $root->appendChild($scoping);
         if ($this->ProxyCount !== null) {
             $scoping->setAttribute('ProxyCount', $this->ProxyCount);
         }
         if (count($this->IDPList) > 0) {
             $idplist = $this->document->createElementNS(Constants::NS_SAMLP, 'IDPList');
             foreach ($this->IDPList as $provider) {
                 $idpEntry = $this->document->createElementNS(Constants::NS_SAMLP, 'IDPEntry');
                 if (is_string($provider)) {
                     $idpEntry->setAttribute('ProviderID', $provider);
                 } elseif (is_array($provider)) {
                     foreach ($provider as $attribute => $value) {
                         if (in_array($attribute, array('ProviderID', 'Loc', 'Name'))) {
                             $idpEntry->setAttribute($attribute, $value);
                         }
                     }
                 }
                 $idplist->appendChild($idpEntry);
             }
             $scoping->appendChild($idplist);
         }
         if (count($this->RequesterID) > 0) {
             Utils::addStrings($scoping, Constants::NS_SAMLP, 'RequesterID', false, $this->RequesterID);
         }
     }
     return $root;
 }
Example #3
0
 /**
  * Convert subject query message to an XML element.
  *
  * @return \DOMElement This subject query.
  */
 public function toUnsignedXML()
 {
     $root = parent::toUnsignedXML();
     $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
     $root->appendChild($subject);
     Utils::addNameId($subject, $this->nameId);
     return $root;
 }
Example #4
0
 /**
  * Convert this logout request message to an XML element.
  *
  * @return \DOMElement This logout request.
  */
 public function toUnsignedXML()
 {
     $root = parent::toUnsignedXML();
     if ($this->notOnOrAfter !== null) {
         $root->setAttribute('NotOnOrAfter', gmdate('Y-m-d\\TH:i:s\\Z', $this->notOnOrAfter));
     }
     if ($this->encryptedNameId === null) {
         Utils::addNameId($root, $this->nameId);
     } else {
         $eid = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
         $root->appendChild($eid);
         $eid->appendChild($root->ownerDocument->importNode($this->encryptedNameId, true));
     }
     foreach ($this->sessionIndexes as $sessionIndex) {
         Utils::addString($root, Constants::NS_SAMLP, 'SessionIndex', $sessionIndex);
     }
     return $root;
 }