Ejemplo n.º 1
0
 /**
  * Create this EntityDescriptor.
  *
  * @param \DOMElement|null $parent The EntitiesDescriptor we should append this EntityDescriptor to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent = null)
 {
     assert('is_string($this->entityID)');
     assert('is_null($this->ID) || is_string($this->ID)');
     assert('is_null($this->validUntil) || is_int($this->validUntil)');
     assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)');
     assert('is_array($this->Extensions)');
     assert('is_array($this->RoleDescriptor)');
     assert('is_null($this->AffiliationDescriptor) || $this->AffiliationDescriptor instanceof \\SAML2\\XML\\md\\AffiliationDescriptor');
     assert('is_null($this->Organization) || $this->Organization instanceof \\SAML2\\XML\\md\\Organization');
     assert('is_array($this->ContactPerson)');
     assert('is_array($this->AdditionalMetadataLocation)');
     if ($parent === null) {
         $doc = DOMDocumentFactory::create();
         $e = $doc->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
         $doc->appendChild($e);
     } else {
         $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
         $parent->appendChild($e);
     }
     $e->setAttribute('entityID', $this->entityID);
     if (isset($this->ID)) {
         $e->setAttribute('ID', $this->ID);
     }
     if (isset($this->validUntil)) {
         $e->setAttribute('validUntil', gmdate('Y-m-d\\TH:i:s\\Z', $this->validUntil));
     }
     if (isset($this->cacheDuration)) {
         $e->setAttribute('cacheDuration', $this->cacheDuration);
     }
     Extensions::addList($e, $this->Extensions);
     /** @var \SAML2\XML\md\UnknownRoleDescriptor|\SAML2\XML\md\IDPSSODescriptor|\SAML2\XML\md\SPSSODescriptor|\SAML2\XML\md\AuthnAuthorityDescriptor|\SAML2\XML\md\AttributeAuthorityDescriptor|\SAML2\XML\md\PDPDescriptor $n */
     foreach ($this->RoleDescriptor as $n) {
         $n->toXML($e);
     }
     if (isset($this->AffiliationDescriptor)) {
         $this->AffiliationDescriptor->toXML($e);
     }
     if (isset($this->Organization)) {
         $this->Organization->toXML($e);
     }
     foreach ($this->ContactPerson as $cp) {
         $cp->toXML($e);
     }
     foreach ($this->AdditionalMetadataLocation as $n) {
         $n->toXML($e);
     }
     $this->signElement($e, $e->firstChild);
     return $e;
 }
Ejemplo n.º 2
0
 /**
  * Add this RoleDescriptor to an EntityDescriptor.
  *
  * @param \DOMElement $parent The EntityDescriptor we should append this endpoint to.
  * @return \DOMElement
  */
 protected function toXML(\DOMElement $parent)
 {
     assert('is_null($this->ID) || is_string($this->ID)');
     assert('is_null($this->validUntil) || is_int($this->validUntil)');
     assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)');
     assert('is_array($this->protocolSupportEnumeration)');
     assert('is_null($this->errorURL) || is_string($this->errorURL)');
     assert('is_array($this->Extensions)');
     assert('is_array($this->KeyDescriptor)');
     assert('is_null($this->Organization) || $this->Organization instanceof \\SAML2\\XML\\md\\Organization');
     assert('is_array($this->ContactPerson)');
     $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, $this->elementName);
     $parent->appendChild($e);
     if (isset($this->ID)) {
         $e->setAttribute('ID', $this->ID);
     }
     if (isset($this->validUntil)) {
         $e->setAttribute('validUntil', gmdate('Y-m-d\\TH:i:s\\Z', $this->validUntil));
     }
     if (isset($this->cacheDuration)) {
         $e->setAttribute('cacheDuration', $this->cacheDuration);
     }
     $e->setAttribute('protocolSupportEnumeration', implode(' ', $this->protocolSupportEnumeration));
     if (isset($this->errorURL)) {
         $e->setAttribute('errorURL', $this->errorURL);
     }
     Extensions::addList($e, $this->Extensions);
     foreach ($this->KeyDescriptor as $kd) {
         $kd->toXML($e);
     }
     if (isset($this->Organization)) {
         $this->Organization->toXML($e);
     }
     foreach ($this->ContactPerson as $cp) {
         $cp->toXML($e);
     }
     return $e;
 }