Beispiel #1
0
 /**
  * Test adding two random elements
  */
 public function testExtensionsAddSome()
 {
     $attribute = new Attribute();
     $attribute->Name = 'TheName';
     $scope = new Scope();
     $scope->scope = "scope";
     Extensions::addList($this->testElement, array($attribute, $scope));
     $list = Extensions::getList($this->testElement);
     $this->assertCount(4, $list);
     $this->assertEquals("urn:mynamespace", $list[0]->namespaceURI);
     $this->assertEquals("ExampleElement", $list[1]->localName);
     $this->assertEquals("Attribute", $list[2]->localName);
     $this->assertEquals("urn:mace:shibboleth:metadata:1.0", $list[3]->namespaceURI);
 }
Beispiel #2
0
 /**
  * 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) {
         Utils::addString($root, Constants::NS_SAML, 'saml:Issuer', $this->issuer);
     }
     if (!empty($this->extensions)) {
         Extensions::addList($root, $this->extensions);
     }
     return $root;
 }