68 parent::__construct(
$xml);
74 if (
$xml->hasAttribute(
'ID')) {
75 $this->ID =
$xml->getAttribute(
'ID');
77 if (
$xml->hasAttribute(
'validUntil')) {
80 if (
$xml->hasAttribute(
'cacheDuration')) {
81 $this->cacheDuration =
$xml->getAttribute(
'cacheDuration');
83 if (
$xml->hasAttribute(
'Name')) {
84 $this->Name =
$xml->getAttribute(
'Name');
89 foreach (
Utils::xpQuery(
$xml,
'./saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) {
90 if ($node->localName ===
'EntityDescriptor') {
104 public function toXML(\
DOMElement $parent = null)
106 assert(is_null($this->ID) || is_string($this->ID));
107 assert(is_null($this->validUntil) || is_int($this->validUntil));
108 assert(is_null($this->cacheDuration) || is_string($this->cacheDuration));
109 assert(is_null($this->Name) || is_string($this->Name));
111 assert(is_array($this->children));
113 if ($parent === null) {
116 $doc->appendChild($e);
118 $e = $parent->ownerDocument->createElementNS(
Constants::NS_MD,
'md:EntitiesDescriptor');
119 $parent->appendChild($e);
122 if (isset($this->ID)) {
123 $e->setAttribute(
'ID', $this->ID);
126 if (isset($this->validUntil)) {
127 $e->setAttribute(
'validUntil', gmdate(
'Y-m-d\TH:i:s\Z', $this->validUntil));
130 if (isset($this->cacheDuration)) {
131 $e->setAttribute(
'cacheDuration', $this->cacheDuration);
134 if (isset($this->Name)) {
135 $e->setAttribute(
'Name', $this->Name);
141 foreach ($this->children as $node) {
__construct(\DOMElement $xml=null)
Initialize an EntitiesDescriptor.
const NS_MD
The namespace for the SAML 2 metadata.
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
signElement(\DOMElement $root, \DOMElement $insertBefore=null)
Sign the given XML element.
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp...
static addList(\DOMElement $parent, array $extensions)
Add a list of Extensions to the given element.
static getList(\DOMElement $parent)
Get a list of Extensions in the given element.