@@ -804,6 +804,9 @@ private function _getAttributesByKeyName($keyName = "Name")
804804 {
805805 $ attributes = array ();
806806 $ entries = $ this ->_queryAssertion ('/saml:AttributeStatement/saml:Attribute ' );
807+
808+ $ security = $ this ->_settings ->getSecurityData ();
809+ $ allowRepeatAttributeName = $ security ['allowRepeatAttributeName ' ];
807810 /** @var $entry DOMNode */
808811 foreach ($ entries as $ entry ) {
809812 $ attributeKeyNode = $ entry ->attributes ->getNamedItem ($ keyName );
@@ -812,10 +815,12 @@ private function _getAttributesByKeyName($keyName = "Name")
812815 }
813816 $ attributeKeyName = $ attributeKeyNode ->nodeValue ;
814817 if (in_array ($ attributeKeyName , array_keys ($ attributes ))) {
815- throw new ValidationError (
816- "Found an Attribute element with duplicated " .$ keyName ,
817- ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
818- );
818+ if (!$ allowRepeatAttributeName ) {
819+ throw new ValidationError (
820+ "Found an Attribute element with duplicated " .$ keyName ,
821+ ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
822+ );
823+ }
819824 }
820825 $ attributeValues = array ();
821826 foreach ($ entry ->childNodes as $ childNode ) {
@@ -824,7 +829,12 @@ private function _getAttributesByKeyName($keyName = "Name")
824829 $ attributeValues [] = $ childNode ->nodeValue ;
825830 }
826831 }
827- $ attributes [$ attributeKeyName ] = $ attributeValues ;
832+
833+ if (in_array ($ attributeKeyName , array_keys ($ attributes ))) {
834+ $ attributes [$ attributeKeyName ] = array_merge ($ attributes [$ attributeKeyName ], $ attributeValues );
835+ } else {
836+ $ attributes [$ attributeKeyName ] = $ attributeValues ;
837+ }
828838 }
829839 return $ attributes ;
830840 }
0 commit comments