@@ -728,12 +728,6 @@ public function getAttributes()
728728 /** @var $entry DOMNode */
729729 foreach ($ entries as $ entry ) {
730730 $ 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- }
737731
738732 if (in_array ($ attributeName , array_keys ($ attributes ))) {
739733 throw new OneLogin_Saml2_ValidationError (
@@ -742,6 +736,54 @@ public function getAttributes()
742736 );
743737 }
744738
739+ $ attributeValues = array ();
740+ foreach ($ entry ->childNodes as $ childNode ) {
741+ $ tagName = ($ childNode ->prefix ? $ childNode ->prefix .': ' : '' ) . 'AttributeValue ' ;
742+ if ($ childNode ->nodeType == XML_ELEMENT_NODE && $ childNode ->tagName === $ tagName ) {
743+ $ attributeValues [] = $ childNode ->nodeValue ;
744+ }
745+ }
746+
747+ $ attributes [$ attributeName ] = $ attributeValues ;
748+ }
749+ return $ attributes ;
750+ }
751+
752+ /**
753+ * Gets the Attributes from the AttributeStatement element using their FriendlyName.
754+ *
755+ * @return array The attributes of the SAML Assertion
756+ */
757+ public function getAttributesWithFriendlyName ()
758+ {
759+ $ attributes = array ();
760+
761+ /* EncryptedAttributes not supported
762+
763+ $encriptedAttributes = $this->_queryAssertion('/saml:AttributeStatement/saml:EncryptedAttribute');
764+
765+ if ($encriptedAttributes->length > 0) {
766+ foreach ($encriptedAttributes as $encriptedAttribute) {
767+ $key = $this->_settings->getSPkey();
768+ $seckey = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'private'));
769+ $seckey->loadKey($key);
770+ $attribute = OneLogin_Saml2_Utils::decryptElement($encriptedAttribute->firstChild(), $seckey);
771+ }
772+ }
773+ */
774+
775+ $ entries = $ this ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
776+
777+ /** @var $entry DOMNode */
778+ foreach ($ entries as $ entry ) {
779+ $ attributeFriendlyNameNode = $ entry ->attributes ->getNamedItem ('FriendlyName ' );
780+
781+ if ($ attributeFriendlyNameNode === null ) {
782+ continue ;
783+ }
784+
785+ $ attributeFriendlyName = $ attributeFriendlyNameNode ->nodeValue ;
786+
745787 if (!empty ($ attributeFriendlyName ) && in_array ($ attributeFriendlyName , array_keys ($ attributes ))) {
746788 throw new OneLogin_Saml2_ValidationError (
747789 "Found an Attribute element with duplicated FriendlyName " ,
@@ -757,11 +799,7 @@ public function getAttributes()
757799 }
758800 }
759801
760- $ attributes [$ attributeName ] = $ attributeValues ;
761-
762- if (!empty ($ attributeFriendlyName )) {
763- $ attributes [$ attributeFriendlyName ] = $ attributeValues ;
764- }
802+ $ attributes [$ attributeFriendlyName ] = $ attributeValues ;
765803 }
766804 return $ attributes ;
767805 }
0 commit comments