Skip to content

Commit a5b8508

Browse files
committed
Add attributes to attribute array using FriendlyName in getAttributes method
1 parent 539a3eb commit a5b8508

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

lib/Saml2/Response.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,13 @@ public function getAttributes()
727727

728728
/** @var $entry DOMNode */
729729
foreach ($entries as $entry) {
730-
$attributeName = $entry->attributes->getNamedItem('Name')->nodeValue;
730+
$attributeName = $entry->attributes->getNamedItem('Name')->nodeValue;
731+
$attributeFriendlyName = null;
732+
733+
$attributeFriendlyNameNode = $entry->attributes->getNamedItem('FriendlyName');
734+
if ($attributeFriendlyNameNode !== null) {
735+
$attributeFriendlyName = $attributeFriendlyNameNode->nodeValue;
736+
}
731737

732738
if (in_array($attributeName, array_keys($attributes))) {
733739
throw new OneLogin_Saml2_ValidationError(
@@ -736,6 +742,13 @@ public function getAttributes()
736742
);
737743
}
738744

745+
if (!empty($attributeFriendlyName) && in_array($attributeFriendlyName, array_keys($attributes))) {
746+
throw new OneLogin_Saml2_ValidationError(
747+
"Found an Attribute element with duplicated FriendlyName",
748+
OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
749+
);
750+
}
751+
739752
$attributeValues = array();
740753
foreach ($entry->childNodes as $childNode) {
741754
$tagName = ($childNode->prefix ? $childNode->prefix.':' : '') . 'AttributeValue';
@@ -745,6 +758,10 @@ public function getAttributes()
745758
}
746759

747760
$attributes[$attributeName] = $attributeValues;
761+
762+
if (!empty($attributeFriendlyName)) {
763+
$attributes[$attributeFriendlyName] = $attributeValues;
764+
}
748765
}
749766
return $attributes;
750767
}

0 commit comments

Comments
 (0)