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