Initialize an EntitiyDescriptor.
99 parent::__construct(
$xml);
105 if (!
$xml->hasAttribute(
'entityID')) {
106 throw new \Exception(
'Missing required attribute entityID on EntityDescriptor.');
108 $this->entityID =
$xml->getAttribute(
'entityID');
110 if (
$xml->hasAttribute(
'ID')) {
111 $this->ID =
$xml->getAttribute(
'ID');
113 if (
$xml->hasAttribute(
'validUntil')) {
116 if (
$xml->hasAttribute(
'cacheDuration')) {
117 $this->cacheDuration =
$xml->getAttribute(
'cacheDuration');
122 for ($node =
$xml->firstChild; $node !== null; $node = $node->nextSibling) {
131 switch ($node->localName) {
132 case 'RoleDescriptor':
133 $this->RoleDescriptor[] =
new UnknownRoleDescriptor($node);
135 case 'IDPSSODescriptor':
136 $this->RoleDescriptor[] =
new IDPSSODescriptor($node);
138 case 'SPSSODescriptor':
139 $this->RoleDescriptor[] =
new SPSSODescriptor($node);
141 case 'AuthnAuthorityDescriptor':
142 $this->RoleDescriptor[] =
new AuthnAuthorityDescriptor($node);
144 case 'AttributeAuthorityDescriptor':
145 $this->RoleDescriptor[] =
new AttributeAuthorityDescriptor($node);
147 case 'PDPDescriptor':
148 $this->RoleDescriptor[] =
new PDPDescriptor($node);
153 $affiliationDescriptor =
Utils::xpQuery(
$xml,
'./saml_metadata:AffiliationDescriptor');
154 if (count($affiliationDescriptor) > 1) {
155 throw new \Exception(
'More than one AffiliationDescriptor in the entity.');
156 } elseif (!empty($affiliationDescriptor)) {
157 $this->AffiliationDescriptor =
new AffiliationDescriptor($affiliationDescriptor[0]);
160 if (empty($this->RoleDescriptor) && is_null($this->AffiliationDescriptor)) {
161 throw new \Exception(
'Must have either one of the RoleDescriptors or an AffiliationDescriptor in EntityDescriptor.');
162 } elseif (!empty($this->RoleDescriptor) && !is_null($this->AffiliationDescriptor)) {
163 throw new \Exception(
'AffiliationDescriptor cannot be combined with other RoleDescriptor elements in EntityDescriptor.');
167 if (count($organization) > 1) {
168 throw new \Exception(
'More than one Organization in the entity.');
169 } elseif (!empty($organization)) {
170 $this->Organization =
new Organization($organization[0]);
174 $this->ContactPerson[] =
new ContactPerson($cp);
177 foreach (
Utils::xpQuery(
$xml,
'./saml_metadata:AdditionalMetadataLocation') as $aml) {
178 $this->AdditionalMetadataLocation[] =
new AdditionalMetadataLocation($aml);
const NS_MD
The namespace for the SAML 2 metadata.
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp...
static getList(\DOMElement $parent)
Get a list of Extensions in the given element.