1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace Sop\X509\AttributeCertificate\Validation; |
6
|
|
|
|
7
|
|
|
use Sop\X509\Certificate\Extension\Target\Target; |
8
|
|
|
use Sop\X509\CertificationPath\CertificationPath; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Provides configuration context for the attribute certificate validation. |
12
|
|
|
*/ |
13
|
|
|
class ACValidationConfig |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Certification path of the AC holder. |
17
|
|
|
* |
18
|
|
|
* @var CertificationPath |
19
|
|
|
*/ |
20
|
|
|
protected $_holderPath; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Certification path of the AC issuer. |
24
|
|
|
* |
25
|
|
|
* @var CertificationPath |
26
|
|
|
*/ |
27
|
|
|
protected $_issuerPath; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Evaluation reference time. |
31
|
|
|
* |
32
|
|
|
* @var \DateTimeImmutable |
33
|
|
|
*/ |
34
|
|
|
protected $_evalTime; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Permitted targets. |
38
|
|
|
* |
39
|
|
|
* @var Target[] |
40
|
|
|
*/ |
41
|
|
|
protected $_targets; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Constructor. |
45
|
|
|
* |
46
|
|
|
* @param CertificationPath $holder_path Certification path of the AC holder |
47
|
|
|
* @param CertificationPath $issuer_path Certification path of the AC issuer |
48
|
|
|
*/ |
49
|
12 |
|
public function __construct(CertificationPath $holder_path, |
50
|
|
|
CertificationPath $issuer_path) |
51
|
|
|
{ |
52
|
12 |
|
$this->_holderPath = $holder_path; |
53
|
12 |
|
$this->_issuerPath = $issuer_path; |
54
|
12 |
|
$this->_evalTime = new \DateTimeImmutable(); |
55
|
12 |
|
$this->_targets = []; |
56
|
12 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get certification path of the AC's holder. |
60
|
|
|
* |
61
|
|
|
* @return CertificationPath |
62
|
|
|
*/ |
63
|
12 |
|
public function holderPath(): CertificationPath |
64
|
|
|
{ |
65
|
12 |
|
return $this->_holderPath; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get certification path of the AC's issuer. |
70
|
|
|
* |
71
|
|
|
* @return CertificationPath |
72
|
|
|
*/ |
73
|
10 |
|
public function issuerPath(): CertificationPath |
74
|
|
|
{ |
75
|
10 |
|
return $this->_issuerPath; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get self with given evaluation reference time. |
80
|
|
|
* |
81
|
|
|
* @param \DateTimeImmutable $dt |
82
|
|
|
* |
83
|
|
|
* @return self |
84
|
2 |
|
*/ |
85
|
|
|
public function withEvaluationTime(\DateTimeImmutable $dt): self |
86
|
2 |
|
{ |
87
|
2 |
|
$obj = clone $this; |
88
|
2 |
|
$obj->_evalTime = $dt; |
89
|
|
|
return $obj; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get the evaluation reference time. |
94
|
|
|
* |
95
|
|
|
* @return \DateTimeImmutable |
96
|
12 |
|
*/ |
97
|
|
|
public function evaluationTime(): \DateTimeImmutable |
98
|
12 |
|
{ |
99
|
|
|
return $this->_evalTime; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Get self with permitted targets. |
104
|
|
|
* |
105
|
|
|
* @param Target ...$targets |
106
|
|
|
* |
107
|
3 |
|
* @return self |
108
|
|
|
*/ |
109
|
3 |
|
public function withTargets(Target ...$targets): self |
110
|
3 |
|
{ |
111
|
3 |
|
$obj = clone $this; |
112
|
|
|
$obj->_targets = $targets; |
113
|
|
|
return $obj; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get array of permitted targets. |
118
|
|
|
* |
119
|
2 |
|
* @return Target[] |
120
|
|
|
*/ |
121
|
2 |
|
public function targets(): array |
122
|
|
|
{ |
123
|
|
|
return $this->_targets; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|