File tree Expand file tree Collapse file tree 5 files changed +48
-1
lines changed
Expand file tree Collapse file tree 5 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 88use SimpleSAML \Assert \AssertionFailedException ;
99use SimpleSAML \SAML2 \Assert \Assert ;
1010use SimpleSAML \SAML2 \Constants as C ;
11+ use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
1112use SimpleSAML \SAML2 \Type \EntityIDValue ;
1213use SimpleSAML \SAML2 \Type \SAMLDateTimeValue ;
1314use SimpleSAML \SAML2 \Type \SAMLStringValue ;
@@ -61,6 +62,15 @@ public function __construct(
6162 array $ children = [],
6263 array $ namespacedAttributes = [],
6364 ) {
65+ /** SAML 2.0 Core specifications paragraph 2.4.1.2 */
66+ if ($ notBefore !== null && $ notOnOrAfter !== null ) {
67+ Assert::true (
68+ $ notBefore ->toDateTime () < $ notOnOrAfter ->toDateTime (),
69+ "The value for NotBefore MUST be less than (earlier than) the value for NotOnOrAfter. " ,
70+ ProtocolViolationException::class,
71+ );
72+ }
73+
6474 if ($ address !== null ) {
6575 try {
6676 /**
Original file line number Diff line number Diff line change @@ -43,6 +43,15 @@ public function __construct(
4343 protected ?OneTimeUse $ oneTimeUse = null ,
4444 protected ?ProxyRestriction $ proxyRestriction = null ,
4545 ) {
46+ /** SAML 2.0 Core specifications paragraph 2.5.1.2 */
47+ if ($ notBefore !== null && $ notOnOrAfter !== null ) {
48+ Assert::true (
49+ $ notBefore ->toDateTime () < $ notOnOrAfter ->toDateTime (),
50+ "The value for NotBefore MUST be less than (earlier than) the value for NotOnOrAfter. " ,
51+ ProtocolViolationException::class,
52+ );
53+ }
54+
4655 Assert::maxCount ($ condition , C::UNBOUNDED_LIMIT );
4756 Assert::allIsInstanceOf ($ condition , AbstractCondition::class);
4857 Assert::maxCount ($ audienceRestriction , C::UNBOUNDED_LIMIT );
Original file line number Diff line number Diff line change @@ -528,7 +528,7 @@ public function testCorrectSignatureMethodCanBeExtracted(): void
528528 <saml:SubjectConfirmationData NotOnOrAfter="2011-08-31T08:51:05Z" Recipient="https://sp.example.com/assertion_consumer" InResponseTo="_13603a6565a69297e9809175b052d115965121c8" />
529529 </saml:SubjectConfirmation>
530530 </saml:Subject>
531- <saml:Conditions NotOnOrAfter="2011-08-31T08:51:05Z" NotBefore="2011-08-31T08:51:05Z ">
531+ <saml:Conditions NotOnOrAfter="2011-08-31T08:51:05Z" NotBefore="2011-08-31T08:51:04Z ">
532532 <saml:AudienceRestriction>
533533 <saml:Audience>urn:test:ServiceProvider</saml:Audience>
534534 </saml:AudienceRestriction>
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 \SAMLDateTimeValue ;
1314use SimpleSAML \SAML2 \XML \saml \AbstractSamlElement ;
@@ -88,6 +89,19 @@ public function testMarshalling(): void
8889 }
8990
9091
92+ /**
93+ */
94+ public function testMarshallingNotBeforeAfterNotOnOrAfter (): void
95+ {
96+ $ this ->expectException (ProtocolViolationException::class);
97+
98+ new Conditions (
99+ SAMLDateTimeValue::fromString ('2024-01-18T06:21:48Z ' ),
100+ SAMLDateTimeValue::fromString ('2014-07-17T01:01:18Z ' ),
101+ );
102+ }
103+
104+
91105 /**
92106 * Adding no contents to a Conditions element should yield an empty element. If there were contents already
93107 * there, those should be left untouched.
Original file line number Diff line number Diff line change 77use PHPUnit \Framework \Attributes \CoversClass ;
88use PHPUnit \Framework \Attributes \Group ;
99use PHPUnit \Framework \TestCase ;
10+ use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
1011use SimpleSAML \SAML2 \Type \EntityIDValue ;
1112use SimpleSAML \SAML2 \Type \SAMLDateTimeValue ;
1213use SimpleSAML \SAML2 \Type \SAMLStringValue ;
@@ -88,6 +89,19 @@ public function testMarshalling(): void
8889 }
8990
9091
92+ /**
93+ */
94+ public function testMarshallingNotBeforeAfterNotOnOrAfter (): void
95+ {
96+ $ this ->expectException (ProtocolViolationException::class);
97+
98+ new SubjectConfirmationData (
99+ SAMLDateTimeValue::fromString ('2009-02-13T23:31:30Z ' ),
100+ SAMLDateTimeValue::fromString ('2001-04-19T04:25:21Z ' ),
101+ );
102+ }
103+
104+
91105 /**
92106 */
93107 public function testMarshallingWithNonIPAddress (): void
You can’t perform that action at this time.
0 commit comments