@@ -707,46 +707,7 @@ public function getSessionIndex()
707
707
*/
708
708
public function getAttributes ()
709
709
{
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 ' );
750
711
}
751
712
752
713
/**
@@ -756,37 +717,28 @@ public function getAttributes()
756
717
*/
757
718
public function getAttributesWithFriendlyName ()
758
719
{
759
- $ attributes = array ();
760
-
761
- /* EncryptedAttributes not supported
762
-
763
- $encriptedAttributes = $this->_queryAssertion('/saml:AttributeStatement/saml:EncryptedAttribute');
720
+ return $ this ->_getAttributesByKeyName ('FriendlyName ' );
721
+ }
764
722
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 ();
774
726
775
727
$ entries = $ this ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
776
728
777
729
/** @var $entry DOMNode */
778
730
foreach ($ entries as $ entry ) {
779
- $ attributeFriendlyNameNode = $ entry ->attributes ->getNamedItem (' FriendlyName ' );
731
+ $ attributeKeyNode = $ entry ->attributes ->getNamedItem ($ keyName );
780
732
781
- if ($ attributeFriendlyNameNode === null ) {
733
+ if ($ attributeKeyNode === null ) {
782
734
continue ;
783
735
}
784
736
785
- $ attributeFriendlyName = $ attributeFriendlyNameNode ->nodeValue ;
737
+ $ attributeKeyName = $ attributeKeyNode ->nodeValue ;
786
738
787
- if (in_array ($ attributeFriendlyName , array_keys ($ attributes ))) {
739
+ if (in_array ($ attributeKeyName , array_keys ($ attributes ))) {
788
740
throw new OneLogin_Saml2_ValidationError (
789
- "Found an Attribute element with duplicated FriendlyName " ,
741
+ "Found an Attribute element with duplicated " . $ keyName ,
790
742
OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
791
743
);
792
744
}
@@ -799,7 +751,7 @@ public function getAttributesWithFriendlyName()
799
751
}
800
752
}
801
753
802
- $ attributes [$ attributeFriendlyName ] = $ attributeValues ;
754
+ $ attributes [$ attributeKeyName ] = $ attributeValues ;
803
755
}
804
756
return $ attributes ;
805
757
}
0 commit comments