private function SAML2_Assertion::parseAttributes in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8
Parse attribute statements in assertion.
Parameters
DOMElement $xml The XML element with the assertion.:
Throws
Exception
1 call to SAML2_Assertion::parseAttributes()
File
- src/
SAML2_Assertion.php, line 276
Class
Namespace
Drupal\miniorange_samlCode
private function parseAttributes(DOMElement $xml) {
$firstAttribute = TRUE;
$attributes = Utilities::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
foreach ($attributes as $attribute) {
if (!$attribute
->hasAttribute('Name')) {
throw new Exception('Missing name on <saml:Attribute> element.');
}
$name = $attribute
->getAttribute('Name');
if ($attribute
->hasAttribute('NameFormat')) {
$nameFormat = $attribute
->getAttribute('NameFormat');
}
else {
$nameFormat = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified';
}
if ($firstAttribute) {
$this->nameFormat = $nameFormat;
$firstAttribute = FALSE;
}
else {
if ($this->nameFormat !== $nameFormat) {
$this->nameFormat = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified';
}
}
if (!array_key_exists($name, $this->attributes)) {
$this->attributes[$name] = array();
}
$values = Utilities::xpQuery($attribute, './saml_assertion:AttributeValue');
foreach ($values as $value) {
$this->attributes[$name][] = trim($value->textContent);
}
}
}