@@ -707,46 +707,7 @@ public function getSessionIndex()
707707     */ 
708708    public  function  getAttributes ()
709709    {
710-         $ attributes  = array ();
711- 
712-         /* EncryptedAttributes not supported 
713- 
714-         $encriptedAttributes = $this->_queryAssertion('/saml:AttributeStatement/saml:EncryptedAttribute'); 
715- 
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-         */ 
725- 
726-         $ entries  = $ this  ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
727- 
728-         /** @var $entry DOMNode */ 
729-         foreach  ($ entries  as  $ entry ) {
730-             $ attributeName  = $ entry ->attributes ->getNamedItem ('Name ' )->nodeValue ;
731- 
732-             if  (in_array ($ attributeName , array_keys ($ attributes ))) {
733-                 throw  new  OneLogin_Saml2_ValidationError (
734-                     "Found an Attribute element with duplicated Name " ,
735-                     OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND 
736-                 );
737-             }
738- 
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 ;
710+         return  $ this  ->_getAttributesByKeyName ('Name ' );
750711    }
751712
752713    /** 
@@ -756,37 +717,28 @@ public function getAttributes()
756717     */ 
757718    public  function  getAttributesWithFriendlyName ()
758719    {
759-         $ attributes  = array ();
760- 
761-         /* EncryptedAttributes not supported 
762- 
763-         $encriptedAttributes = $this->_queryAssertion('/saml:AttributeStatement/saml:EncryptedAttribute'); 
720+         return  $ this  ->_getAttributesByKeyName ('FriendlyName ' );
721+     }
764722
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-         */ 
723+     private  function  _getAttributesByKeyName ($ keyName ="Name " )
724+     {
725+         $ attributes  = array ();
774726
775727        $ entries  = $ this  ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
776728
777729        /** @var $entry DOMNode */ 
778730        foreach  ($ entries  as  $ entry ) {
779-             $ attributeFriendlyNameNode   = $ entry ->attributes ->getNamedItem (' FriendlyName '  );
731+             $ attributeKeyNode   = $ entry ->attributes ->getNamedItem ($ keyName  );
780732
781-             if  ($ attributeFriendlyNameNode   === null ) {
733+             if  ($ attributeKeyNode   === null ) {
782734                continue ;
783735            }
784736
785-             $ attributeFriendlyName   = $ attributeFriendlyNameNode  ->nodeValue ;
737+             $ attributeKeyName   = $ attributeKeyNode  ->nodeValue ;
786738
787-             if  (in_array ($ attributeFriendlyName  , array_keys ($ attributes ))) {
739+             if  (in_array ($ attributeKeyName  , array_keys ($ attributes ))) {
788740                throw  new  OneLogin_Saml2_ValidationError (
789-                     "Found an Attribute element with duplicated FriendlyName  "  ,
741+                     "Found an Attribute element with duplicated  "  . $ keyName  ,
790742                    OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND 
791743                );
792744            }
@@ -799,7 +751,7 @@ public function getAttributesWithFriendlyName()
799751                }
800752            }
801753
802-             $ attributes [$ attributeFriendlyName  ] = $ attributeValues ;
754+             $ attributes [$ attributeKeyName  ] = $ attributeValues ;
803755        }
804756        return  $ attributes ;
805757    }
0 commit comments