ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RegistrationInfo.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\mdrpi;
4
6
14{
21
28
36 public $RegistrationPolicy = array();
37
44 public function __construct(\DOMElement $xml = null)
45 {
46 if ($xml === null) {
47 return;
48 }
49
50 if (!$xml->hasAttribute('registrationAuthority')) {
51 throw new \Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.');
52 }
53 $this->registrationAuthority = $xml->getAttribute('registrationAuthority');
54
55 if ($xml->hasAttribute('registrationInstant')) {
56 $this->registrationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('registrationInstant'));
57 }
58
59 $this->RegistrationPolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'RegistrationPolicy');
60 }
61
68 public function toXML(\DOMElement $parent)
69 {
70 assert(is_string($this->registrationAuthority));
71 assert(is_int($this->registrationInstant) || is_null($this->registrationInstant));
72 assert(is_array($this->RegistrationPolicy));
73
74 if (empty($this->registrationAuthority)) {
75 throw new \Exception('Missing required registration authority.');
76 }
77
78 $doc = $parent->ownerDocument;
79
80 $e = $doc->createElementNS(Common::NS_MDRPI, 'mdrpi:RegistrationInfo');
81 $parent->appendChild($e);
82
83 $e->setAttribute('registrationAuthority', $this->registrationAuthority);
84
85 if ($this->registrationInstant !== null) {
86 $e->setAttribute('registrationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->registrationInstant));
87 }
88
89 Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:RegistrationPolicy', true, $this->RegistrationPolicy);
90
91 return $e;
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
static addStrings(\DOMElement $parent, $namespace, $name, $localized, array $values)
Append string elements.
Definition: Utils.php:659
static extractLocalizedStrings(\DOMElement $parent, $namespaceURI, $localName)
Extract localized strings from a set of nodes.
Definition: Utils.php:580
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp.
Definition: Utils.php:721
__construct(\DOMElement $xml=null)
Create/parse a mdrpi:RegistrationInfo element.
toXML(\DOMElement $parent)
Convert this element to XML.
$xml
Definition: metadata.php:240