1 | <?php |
||
19 | class Extensions implements \Countable, \IteratorAggregate |
||
20 | { |
||
21 | /** |
||
22 | * Extensions. |
||
23 | * |
||
24 | * @var Extension\Extension[] $_extensions |
||
25 | */ |
||
26 | protected $_extensions; |
||
27 | |||
28 | /** |
||
29 | * Constructor. |
||
30 | * |
||
31 | * @param Ext\Extension ...$extensions Extension objects |
||
32 | */ |
||
33 | 65 | public function __construct(Ext\Extension ...$extensions) |
|
40 | |||
41 | /** |
||
42 | * Initialize from ASN.1. |
||
43 | * |
||
44 | * @param Sequence $seq |
||
45 | * @return self |
||
46 | */ |
||
47 | 26 | public static function fromASN1(Sequence $seq): Extensions |
|
55 | |||
56 | /** |
||
57 | * Generate ASN.1 structure. |
||
58 | * |
||
59 | * @return Sequence |
||
60 | */ |
||
61 | 66 | public function toASN1(): Sequence |
|
70 | |||
71 | /** |
||
72 | * Get self with extensions added. |
||
73 | * |
||
74 | * @param Ext\Extension ...$exts One or more extensions to add |
||
75 | * @return self |
||
76 | */ |
||
77 | 5 | public function withExtensions(Ext\Extension ...$exts): Extensions |
|
85 | |||
86 | /** |
||
87 | * Check whether extension is present. |
||
88 | * |
||
89 | * @param string $oid Extensions OID |
||
90 | * @return bool |
||
91 | */ |
||
92 | 108 | public function has(string $oid): bool |
|
96 | |||
97 | /** |
||
98 | * Get extension by OID. |
||
99 | * |
||
100 | * @param string $oid |
||
101 | * @throws \LogicException If extension is not present |
||
102 | * @return Extension\Extension |
||
103 | */ |
||
104 | 86 | public function get(string $oid): Ext\Extension |
|
111 | |||
112 | /** |
||
113 | * Check whether 'Authority Key Identifier' extension is present. |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | 10 | public function hasAuthorityKeyIdentifier(): bool |
|
121 | |||
122 | /** |
||
123 | * Get 'Authority Key Identifier' extension. |
||
124 | * |
||
125 | * @throws \LogicException If extension is not present |
||
126 | * @return \X509\Certificate\Extension\AuthorityKeyIdentifierExtension |
||
127 | */ |
||
128 | 11 | public function authorityKeyIdentifier(): Ext\AuthorityKeyIdentifierExtension |
|
134 | |||
135 | /** |
||
136 | * Check whether 'Subject Key Identifier' extension is present. |
||
137 | * |
||
138 | * @return bool |
||
139 | */ |
||
140 | 14 | public function hasSubjectKeyIdentifier(): bool |
|
144 | |||
145 | /** |
||
146 | * Get 'Subject Key Identifier' extension. |
||
147 | * |
||
148 | * @throws \LogicException If extension is not present |
||
149 | * @return \X509\Certificate\Extension\SubjectKeyIdentifierExtension |
||
150 | */ |
||
151 | 13 | public function subjectKeyIdentifier(): Ext\SubjectKeyIdentifierExtension |
|
158 | |||
159 | /** |
||
160 | * Check whether 'Key Usage' extension is present. |
||
161 | * |
||
162 | * @return bool |
||
163 | */ |
||
164 | 41 | public function hasKeyUsage(): bool |
|
168 | |||
169 | /** |
||
170 | * Get 'Key Usage' extension. |
||
171 | * |
||
172 | * @throws \LogicException If extension is not present |
||
173 | * @return \X509\Certificate\Extension\KeyUsageExtension |
||
174 | */ |
||
175 | 21 | public function keyUsage(): Ext\KeyUsageExtension |
|
181 | |||
182 | /** |
||
183 | * Check whether 'Certificate Policies' extension is present. |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | 44 | public function hasCertificatePolicies(): bool |
|
191 | |||
192 | /** |
||
193 | * Get 'Certificate Policies' extension. |
||
194 | * |
||
195 | * @throws \LogicException If extension is not present |
||
196 | * @return \X509\Certificate\Extension\CertificatePoliciesExtension |
||
197 | */ |
||
198 | 16 | public function certificatePolicies(): Ext\CertificatePoliciesExtension |
|
204 | |||
205 | /** |
||
206 | * Check whether 'Policy Mappings' extension is present. |
||
207 | * |
||
208 | * @return bool |
||
209 | */ |
||
210 | 44 | public function hasPolicyMappings(): bool |
|
214 | |||
215 | /** |
||
216 | * Get 'Policy Mappings' extension. |
||
217 | * |
||
218 | * @throws \LogicException If extension is not present |
||
219 | * @return \X509\Certificate\Extension\PolicyMappingsExtension |
||
220 | */ |
||
221 | 5 | public function policyMappings(): Ext\PolicyMappingsExtension |
|
227 | |||
228 | /** |
||
229 | * Check whether 'Subject Alternative Name' extension is present. |
||
230 | * |
||
231 | * @return bool |
||
232 | */ |
||
233 | 3 | public function hasSubjectAlternativeName(): bool |
|
237 | |||
238 | /** |
||
239 | * Get 'Subject Alternative Name' extension. |
||
240 | * |
||
241 | * @throws \LogicException If extension is not present |
||
242 | * @return \X509\Certificate\Extension\SubjectAlternativeNameExtension |
||
243 | */ |
||
244 | 4 | public function subjectAlternativeName(): Ext\SubjectAlternativeNameExtension |
|
250 | |||
251 | /** |
||
252 | * Check whether 'Issuer Alternative Name' extension is present. |
||
253 | * |
||
254 | * @return bool |
||
255 | */ |
||
256 | 1 | public function hasIssuerAlternativeName(): bool |
|
260 | |||
261 | /** |
||
262 | * Get 'Issuer Alternative Name' extension. |
||
263 | * |
||
264 | * @return \X509\Certificate\Extension\IssuerAlternativeNameExtension |
||
265 | */ |
||
266 | 1 | public function issuerAlternativeName(): Ext\IssuerAlternativeNameExtension |
|
272 | |||
273 | /** |
||
274 | * Check whether 'Basic Constraints' extension is present. |
||
275 | * |
||
276 | * @return bool |
||
277 | */ |
||
278 | 43 | public function hasBasicConstraints(): bool |
|
282 | |||
283 | /** |
||
284 | * Get 'Basic Constraints' extension. |
||
285 | * |
||
286 | * @throws \LogicException If extension is not present |
||
287 | * @return \X509\Certificate\Extension\BasicConstraintsExtension |
||
288 | */ |
||
289 | 40 | public function basicConstraints(): Ext\BasicConstraintsExtension |
|
295 | |||
296 | /** |
||
297 | * Check whether 'Name Constraints' extension is present. |
||
298 | * |
||
299 | * @return bool |
||
300 | */ |
||
301 | 43 | public function hasNameConstraints(): bool |
|
305 | |||
306 | /** |
||
307 | * Get 'Name Constraints' extension. |
||
308 | * |
||
309 | * @throws \LogicException If extension is not present |
||
310 | * @return \X509\Certificate\Extension\NameConstraintsExtension |
||
311 | */ |
||
312 | 1 | public function nameConstraints(): Ext\NameConstraintsExtension |
|
318 | |||
319 | /** |
||
320 | * Check whether 'Policy Constraints' extension is present. |
||
321 | * |
||
322 | * @return bool |
||
323 | */ |
||
324 | 43 | public function hasPolicyConstraints(): bool |
|
328 | |||
329 | /** |
||
330 | * Get 'Policy Constraints' extension. |
||
331 | * |
||
332 | * @throws \LogicException If extension is not present |
||
333 | * @return \X509\Certificate\Extension\PolicyConstraintsExtension |
||
334 | */ |
||
335 | 16 | public function policyConstraints(): Ext\PolicyConstraintsExtension |
|
341 | |||
342 | /** |
||
343 | * Check whether 'Extended Key Usage' extension is present. |
||
344 | * |
||
345 | * @return bool |
||
346 | */ |
||
347 | 1 | public function hasExtendedKeyUsage(): bool |
|
351 | |||
352 | /** |
||
353 | * Get 'Extended Key Usage' extension. |
||
354 | * |
||
355 | * @throws \LogicException If extension is not present |
||
356 | * @return \X509\Certificate\Extension\ExtendedKeyUsageExtension |
||
357 | */ |
||
358 | 1 | public function extendedKeyUsage(): Ext\ExtendedKeyUsageExtension |
|
364 | |||
365 | /** |
||
366 | * Check whether 'CRL Distribution Points' extension is present. |
||
367 | * |
||
368 | * @return bool |
||
369 | */ |
||
370 | 1 | public function hasCRLDistributionPoints(): bool |
|
374 | |||
375 | /** |
||
376 | * Get 'CRL Distribution Points' extension. |
||
377 | * |
||
378 | * @throws \LogicException If extension is not present |
||
379 | * @return \X509\Certificate\Extension\CRLDistributionPointsExtension |
||
380 | */ |
||
381 | 1 | public function crlDistributionPoints(): Ext\CRLDistributionPointsExtension |
|
387 | |||
388 | /** |
||
389 | * Check whether 'Inhibit anyPolicy' extension is present. |
||
390 | * |
||
391 | * @return bool |
||
392 | */ |
||
393 | 43 | public function hasInhibitAnyPolicy(): bool |
|
397 | |||
398 | /** |
||
399 | * Get 'Inhibit anyPolicy' extension. |
||
400 | * |
||
401 | * @throws \LogicException If extension is not present |
||
402 | * @return \X509\Certificate\Extension\InhibitAnyPolicyExtension |
||
403 | */ |
||
404 | 3 | public function inhibitAnyPolicy(): Ext\InhibitAnyPolicyExtension |
|
410 | |||
411 | /** |
||
412 | * |
||
413 | * @see \Countable::count() |
||
414 | * @return int |
||
415 | */ |
||
416 | 77 | public function count(): int |
|
420 | |||
421 | /** |
||
422 | * Get iterator for extensions. |
||
423 | * |
||
424 | * @see \IteratorAggregate::getIterator() |
||
425 | * @return \Traversable |
||
426 | */ |
||
427 | 1 | public function getIterator(): \Traversable |
|
431 | } |
||
432 |