1 | <?php |
||
20 | class Holder |
||
21 | { |
||
22 | /** |
||
23 | * Holder PKC's issuer and serial. |
||
24 | * |
||
25 | * @var IssuerSerial|null $_baseCertificateID |
||
26 | */ |
||
27 | protected $_baseCertificateID; |
||
28 | |||
29 | /** |
||
30 | * Holder PKC's subject. |
||
31 | * |
||
32 | * @var GeneralNames|null $_entityName |
||
33 | */ |
||
34 | protected $_entityName; |
||
35 | |||
36 | /** |
||
37 | * Linked object. |
||
38 | * |
||
39 | * @var ObjectDigestInfo|null $_objectDigestInfo |
||
40 | */ |
||
41 | protected $_objectDigestInfo; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param IssuerSerial|null $issuer_serial |
||
47 | * @param GeneralNames|null $entity_name |
||
48 | */ |
||
49 | 21 | public function __construct(IssuerSerial $issuer_serial = null, |
|
55 | |||
56 | /** |
||
57 | * Initialize from a holder's public key certificate. |
||
58 | * |
||
59 | * @param Certificate $cert |
||
60 | * @return self |
||
61 | */ |
||
62 | 1 | public static function fromPKC(Certificate $cert): self |
|
66 | |||
67 | /** |
||
68 | * Initialize from ASN.1. |
||
69 | * |
||
70 | * @param Sequence $seq |
||
71 | */ |
||
72 | 7 | public static function fromASN1(Sequence $seq): self |
|
99 | |||
100 | /** |
||
101 | * Get self with base certificate ID. |
||
102 | * |
||
103 | * @param IssuerSerial $issuer |
||
104 | * @return self |
||
105 | */ |
||
106 | 1 | public function withBaseCertificateID(IssuerSerial $issuer): self |
|
112 | |||
113 | /** |
||
114 | * Get self with entity name. |
||
115 | * |
||
116 | * @param GeneralNames $names |
||
117 | * @return self |
||
118 | */ |
||
119 | 1 | public function withEntityName(GeneralNames $names): self |
|
125 | |||
126 | /** |
||
127 | * Get self with object digest info. |
||
128 | * |
||
129 | * @param ObjectDigestInfo $odi |
||
130 | * @return self |
||
131 | */ |
||
132 | 2 | public function withObjectDigestInfo(ObjectDigestInfo $odi): self |
|
138 | |||
139 | /** |
||
140 | * Check whether base certificate ID is present. |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | 2 | public function hasBaseCertificateID(): bool |
|
148 | |||
149 | /** |
||
150 | * Get base certificate ID. |
||
151 | * |
||
152 | * @throws \LogicException |
||
153 | * @return IssuerSerial |
||
154 | */ |
||
155 | 2 | public function baseCertificateID(): IssuerSerial |
|
162 | |||
163 | /** |
||
164 | * Check whether entity name is present. |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | 2 | public function hasEntityName(): bool |
|
172 | |||
173 | /** |
||
174 | * Get entity name. |
||
175 | * |
||
176 | * @throws \LogicException |
||
177 | * @return GeneralNames |
||
178 | */ |
||
179 | 2 | public function entityName(): GeneralNames |
|
186 | |||
187 | /** |
||
188 | * Check whether object digest info is present. |
||
189 | * |
||
190 | * @return bool |
||
191 | */ |
||
192 | 2 | public function hasObjectDigestInfo(): bool |
|
196 | |||
197 | /** |
||
198 | * Get object digest info. |
||
199 | * |
||
200 | * @throws \LogicException |
||
201 | * @return ObjectDigestInfo |
||
202 | */ |
||
203 | 2 | public function objectDigestInfo(): ObjectDigestInfo |
|
210 | |||
211 | /** |
||
212 | * Generate ASN.1 structure. |
||
213 | * |
||
214 | * @return Sequence |
||
215 | */ |
||
216 | 20 | public function toASN1(): Sequence |
|
233 | |||
234 | /** |
||
235 | * Check whether Holder identifies given certificate. |
||
236 | * |
||
237 | * @param Certificate $cert |
||
238 | * @return boolean |
||
239 | */ |
||
240 | 19 | public function identifiesPKC(Certificate $cert): bool |
|
257 | |||
258 | /** |
||
259 | * Check whether entityName matches the given certificate. |
||
260 | * |
||
261 | * @param Certificate $cert |
||
262 | * @return boolean |
||
263 | */ |
||
264 | 4 | private function _checkEntityName(Certificate $cert): bool |
|
281 | |||
282 | /** |
||
283 | * Check whether any of the subject alternative names match entityName. |
||
284 | * |
||
285 | * @param GeneralNames $san |
||
286 | * @return boolean |
||
287 | */ |
||
288 | 2 | private function _checkEntityAlternativeNames(GeneralNames $san): bool |
|
299 | } |
||
300 |