| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\AttributeCertificate\Validation; |
| 6 |
|
| 7 |
use DateTimeImmutable; |
| 8 |
use Psr\Clock\ClockInterface; |
| 9 |
use SpomkyLabs\Pki\X509\Certificate\Extension\Target\Target; |
| 10 |
use SpomkyLabs\Pki\X509\CertificationPath\CertificationPath; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
final class ACValidationConfig |
| 16 |
{ |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
private DateTimeImmutable $evalTime; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
private array $targets; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
private function __construct( |
| 34 |
private readonly CertificationPath $holderPath, |
| 35 |
private readonly CertificationPath $issuerPath, |
| 36 |
?ClockInterface $clock = null, |
| 37 |
) { |
| 38 |
$this->evalTime = $clock !== null ? $clock->now() : new DateTimeImmutable(); |
| 39 |
$this->targets = []; |
| 40 |
} |
| 41 |
|
| 42 |
public static function create( |
| 43 |
CertificationPath $holderPath, |
| 44 |
CertificationPath $issuerPath, |
| 45 |
?ClockInterface $clock = null, |
| 46 |
): self { |
| 47 |
return new self($holderPath, $issuerPath, $clock); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public function holderPath(): CertificationPath |
| 54 |
{ |
| 55 |
return $this->holderPath; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
public function issuerPath(): CertificationPath |
| 62 |
{ |
| 63 |
return $this->issuerPath; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public function withEvaluationTime(DateTimeImmutable $dt): self |
| 70 |
{ |
| 71 |
$obj = clone $this; |
| 72 |
$obj->evalTime = $dt; |
| 73 |
return $obj; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public function evaluationTime(): DateTimeImmutable |
| 80 |
{ |
| 81 |
return $this->evalTime; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public function withTargets(Target ...$targets): self |
| 88 |
{ |
| 89 |
$obj = clone $this; |
| 90 |
$obj->targets = $targets; |
| 91 |
return $obj; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
public function targets(): array |
| 100 |
{ |
| 101 |
return $this->targets; |
| 102 |
} |
| 103 |
} |