@@ -707,31 +707,38 @@ public function getSessionIndex()
707707 */
708708 public function getAttributes ()
709709 {
710- $ attributes = array ();
711-
712- /* EncryptedAttributes not supported
710+ return $ this ->_getAttributesByKeyName ('Name ' );
711+ }
713712
714- $encriptedAttributes = $this->_queryAssertion('/saml:AttributeStatement/saml:EncryptedAttribute');
713+ /**
714+ * Gets the Attributes from the AttributeStatement element using their FriendlyName.
715+ *
716+ * @return array The attributes of the SAML Assertion
717+ */
718+ public function getAttributesWithFriendlyName ()
719+ {
720+ return $ this ->_getAttributesByKeyName ('FriendlyName ' );
721+ }
715722
716- if ($encriptedAttributes->length > 0) {
717- foreach ($encriptedAttributes as $encriptedAttribute) {
718- $key = $this->_settings->getSPkey();
719- $seckey = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'private'));
720- $seckey->loadKey($key);
721- $attribute = OneLogin_Saml2_Utils::decryptElement($encriptedAttribute->firstChild(), $seckey);
722- }
723- }
724- */
723+ private function _getAttributesByKeyName ($ keyName ="Name " )
724+ {
725+ $ attributes = array ();
725726
726727 $ entries = $ this ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
727728
728729 /** @var $entry DOMNode */
729730 foreach ($ entries as $ entry ) {
730- $ attributeName = $ entry ->attributes ->getNamedItem ('Name ' )->nodeValue ;
731+ $ attributeKeyNode = $ entry ->attributes ->getNamedItem ($ keyName );
732+
733+ if ($ attributeKeyNode === null ) {
734+ continue ;
735+ }
736+
737+ $ attributeKeyName = $ attributeKeyNode ->nodeValue ;
731738
732- if (in_array ($ attributeName , array_keys ($ attributes ))) {
739+ if (in_array ($ attributeKeyName , array_keys ($ attributes ))) {
733740 throw new OneLogin_Saml2_ValidationError (
734- "Found an Attribute element with duplicated Name " ,
741+ "Found an Attribute element with duplicated " . $ keyName ,
735742 OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
736743 );
737744 }
@@ -744,7 +751,7 @@ public function getAttributes()
744751 }
745752 }
746753
747- $ attributes [$ attributeName ] = $ attributeValues ;
754+ $ attributes [$ attributeKeyName ] = $ attributeValues ;
748755 }
749756 return $ attributes ;
750757 }
0 commit comments