1 | <?php |
||
23 | class AttributeCertificateInfo |
||
24 | { |
||
25 | const VERSION_2 = 1; |
||
26 | |||
27 | /** |
||
28 | * AC version. |
||
29 | * |
||
30 | * @var int $_version |
||
31 | */ |
||
32 | protected $_version; |
||
33 | |||
34 | /** |
||
35 | * AC holder. |
||
36 | * |
||
37 | * @var Holder $_holder |
||
38 | */ |
||
39 | protected $_holder; |
||
40 | |||
41 | /** |
||
42 | * AC issuer. |
||
43 | * |
||
44 | * @var AttCertIssuer $_issuer |
||
45 | */ |
||
46 | protected $_issuer; |
||
47 | |||
48 | /** |
||
49 | * Signature algorithm identifier. |
||
50 | * |
||
51 | * @var SignatureAlgorithmIdentifier $_signature |
||
52 | */ |
||
53 | protected $_signature; |
||
54 | |||
55 | /** |
||
56 | * AC serial number. |
||
57 | * |
||
58 | * @var string $_serialNumber |
||
59 | */ |
||
60 | protected $_serialNumber; |
||
61 | |||
62 | /** |
||
63 | * Validity period. |
||
64 | * |
||
65 | * @var AttCertValidityPeriod $_attrCertValidityPeriod |
||
66 | */ |
||
67 | protected $_attrCertValidityPeriod; |
||
68 | |||
69 | /** |
||
70 | * Attributes. |
||
71 | * |
||
72 | * @var Attributes $_attributes |
||
73 | */ |
||
74 | protected $_attributes; |
||
75 | |||
76 | /** |
||
77 | * Issuer unique identifier. |
||
78 | * |
||
79 | * @var UniqueIdentifier|null $_issuerUniqueID |
||
80 | */ |
||
81 | protected $_issuerUniqueID; |
||
82 | |||
83 | /** |
||
84 | * Extensions. |
||
85 | * |
||
86 | * @var Extensions $_extensions |
||
87 | */ |
||
88 | protected $_extensions; |
||
89 | |||
90 | /** |
||
91 | * Constructor. |
||
92 | * |
||
93 | * @param Holder $holder AC holder |
||
94 | * @param AttCertIssuer $issuer AC issuer |
||
95 | * @param AttCertValidityPeriod $validity Validity |
||
96 | * @param Attributes $attribs Attributes |
||
97 | */ |
||
98 | 8 | public function __construct(Holder $holder, AttCertIssuer $issuer, |
|
108 | |||
109 | /** |
||
110 | * Initialize from ASN.1. |
||
111 | * |
||
112 | * @param Sequence $seq |
||
113 | * @throws \UnexpectedValueException |
||
114 | * @return self |
||
115 | */ |
||
116 | 7 | public static function fromASN1(Sequence $seq): self |
|
150 | |||
151 | /** |
||
152 | * Get self with holder. |
||
153 | * |
||
154 | * @param Holder $holder |
||
155 | * @return self |
||
156 | */ |
||
157 | 1 | public function withHolder(Holder $holder): self |
|
163 | |||
164 | /** |
||
165 | * Get self with issuer. |
||
166 | * |
||
167 | * @param AttCertIssuer $issuer |
||
168 | * @return self |
||
169 | */ |
||
170 | 1 | public function withIssuer(AttCertIssuer $issuer): self |
|
176 | |||
177 | /** |
||
178 | * Get self with signature algorithm identifier. |
||
179 | * |
||
180 | * @param SignatureAlgorithmIdentifier $algo |
||
181 | * @return self |
||
182 | */ |
||
183 | 3 | public function withSignature(SignatureAlgorithmIdentifier $algo): self |
|
189 | |||
190 | /** |
||
191 | * Get self with serial number. |
||
192 | * |
||
193 | * @param int|string $serial |
||
194 | * @return self |
||
195 | */ |
||
196 | 4 | public function withSerialNumber($serial): self |
|
202 | |||
203 | /** |
||
204 | * Get self with random positive serial number. |
||
205 | * |
||
206 | * @param int $size Number of random bytes |
||
207 | * @return self |
||
208 | */ |
||
209 | 1 | public function withRandomSerialNumber(int $size = 16): self |
|
219 | |||
220 | /** |
||
221 | * Get self with validity period. |
||
222 | * |
||
223 | * @param AttCertValidityPeriod $validity |
||
224 | * @return self |
||
225 | */ |
||
226 | 1 | public function withValidity(AttCertValidityPeriod $validity): self |
|
232 | |||
233 | /** |
||
234 | * Get self with attributes. |
||
235 | * |
||
236 | * @param Attributes $attribs |
||
237 | * @return self |
||
238 | */ |
||
239 | 1 | public function withAttributes(Attributes $attribs): self |
|
245 | |||
246 | /** |
||
247 | * Get self with issuer unique identifier. |
||
248 | * |
||
249 | * @param UniqueIdentifier $uid |
||
250 | * @return self |
||
251 | */ |
||
252 | 2 | public function withIssuerUniqueID(UniqueIdentifier $uid): self |
|
258 | |||
259 | /** |
||
260 | * Get self with extensions. |
||
261 | * |
||
262 | * @param Extensions $extensions |
||
263 | * @return self |
||
264 | */ |
||
265 | 2 | public function withExtensions(Extensions $extensions): self |
|
271 | |||
272 | /** |
||
273 | * Get self with extensions added. |
||
274 | * |
||
275 | * @param Extension ...$exts One or more Extension objects |
||
276 | * @return self |
||
277 | */ |
||
278 | 1 | public function withAdditionalExtensions(Extension ...$exts): self |
|
284 | |||
285 | /** |
||
286 | * Get version. |
||
287 | * |
||
288 | * @return int |
||
289 | */ |
||
290 | 1 | public function version(): int |
|
294 | |||
295 | /** |
||
296 | * Get AC holder. |
||
297 | * |
||
298 | * @return Holder |
||
299 | */ |
||
300 | 14 | public function holder(): Holder |
|
304 | |||
305 | /** |
||
306 | * Get AC issuer. |
||
307 | * |
||
308 | * @return AttCertIssuer |
||
309 | */ |
||
310 | 12 | public function issuer(): AttCertIssuer |
|
314 | |||
315 | /** |
||
316 | * Check whether signature is set. |
||
317 | * |
||
318 | * @return bool |
||
319 | */ |
||
320 | 21 | public function hasSignature(): bool |
|
324 | |||
325 | /** |
||
326 | * Get signature algorithm identifier. |
||
327 | * |
||
328 | * @return SignatureAlgorithmIdentifier |
||
329 | */ |
||
330 | 21 | public function signature(): SignatureAlgorithmIdentifier |
|
337 | |||
338 | /** |
||
339 | * Check whether serial number is present. |
||
340 | * |
||
341 | * @return bool |
||
342 | */ |
||
343 | 22 | public function hasSerialNumber(): bool |
|
347 | |||
348 | /** |
||
349 | * Get AC serial number. |
||
350 | * |
||
351 | * @return string |
||
352 | */ |
||
353 | 22 | public function serialNumber(): string |
|
360 | |||
361 | /** |
||
362 | * Get validity period. |
||
363 | * |
||
364 | * @return AttCertValidityPeriod |
||
365 | */ |
||
366 | 6 | public function validityPeriod(): AttCertValidityPeriod |
|
370 | |||
371 | /** |
||
372 | * Get attributes. |
||
373 | * |
||
374 | * @return Attributes |
||
375 | */ |
||
376 | 1 | public function attributes(): Attributes |
|
380 | |||
381 | /** |
||
382 | * Check whether issuer unique identifier is present. |
||
383 | * |
||
384 | * @return bool |
||
385 | */ |
||
386 | 2 | public function hasIssuerUniqueID(): bool |
|
390 | |||
391 | /** |
||
392 | * Get issuer unique identifier. |
||
393 | * |
||
394 | * @return UniqueIdentifier |
||
395 | */ |
||
396 | 2 | public function issuerUniqueID(): UniqueIdentifier |
|
403 | |||
404 | /** |
||
405 | * Get extensions. |
||
406 | * |
||
407 | * @return Extensions |
||
408 | */ |
||
409 | 4 | public function extensions(): Extensions |
|
413 | |||
414 | /** |
||
415 | * Get ASN.1 structure. |
||
416 | * |
||
417 | * @return Sequence |
||
418 | */ |
||
419 | 19 | public function toASN1(): Sequence |
|
434 | |||
435 | /** |
||
436 | * Create signed attribute certificate. |
||
437 | * |
||
438 | * @param SignatureAlgorithmIdentifier $algo Signature algorithm |
||
439 | * @param PrivateKeyInfo $privkey_info Private key |
||
440 | * @param Crypto|null $crypto Crypto engine, use default if not set |
||
441 | * @return AttributeCertificate |
||
442 | */ |
||
443 | 1 | public function sign(SignatureAlgorithmIdentifier $algo, |
|
456 | } |
||
457 |