/** * 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 = new DOMDocument(); $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:EntityDescriptor'); $doc->appendChild($e); } else { $e = $parent->ownerDocument->createElementNS(SAML2_Const::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); } SAML2_XML_md_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; }
/** * 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(SAML2_Const::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); } SAML2_XML_md_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; }