File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed
Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 1818use SimpleSAML \XMLSecurity \Backend \EncryptionBackend ;
1919use SimpleSAML \XMLSecurity \XML \EncryptableElementInterface ;
2020
21+ use function array_unique ;
22+ use function count ;
2123use function strval ;
2224
2325/**
@@ -65,7 +67,7 @@ public function __construct(
6567 array $ namespacedAttribute = [],
6668 ) {
6769 Assert::maxCount ($ attributeValue , C::UNBOUNDED_LIMIT );
68- Assert::allIsInstanceOf ($ attributeValue , AttributeValue::class, ' Invalid AttributeValue. ' );
70+ Assert::allIsInstanceOf ($ attributeValue , AttributeValue::class, InvalidDOMElementException::class );
6971
7072 switch (strval ($ nameFormat )) {
7173 case C::NAMEFORMAT_URI :
@@ -82,6 +84,22 @@ public function __construct(
8284 break ;
8385 }
8486
87+ $ types = array_map (
88+ function (AttributeValue $ av ) {
89+ return $ av ->getXsiType ();
90+ },
91+ $ attributeValue ,
92+ );
93+
94+ if ($ types !== []) {
95+ Assert::same (
96+ count (array_unique ($ types )),
97+ 1 ,
98+ "All of the <AttributeValue> elements must have the identical datatype assigned. " ,
99+ ProtocolViolationException::class,
100+ );
101+ }
102+
85103 $ this ->setAttributesNS ($ namespacedAttribute );
86104 }
87105
Original file line number Diff line number Diff line change @@ -93,9 +93,6 @@ public function testMarshalling(): void
9393 [
9494 new AttributeValue (StringValue::fromString ('FirstValue ' )),
9595 new AttributeValue (StringValue::fromString ('SecondValue ' )),
96- new AttributeValue (IntegerValue::fromInteger (3 )),
97- new AttributeValue (DateTimeValue::fromString ('2024-04-04T04:44:44Z ' )),
98- new AttributeValue (null ),
9996 ],
10097 [$ attr1 , $ attr2 ],
10198 );
Original file line number Diff line number Diff line change 1- <saml : Attribute xmlns : saml =" urn:oasis:names:tc:SAML:2.0:assertion" xmlns : test =" urn:test:something" xmlns : xsi = " http://www.w3.org/2001/XMLSchema-instance " xmlns : xs = " http://www.w3.org/2001/XMLSchema " Name =" TheName" NameFormat =" urn:oasis:names:tc:SAML:2.0:attrname-format:basic" FriendlyName =" TheFriendlyName" test : attr1 =" testval1" test : attr2 =" testval2" >
1+ <saml : Attribute xmlns : saml =" urn:oasis:names:tc:SAML:2.0:assertion" xmlns : test =" urn:test:something" Name =" TheName" NameFormat =" urn:oasis:names:tc:SAML:2.0:attrname-format:basic" FriendlyName =" TheFriendlyName" test : attr1 =" testval1" test : attr2 =" testval2" >
22 <saml : AttributeValue >FirstValue</saml : AttributeValue >
33 <saml : AttributeValue >SecondValue</saml : AttributeValue >
4- <saml : AttributeValue xsi : type =" xs:integer" >3</saml : AttributeValue >
5- <saml : AttributeValue xsi : type =" xs:dateTime" >2024-04-04T04:44:44Z</saml : AttributeValue >
6- <saml : AttributeValue xsi : nil =" 1" />
74</saml : Attribute >
You can’t perform that action at this time.
0 commit comments