NotOnOrAfter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator;
6
7
use DateInterval;
8
use SimpleSAML\SAML2\Assertion\Validation\AssertionConstraintValidator;
9
use SimpleSAML\SAML2\Assertion\Validation\Result;
10
use SimpleSAML\SAML2\Utils;
11
use SimpleSAML\SAML2\XML\saml\Assertion;
12
13
class NotOnOrAfter implements AssertionConstraintValidator
14
{
15
    /**
16
     * @param \SimpleSAML\SAML2\XML\saml\Assertion $assertion
17
     * @param \SimpleSAML\SAML2\Assertion\Validation\Result $result
18
     */
19
    public function validate(Assertion $assertion, Result $result): void
20
    {
21
        $notOnOrAfter = $assertion->getConditions()?->getNotOnOrAfter()?->toDateTime();
22
        $clock = Utils::getContainer()->getClock();
23
24
        if (($notOnOrAfter !== null) && ($notOnOrAfter <= ($clock->now()->sub(new DateInterval('PT60S'))))) {
25
            $result->addError(
26
                'Received an assertion that has expired. Check clock synchronization on IdP and SP.',
27
            );
28
        }
29
    }
30
}
31