SubjectConfirmationNotBefore   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 9 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\Result;
9
use SimpleSAML\SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
10
use SimpleSAML\SAML2\Utils;
11
use SimpleSAML\SAML2\XML\saml\SubjectConfirmation;
12
13
class SubjectConfirmationNotBefore implements SubjectConfirmationConstraintValidator
14
{
15
    /**
16
     * @param \SimpleSAML\SAML2\XML\saml\SubjectConfirmation $subjectConfirmation
17
     * @param \SimpleSAML\SAML2\Assertion\Validation\Result $result
18
     *
19
     * @throws \SimpleSAML\Assert\AssertionFailedException if assertions are false
20
     */
21
    public function validate(
22
        SubjectConfirmation $subjectConfirmation,
23
        Result $result,
24
    ): void {
25
        $notBefore = $subjectConfirmation->getSubjectConfirmationData()?->getNotBefore()?->toDateTime();
26
        $clock = Utils::getContainer()->getClock();
27
28
        if ($notBefore !== null && $notBefore > ($clock->now()->add(new DateInterval('PT60S')))) {
29
            $result->addError('NotBefore in SubjectConfirmationData is in the future');
30
        }
31
    }
32
}
33