File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 66
77use DOMElement ;
88use SimpleSAML \SAML2 \Assert \Assert ;
9+ use SimpleSAML \SAML2 \Constants as C ;
910use SimpleSAML \SAML2 \Exception \ArrayValidationException ;
11+ use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
1012use SimpleSAML \SAML2 \Type \SAMLAnyURIValue ;
1113use SimpleSAML \SAML2 \Type \SAMLStringValue ;
1214use SimpleSAML \XML \ArrayizableElementInterface ;
@@ -45,6 +47,18 @@ public function __construct(
4547 protected ?SAMLStringValue $ SPNameQualifier = null ,
4648 protected ?BooleanValue $ AllowCreate = null ,
4749 ) {
50+ if ($ AllowCreate ->equals (BooleanValue::fromBoolean (true )) {
51+ // Per Errata E14: AllowCreate
52+ Assert::notSame (
53+ $ Format ->getValue (),
54+ C::NAMEID_TRANSIENT ,
55+ ProtocolViolationException::class,
56+ sprintf (
57+ 'AllowCreate=\"true\" MUST NOT be used in conjunction with the %s <NameID> Format. ' ,
58+ C::NAMEID_TRANSIENT ,
59+ ),
60+ );
61+ }
4862 }
4963
5064
Original file line number Diff line number Diff line change 88use PHPUnit \Framework \Attributes \Group ;
99use PHPUnit \Framework \TestCase ;
1010use SimpleSAML \SAML2 \Constants as C ;
11+ use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
1112use SimpleSAML \SAML2 \Type \SAMLAnyURIValue ;
1213use SimpleSAML \SAML2 \Type \SAMLStringValue ;
1314use SimpleSAML \SAML2 \XML \samlp \AbstractSamlpElement ;
@@ -103,4 +104,19 @@ public function testMarshallingEmptyElement(): void
103104 );
104105 $ this ->assertTrue ($ nameIdPolicy ->isEmptyElement ());
105106 }
107+
108+
109+ /**
110+ * Illegal combination of AllowCreate=true and transient NameID format is rejected.
111+ */
112+ public function testIllegalCombinationThrowsException (): void
113+ {
114+ $ this ->expectException (ProtocolViolationException::class);
115+
116+ new NameIDPolicy (
117+ SAMLAnyURIValue::fromString (C::NAMEID_TRANSIENT ),
118+ SAMLStringValue::fromString ('urn:x-simplesamlphp:spnamequalifier ' ),
119+ BooleanValue::fromBoolean (true ),
120+ );
121+ }
106122}
You can’t perform that action at this time.
0 commit comments