@@ -16,83 +16,83 @@ |
||
16 | 16 | */ |
17 | 17 | class NoticeReference |
18 | 18 | { |
19 | - /** |
|
20 | - * Organization. |
|
21 | - * |
|
22 | - * @var DisplayText $_organization |
|
23 | - */ |
|
24 | - protected $_organization; |
|
19 | + /** |
|
20 | + * Organization. |
|
21 | + * |
|
22 | + * @var DisplayText $_organization |
|
23 | + */ |
|
24 | + protected $_organization; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Notification reference numbers. |
|
28 | - * |
|
29 | - * @var int[] $_numbers |
|
30 | - */ |
|
31 | - protected $_numbers; |
|
26 | + /** |
|
27 | + * Notification reference numbers. |
|
28 | + * |
|
29 | + * @var int[] $_numbers |
|
30 | + */ |
|
31 | + protected $_numbers; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor. |
|
35 | - * |
|
36 | - * @param DisplayText $organization |
|
37 | - * @param int[] $numbers |
|
38 | - */ |
|
39 | - public function __construct(DisplayText $organization, ...$numbers) |
|
40 | - { |
|
41 | - $this->_organization = $organization; |
|
42 | - $this->_numbers = $numbers; |
|
43 | - } |
|
33 | + /** |
|
34 | + * Constructor. |
|
35 | + * |
|
36 | + * @param DisplayText $organization |
|
37 | + * @param int[] $numbers |
|
38 | + */ |
|
39 | + public function __construct(DisplayText $organization, ...$numbers) |
|
40 | + { |
|
41 | + $this->_organization = $organization; |
|
42 | + $this->_numbers = $numbers; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Initialize from ASN.1. |
|
47 | - * |
|
48 | - * @param Sequence $seq |
|
49 | - * @return self |
|
50 | - */ |
|
51 | - public static function fromASN1(Sequence $seq) |
|
52 | - { |
|
53 | - $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
54 | - $numbers = array_map( |
|
55 | - function (UnspecifiedType $el) { |
|
56 | - return $el->asInteger()->number(); |
|
57 | - }, |
|
58 | - $seq->at(1) |
|
59 | - ->asSequence() |
|
60 | - ->elements()); |
|
61 | - return new self($org, ...$numbers); |
|
62 | - } |
|
45 | + /** |
|
46 | + * Initialize from ASN.1. |
|
47 | + * |
|
48 | + * @param Sequence $seq |
|
49 | + * @return self |
|
50 | + */ |
|
51 | + public static function fromASN1(Sequence $seq) |
|
52 | + { |
|
53 | + $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
54 | + $numbers = array_map( |
|
55 | + function (UnspecifiedType $el) { |
|
56 | + return $el->asInteger()->number(); |
|
57 | + }, |
|
58 | + $seq->at(1) |
|
59 | + ->asSequence() |
|
60 | + ->elements()); |
|
61 | + return new self($org, ...$numbers); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Get reference organization. |
|
66 | - * |
|
67 | - * @return DisplayText |
|
68 | - */ |
|
69 | - public function organization(): DisplayText |
|
70 | - { |
|
71 | - return $this->_organization; |
|
72 | - } |
|
64 | + /** |
|
65 | + * Get reference organization. |
|
66 | + * |
|
67 | + * @return DisplayText |
|
68 | + */ |
|
69 | + public function organization(): DisplayText |
|
70 | + { |
|
71 | + return $this->_organization; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Get reference numbers. |
|
76 | - * |
|
77 | - * @return int[] |
|
78 | - */ |
|
79 | - public function numbers(): array |
|
80 | - { |
|
81 | - return $this->_numbers; |
|
82 | - } |
|
74 | + /** |
|
75 | + * Get reference numbers. |
|
76 | + * |
|
77 | + * @return int[] |
|
78 | + */ |
|
79 | + public function numbers(): array |
|
80 | + { |
|
81 | + return $this->_numbers; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Generate ASN.1 structure. |
|
86 | - * |
|
87 | - * @return Sequence |
|
88 | - */ |
|
89 | - public function toASN1(): Sequence |
|
90 | - { |
|
91 | - $org = $this->_organization->toASN1(); |
|
92 | - $nums = array_map( |
|
93 | - function ($number) { |
|
94 | - return new Integer($number); |
|
95 | - }, $this->_numbers); |
|
96 | - return new Sequence($org, new Sequence(...$nums)); |
|
97 | - } |
|
84 | + /** |
|
85 | + * Generate ASN.1 structure. |
|
86 | + * |
|
87 | + * @return Sequence |
|
88 | + */ |
|
89 | + public function toASN1(): Sequence |
|
90 | + { |
|
91 | + $org = $this->_organization->toASN1(); |
|
92 | + $nums = array_map( |
|
93 | + function ($number) { |
|
94 | + return new Integer($number); |
|
95 | + }, $this->_numbers); |
|
96 | + return new Sequence($org, new Sequence(...$nums)); |
|
97 | + } |
|
98 | 98 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension\CertificatePolicy; |
6 | 6 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | $org = DisplayText::fromASN1($seq->at(0)->asString()); |
54 | 54 | $numbers = array_map( |
55 | - function (UnspecifiedType $el) { |
|
55 | + function(UnspecifiedType $el) { |
|
56 | 56 | return $el->asInteger()->number(); |
57 | 57 | }, |
58 | 58 | $seq->at(1) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | $org = $this->_organization->toASN1(); |
92 | 92 | $nums = array_map( |
93 | - function ($number) { |
|
93 | + function($number) { |
|
94 | 94 | return new Integer($number); |
95 | 95 | }, $this->_numbers); |
96 | 96 | return new Sequence($org, new Sequence(...$nums)); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension\CertificatePolicy; |
6 | 6 |
@@ -15,51 +15,51 @@ |
||
15 | 15 | */ |
16 | 16 | class CPSQualifier extends PolicyQualifierInfo |
17 | 17 | { |
18 | - /** |
|
19 | - * URI. |
|
20 | - * |
|
21 | - * @var string $_uri |
|
22 | - */ |
|
23 | - protected $_uri; |
|
18 | + /** |
|
19 | + * URI. |
|
20 | + * |
|
21 | + * @var string $_uri |
|
22 | + */ |
|
23 | + protected $_uri; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Constructor. |
|
27 | - * |
|
28 | - * @param string $uri |
|
29 | - */ |
|
30 | - public function __construct(string $uri) |
|
31 | - { |
|
32 | - $this->_oid = self::OID_CPS; |
|
33 | - $this->_uri = $uri; |
|
34 | - } |
|
25 | + /** |
|
26 | + * Constructor. |
|
27 | + * |
|
28 | + * @param string $uri |
|
29 | + */ |
|
30 | + public function __construct(string $uri) |
|
31 | + { |
|
32 | + $this->_oid = self::OID_CPS; |
|
33 | + $this->_uri = $uri; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * |
|
38 | - * @param UnspecifiedType $el |
|
39 | - * @return self |
|
40 | - */ |
|
41 | - public static function fromQualifierASN1(UnspecifiedType $el) |
|
42 | - { |
|
43 | - return new self($el->asString()->string()); |
|
44 | - } |
|
36 | + /** |
|
37 | + * |
|
38 | + * @param UnspecifiedType $el |
|
39 | + * @return self |
|
40 | + */ |
|
41 | + public static function fromQualifierASN1(UnspecifiedType $el) |
|
42 | + { |
|
43 | + return new self($el->asString()->string()); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get URI. |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function uri(): string |
|
52 | - { |
|
53 | - return $this->_uri; |
|
54 | - } |
|
46 | + /** |
|
47 | + * Get URI. |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function uri(): string |
|
52 | + { |
|
53 | + return $this->_uri; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * |
|
58 | - * {@inheritdoc} |
|
59 | - * @return IA5String |
|
60 | - */ |
|
61 | - protected function _qualifierASN1(): IA5String |
|
62 | - { |
|
63 | - return new IA5String($this->_uri); |
|
64 | - } |
|
56 | + /** |
|
57 | + * |
|
58 | + * {@inheritdoc} |
|
59 | + * @return IA5String |
|
60 | + */ |
|
61 | + protected function _qualifierASN1(): IA5String |
|
62 | + { |
|
63 | + return new IA5String($this->_uri); |
|
64 | + } |
|
65 | 65 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension\CertificatePolicy; |
6 | 6 |
@@ -16,207 +16,207 @@ |
||
16 | 16 | */ |
17 | 17 | class PolicyInformation implements \Countable, \IteratorAggregate |
18 | 18 | { |
19 | - /** |
|
20 | - * Wildcard policy. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - const OID_ANY_POLICY = "2.5.29.32.0"; |
|
25 | - |
|
26 | - /** |
|
27 | - * Policy identifier. |
|
28 | - * |
|
29 | - * @var string $_oid |
|
30 | - */ |
|
31 | - protected $_oid; |
|
32 | - |
|
33 | - /** |
|
34 | - * Policy qualifiers. |
|
35 | - * |
|
36 | - * @var PolicyQualifierInfo[] $_qualifiers |
|
37 | - */ |
|
38 | - protected $_qualifiers; |
|
39 | - |
|
40 | - /** |
|
41 | - * Constructor. |
|
42 | - * |
|
43 | - * @param string $oid |
|
44 | - * @param PolicyQualifierInfo[] $qualifiers |
|
45 | - */ |
|
46 | - public function __construct(string $oid, PolicyQualifierInfo ...$qualifiers) |
|
47 | - { |
|
48 | - $this->_oid = $oid; |
|
49 | - $this->_qualifiers = array(); |
|
50 | - foreach ($qualifiers as $qual) { |
|
51 | - $this->_qualifiers[$qual->oid()] = $qual; |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Initialize from ASN.1. |
|
57 | - * |
|
58 | - * @param Sequence $seq |
|
59 | - * @return self |
|
60 | - */ |
|
61 | - public static function fromASN1(Sequence $seq) |
|
62 | - { |
|
63 | - $oid = $seq->at(0) |
|
64 | - ->asObjectIdentifier() |
|
65 | - ->oid(); |
|
66 | - $qualifiers = array(); |
|
67 | - if (count($seq) > 1) { |
|
68 | - $qualifiers = array_map( |
|
69 | - function (UnspecifiedType $el) { |
|
70 | - return PolicyQualifierInfo::fromASN1($el->asSequence()); |
|
71 | - }, |
|
72 | - $seq->at(1) |
|
73 | - ->asSequence() |
|
74 | - ->elements()); |
|
75 | - } |
|
76 | - return new self($oid, ...$qualifiers); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Get policy identifier. |
|
81 | - * |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function oid(): string |
|
85 | - { |
|
86 | - return $this->_oid; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Check whether this policy is anyPolicy. |
|
91 | - * |
|
92 | - * @return bool |
|
93 | - */ |
|
94 | - public function isAnyPolicy(): bool |
|
95 | - { |
|
96 | - return self::OID_ANY_POLICY === $this->_oid; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Get policy qualifiers. |
|
101 | - * |
|
102 | - * @return PolicyQualifierInfo[] |
|
103 | - */ |
|
104 | - public function qualifiers(): array |
|
105 | - { |
|
106 | - return array_values($this->_qualifiers); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Check whether qualifier is present. |
|
111 | - * |
|
112 | - * @param string $oid |
|
113 | - * @return boolean |
|
114 | - */ |
|
115 | - public function has(string $oid): bool |
|
116 | - { |
|
117 | - return isset($this->_qualifiers[$oid]); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Get qualifier by OID. |
|
122 | - * |
|
123 | - * @param string $oid |
|
124 | - * @throws \OutOfBoundsException |
|
125 | - * @return PolicyQualifierInfo |
|
126 | - */ |
|
127 | - public function get($oid): PolicyQualifierInfo |
|
128 | - { |
|
129 | - if (!$this->has($oid)) { |
|
130 | - throw new \LogicException("No $oid qualifier."); |
|
131 | - } |
|
132 | - return $this->_qualifiers[$oid]; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Check whether CPS qualifier is present. |
|
137 | - * |
|
138 | - * @return bool |
|
139 | - */ |
|
140 | - public function hasCPSQualifier(): bool |
|
141 | - { |
|
142 | - return $this->has(PolicyQualifierInfo::OID_CPS); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Get CPS qualifier. |
|
147 | - * |
|
148 | - * @throws \LogicException |
|
149 | - * @return CPSQualifier |
|
150 | - */ |
|
151 | - public function CPSQualifier(): CPSQualifier |
|
152 | - { |
|
153 | - if (!$this->hasCPSQualifier()) { |
|
154 | - throw new \LogicException("CPS qualifier not set."); |
|
155 | - } |
|
156 | - return $this->get(PolicyQualifierInfo::OID_CPS); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Check whether user notice qualifier is present. |
|
161 | - * |
|
162 | - * @return bool |
|
163 | - */ |
|
164 | - public function hasUserNoticeQualifier(): bool |
|
165 | - { |
|
166 | - return $this->has(PolicyQualifierInfo::OID_UNOTICE); |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Get user notice qualifier. |
|
171 | - * |
|
172 | - * @throws \LogicException |
|
173 | - * @return UserNoticeQualifier |
|
174 | - */ |
|
175 | - public function userNoticeQualifier(): UserNoticeQualifier |
|
176 | - { |
|
177 | - if (!$this->hasUserNoticeQualifier()) { |
|
178 | - throw new \LogicException("User notice qualifier not set."); |
|
179 | - } |
|
180 | - return $this->get(PolicyQualifierInfo::OID_UNOTICE); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Get ASN.1 structure. |
|
185 | - * |
|
186 | - * @return Sequence |
|
187 | - */ |
|
188 | - public function toASN1(): Sequence |
|
189 | - { |
|
190 | - $elements = array(new ObjectIdentifier($this->_oid)); |
|
191 | - if (count($this->_qualifiers)) { |
|
192 | - $qualifiers = array_map( |
|
193 | - function (PolicyQualifierInfo $pqi) { |
|
194 | - return $pqi->toASN1(); |
|
195 | - }, array_values($this->_qualifiers)); |
|
196 | - $elements[] = new Sequence(...$qualifiers); |
|
197 | - } |
|
198 | - return new Sequence(...$elements); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Get number of qualifiers. |
|
203 | - * |
|
204 | - * @see \Countable::count() |
|
205 | - * @return int |
|
206 | - */ |
|
207 | - public function count(): int |
|
208 | - { |
|
209 | - return count($this->_qualifiers); |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Get iterator for qualifiers. |
|
214 | - * |
|
215 | - * @see \IteratorAggregate::getIterator() |
|
216 | - * @return \ArrayIterator |
|
217 | - */ |
|
218 | - public function getIterator(): \ArrayIterator |
|
219 | - { |
|
220 | - return new \ArrayIterator($this->_qualifiers); |
|
221 | - } |
|
19 | + /** |
|
20 | + * Wildcard policy. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + const OID_ANY_POLICY = "2.5.29.32.0"; |
|
25 | + |
|
26 | + /** |
|
27 | + * Policy identifier. |
|
28 | + * |
|
29 | + * @var string $_oid |
|
30 | + */ |
|
31 | + protected $_oid; |
|
32 | + |
|
33 | + /** |
|
34 | + * Policy qualifiers. |
|
35 | + * |
|
36 | + * @var PolicyQualifierInfo[] $_qualifiers |
|
37 | + */ |
|
38 | + protected $_qualifiers; |
|
39 | + |
|
40 | + /** |
|
41 | + * Constructor. |
|
42 | + * |
|
43 | + * @param string $oid |
|
44 | + * @param PolicyQualifierInfo[] $qualifiers |
|
45 | + */ |
|
46 | + public function __construct(string $oid, PolicyQualifierInfo ...$qualifiers) |
|
47 | + { |
|
48 | + $this->_oid = $oid; |
|
49 | + $this->_qualifiers = array(); |
|
50 | + foreach ($qualifiers as $qual) { |
|
51 | + $this->_qualifiers[$qual->oid()] = $qual; |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Initialize from ASN.1. |
|
57 | + * |
|
58 | + * @param Sequence $seq |
|
59 | + * @return self |
|
60 | + */ |
|
61 | + public static function fromASN1(Sequence $seq) |
|
62 | + { |
|
63 | + $oid = $seq->at(0) |
|
64 | + ->asObjectIdentifier() |
|
65 | + ->oid(); |
|
66 | + $qualifiers = array(); |
|
67 | + if (count($seq) > 1) { |
|
68 | + $qualifiers = array_map( |
|
69 | + function (UnspecifiedType $el) { |
|
70 | + return PolicyQualifierInfo::fromASN1($el->asSequence()); |
|
71 | + }, |
|
72 | + $seq->at(1) |
|
73 | + ->asSequence() |
|
74 | + ->elements()); |
|
75 | + } |
|
76 | + return new self($oid, ...$qualifiers); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Get policy identifier. |
|
81 | + * |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function oid(): string |
|
85 | + { |
|
86 | + return $this->_oid; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Check whether this policy is anyPolicy. |
|
91 | + * |
|
92 | + * @return bool |
|
93 | + */ |
|
94 | + public function isAnyPolicy(): bool |
|
95 | + { |
|
96 | + return self::OID_ANY_POLICY === $this->_oid; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Get policy qualifiers. |
|
101 | + * |
|
102 | + * @return PolicyQualifierInfo[] |
|
103 | + */ |
|
104 | + public function qualifiers(): array |
|
105 | + { |
|
106 | + return array_values($this->_qualifiers); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Check whether qualifier is present. |
|
111 | + * |
|
112 | + * @param string $oid |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | + public function has(string $oid): bool |
|
116 | + { |
|
117 | + return isset($this->_qualifiers[$oid]); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Get qualifier by OID. |
|
122 | + * |
|
123 | + * @param string $oid |
|
124 | + * @throws \OutOfBoundsException |
|
125 | + * @return PolicyQualifierInfo |
|
126 | + */ |
|
127 | + public function get($oid): PolicyQualifierInfo |
|
128 | + { |
|
129 | + if (!$this->has($oid)) { |
|
130 | + throw new \LogicException("No $oid qualifier."); |
|
131 | + } |
|
132 | + return $this->_qualifiers[$oid]; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Check whether CPS qualifier is present. |
|
137 | + * |
|
138 | + * @return bool |
|
139 | + */ |
|
140 | + public function hasCPSQualifier(): bool |
|
141 | + { |
|
142 | + return $this->has(PolicyQualifierInfo::OID_CPS); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Get CPS qualifier. |
|
147 | + * |
|
148 | + * @throws \LogicException |
|
149 | + * @return CPSQualifier |
|
150 | + */ |
|
151 | + public function CPSQualifier(): CPSQualifier |
|
152 | + { |
|
153 | + if (!$this->hasCPSQualifier()) { |
|
154 | + throw new \LogicException("CPS qualifier not set."); |
|
155 | + } |
|
156 | + return $this->get(PolicyQualifierInfo::OID_CPS); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Check whether user notice qualifier is present. |
|
161 | + * |
|
162 | + * @return bool |
|
163 | + */ |
|
164 | + public function hasUserNoticeQualifier(): bool |
|
165 | + { |
|
166 | + return $this->has(PolicyQualifierInfo::OID_UNOTICE); |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Get user notice qualifier. |
|
171 | + * |
|
172 | + * @throws \LogicException |
|
173 | + * @return UserNoticeQualifier |
|
174 | + */ |
|
175 | + public function userNoticeQualifier(): UserNoticeQualifier |
|
176 | + { |
|
177 | + if (!$this->hasUserNoticeQualifier()) { |
|
178 | + throw new \LogicException("User notice qualifier not set."); |
|
179 | + } |
|
180 | + return $this->get(PolicyQualifierInfo::OID_UNOTICE); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Get ASN.1 structure. |
|
185 | + * |
|
186 | + * @return Sequence |
|
187 | + */ |
|
188 | + public function toASN1(): Sequence |
|
189 | + { |
|
190 | + $elements = array(new ObjectIdentifier($this->_oid)); |
|
191 | + if (count($this->_qualifiers)) { |
|
192 | + $qualifiers = array_map( |
|
193 | + function (PolicyQualifierInfo $pqi) { |
|
194 | + return $pqi->toASN1(); |
|
195 | + }, array_values($this->_qualifiers)); |
|
196 | + $elements[] = new Sequence(...$qualifiers); |
|
197 | + } |
|
198 | + return new Sequence(...$elements); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Get number of qualifiers. |
|
203 | + * |
|
204 | + * @see \Countable::count() |
|
205 | + * @return int |
|
206 | + */ |
|
207 | + public function count(): int |
|
208 | + { |
|
209 | + return count($this->_qualifiers); |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Get iterator for qualifiers. |
|
214 | + * |
|
215 | + * @see \IteratorAggregate::getIterator() |
|
216 | + * @return \ArrayIterator |
|
217 | + */ |
|
218 | + public function getIterator(): \ArrayIterator |
|
219 | + { |
|
220 | + return new \ArrayIterator($this->_qualifiers); |
|
221 | + } |
|
222 | 222 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension\CertificatePolicy; |
6 | 6 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $qualifiers = array(); |
67 | 67 | if (count($seq) > 1) { |
68 | 68 | $qualifiers = array_map( |
69 | - function (UnspecifiedType $el) { |
|
69 | + function(UnspecifiedType $el) { |
|
70 | 70 | return PolicyQualifierInfo::fromASN1($el->asSequence()); |
71 | 71 | }, |
72 | 72 | $seq->at(1) |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $elements = array(new ObjectIdentifier($this->_oid)); |
191 | 191 | if (count($this->_qualifiers)) { |
192 | 192 | $qualifiers = array_map( |
193 | - function (PolicyQualifierInfo $pqi) { |
|
193 | + function(PolicyQualifierInfo $pqi) { |
|
194 | 194 | return $pqi->toASN1(); |
195 | 195 | }, array_values($this->_qualifiers)); |
196 | 196 | $elements[] = new Sequence(...$qualifiers); |
@@ -16,85 +16,85 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class PolicyQualifierInfo |
18 | 18 | { |
19 | - /** |
|
20 | - * OID for the CPS Pointer qualifier. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - const OID_CPS = "1.3.6.1.5.5.7.2.1"; |
|
19 | + /** |
|
20 | + * OID for the CPS Pointer qualifier. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + const OID_CPS = "1.3.6.1.5.5.7.2.1"; |
|
25 | 25 | |
26 | - /** |
|
27 | - * OID for the user notice qualifier. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - const OID_UNOTICE = "1.3.6.1.5.5.7.2.2"; |
|
26 | + /** |
|
27 | + * OID for the user notice qualifier. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + const OID_UNOTICE = "1.3.6.1.5.5.7.2.2"; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Qualifier identifier. |
|
35 | - * |
|
36 | - * @var string $_oid |
|
37 | - */ |
|
38 | - protected $_oid; |
|
33 | + /** |
|
34 | + * Qualifier identifier. |
|
35 | + * |
|
36 | + * @var string $_oid |
|
37 | + */ |
|
38 | + protected $_oid; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Generate ASN.1 for the 'qualifier' field. |
|
42 | - * |
|
43 | - * @return \ASN1\Element |
|
44 | - */ |
|
45 | - abstract protected function _qualifierASN1(); |
|
40 | + /** |
|
41 | + * Generate ASN.1 for the 'qualifier' field. |
|
42 | + * |
|
43 | + * @return \ASN1\Element |
|
44 | + */ |
|
45 | + abstract protected function _qualifierASN1(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Initialize from qualifier ASN.1 element. |
|
49 | - * |
|
50 | - * @param UnspecifiedType $el |
|
51 | - * @return self |
|
52 | - */ |
|
53 | - public static function fromQualifierASN1(UnspecifiedType $el) |
|
54 | - { |
|
55 | - throw new \BadMethodCallException( |
|
56 | - __FUNCTION__ . " must be implemented in the derived class."); |
|
57 | - } |
|
47 | + /** |
|
48 | + * Initialize from qualifier ASN.1 element. |
|
49 | + * |
|
50 | + * @param UnspecifiedType $el |
|
51 | + * @return self |
|
52 | + */ |
|
53 | + public static function fromQualifierASN1(UnspecifiedType $el) |
|
54 | + { |
|
55 | + throw new \BadMethodCallException( |
|
56 | + __FUNCTION__ . " must be implemented in the derived class."); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Initialize from ASN.1. |
|
61 | - * |
|
62 | - * @param Sequence $seq |
|
63 | - * @throws \UnexpectedValueException |
|
64 | - * @return self |
|
65 | - */ |
|
66 | - public static function fromASN1(Sequence $seq) |
|
67 | - { |
|
68 | - $oid = $seq->at(0) |
|
69 | - ->asObjectIdentifier() |
|
70 | - ->oid(); |
|
71 | - switch ($oid) { |
|
72 | - case self::OID_CPS: |
|
73 | - return CPSQualifier::fromQualifierASN1($seq->at(1)); |
|
74 | - case self::OID_UNOTICE: |
|
75 | - return UserNoticeQualifier::fromQualifierASN1($seq->at(1)); |
|
76 | - } |
|
77 | - throw new \UnexpectedValueException("Qualifier $oid not supported."); |
|
78 | - } |
|
59 | + /** |
|
60 | + * Initialize from ASN.1. |
|
61 | + * |
|
62 | + * @param Sequence $seq |
|
63 | + * @throws \UnexpectedValueException |
|
64 | + * @return self |
|
65 | + */ |
|
66 | + public static function fromASN1(Sequence $seq) |
|
67 | + { |
|
68 | + $oid = $seq->at(0) |
|
69 | + ->asObjectIdentifier() |
|
70 | + ->oid(); |
|
71 | + switch ($oid) { |
|
72 | + case self::OID_CPS: |
|
73 | + return CPSQualifier::fromQualifierASN1($seq->at(1)); |
|
74 | + case self::OID_UNOTICE: |
|
75 | + return UserNoticeQualifier::fromQualifierASN1($seq->at(1)); |
|
76 | + } |
|
77 | + throw new \UnexpectedValueException("Qualifier $oid not supported."); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Get qualifier identifier. |
|
82 | - * |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function oid(): string |
|
86 | - { |
|
87 | - return $this->_oid; |
|
88 | - } |
|
80 | + /** |
|
81 | + * Get qualifier identifier. |
|
82 | + * |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function oid(): string |
|
86 | + { |
|
87 | + return $this->_oid; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Generate ASN.1 structure. |
|
92 | - * |
|
93 | - * @return Sequence |
|
94 | - */ |
|
95 | - public function toASN1(): Sequence |
|
96 | - { |
|
97 | - return new Sequence(new ObjectIdentifier($this->_oid), |
|
98 | - $this->_qualifierASN1()); |
|
99 | - } |
|
90 | + /** |
|
91 | + * Generate ASN.1 structure. |
|
92 | + * |
|
93 | + * @return Sequence |
|
94 | + */ |
|
95 | + public function toASN1(): Sequence |
|
96 | + { |
|
97 | + return new Sequence(new ObjectIdentifier($this->_oid), |
|
98 | + $this->_qualifierASN1()); |
|
99 | + } |
|
100 | 100 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension\CertificatePolicy; |
6 | 6 |
@@ -13,34 +13,34 @@ |
||
13 | 13 | */ |
14 | 14 | class NoRevocationAvailableExtension extends Extension |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param bool $critical |
|
20 | - */ |
|
21 | - public function __construct(bool $critical) |
|
22 | - { |
|
23 | - parent::__construct(self::OID_NO_REV_AVAIL, $critical); |
|
24 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param bool $critical |
|
20 | + */ |
|
21 | + public function __construct(bool $critical) |
|
22 | + { |
|
23 | + parent::__construct(self::OID_NO_REV_AVAIL, $critical); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * |
|
28 | - * {@inheritdoc} |
|
29 | - * @return self |
|
30 | - */ |
|
31 | - protected static function _fromDER($data, $critical) |
|
32 | - { |
|
33 | - NullType::fromDER($data); |
|
34 | - return new self($critical); |
|
35 | - } |
|
26 | + /** |
|
27 | + * |
|
28 | + * {@inheritdoc} |
|
29 | + * @return self |
|
30 | + */ |
|
31 | + protected static function _fromDER($data, $critical) |
|
32 | + { |
|
33 | + NullType::fromDER($data); |
|
34 | + return new self($critical); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * |
|
39 | - * {@inheritdoc} |
|
40 | - * @return NullType |
|
41 | - */ |
|
42 | - protected function _valueASN1(): NullType |
|
43 | - { |
|
44 | - return new NullType(); |
|
45 | - } |
|
37 | + /** |
|
38 | + * |
|
39 | + * {@inheritdoc} |
|
40 | + * @return NullType |
|
41 | + */ |
|
42 | + protected function _valueASN1(): NullType |
|
43 | + { |
|
44 | + return new NullType(); |
|
45 | + } |
|
46 | 46 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension; |
6 | 6 |
@@ -14,95 +14,95 @@ |
||
14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.13 |
15 | 15 | */ |
16 | 16 | class CRLDistributionPointsExtension extends Extension implements |
17 | - \Countable, |
|
18 | - \IteratorAggregate |
|
17 | + \Countable, |
|
18 | + \IteratorAggregate |
|
19 | 19 | { |
20 | - /** |
|
21 | - * Distribution points. |
|
22 | - * |
|
23 | - * @var DistributionPoint[] $_distributionPoints |
|
24 | - */ |
|
25 | - protected $_distributionPoints; |
|
20 | + /** |
|
21 | + * Distribution points. |
|
22 | + * |
|
23 | + * @var DistributionPoint[] $_distributionPoints |
|
24 | + */ |
|
25 | + protected $_distributionPoints; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param bool $critical |
|
31 | - * @param DistributionPoint[] $distribution_points |
|
32 | - */ |
|
33 | - public function __construct(bool $critical, |
|
34 | - DistributionPoint ...$distribution_points) |
|
35 | - { |
|
36 | - parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
37 | - $this->_distributionPoints = $distribution_points; |
|
38 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param bool $critical |
|
31 | + * @param DistributionPoint[] $distribution_points |
|
32 | + */ |
|
33 | + public function __construct(bool $critical, |
|
34 | + DistributionPoint ...$distribution_points) |
|
35 | + { |
|
36 | + parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
37 | + $this->_distributionPoints = $distribution_points; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * |
|
42 | - * {@inheritdoc} |
|
43 | - * @return self |
|
44 | - */ |
|
45 | - protected static function _fromDER($data, $critical) |
|
46 | - { |
|
47 | - $dps = array_map( |
|
48 | - function (UnspecifiedType $el) { |
|
49 | - return DistributionPoint::fromASN1($el->asSequence()); |
|
50 | - }, Sequence::fromDER($data)->elements()); |
|
51 | - if (!count($dps)) { |
|
52 | - throw new \UnexpectedValueException( |
|
53 | - "CRLDistributionPoints must have" . |
|
54 | - " at least one DistributionPoint."); |
|
55 | - } |
|
56 | - // late static bound, extended by Freshest CRL extension |
|
57 | - return new static($critical, ...$dps); |
|
58 | - } |
|
40 | + /** |
|
41 | + * |
|
42 | + * {@inheritdoc} |
|
43 | + * @return self |
|
44 | + */ |
|
45 | + protected static function _fromDER($data, $critical) |
|
46 | + { |
|
47 | + $dps = array_map( |
|
48 | + function (UnspecifiedType $el) { |
|
49 | + return DistributionPoint::fromASN1($el->asSequence()); |
|
50 | + }, Sequence::fromDER($data)->elements()); |
|
51 | + if (!count($dps)) { |
|
52 | + throw new \UnexpectedValueException( |
|
53 | + "CRLDistributionPoints must have" . |
|
54 | + " at least one DistributionPoint."); |
|
55 | + } |
|
56 | + // late static bound, extended by Freshest CRL extension |
|
57 | + return new static($critical, ...$dps); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * |
|
62 | - * {@inheritdoc} |
|
63 | - * @return Sequence |
|
64 | - */ |
|
65 | - protected function _valueASN1(): Sequence |
|
66 | - { |
|
67 | - if (!count($this->_distributionPoints)) { |
|
68 | - throw new \LogicException("No distribution points."); |
|
69 | - } |
|
70 | - $elements = array_map( |
|
71 | - function (DistributionPoint $dp) { |
|
72 | - return $dp->toASN1(); |
|
73 | - }, $this->_distributionPoints); |
|
74 | - return new Sequence(...$elements); |
|
75 | - } |
|
60 | + /** |
|
61 | + * |
|
62 | + * {@inheritdoc} |
|
63 | + * @return Sequence |
|
64 | + */ |
|
65 | + protected function _valueASN1(): Sequence |
|
66 | + { |
|
67 | + if (!count($this->_distributionPoints)) { |
|
68 | + throw new \LogicException("No distribution points."); |
|
69 | + } |
|
70 | + $elements = array_map( |
|
71 | + function (DistributionPoint $dp) { |
|
72 | + return $dp->toASN1(); |
|
73 | + }, $this->_distributionPoints); |
|
74 | + return new Sequence(...$elements); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Get distribution points. |
|
79 | - * |
|
80 | - * @return DistributionPoint[] |
|
81 | - */ |
|
82 | - public function distributionPoints(): array |
|
83 | - { |
|
84 | - return $this->_distributionPoints; |
|
85 | - } |
|
77 | + /** |
|
78 | + * Get distribution points. |
|
79 | + * |
|
80 | + * @return DistributionPoint[] |
|
81 | + */ |
|
82 | + public function distributionPoints(): array |
|
83 | + { |
|
84 | + return $this->_distributionPoints; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Get the number of distribution points. |
|
89 | - * |
|
90 | - * @see \Countable::count() |
|
91 | - * @return int |
|
92 | - */ |
|
93 | - public function count(): int |
|
94 | - { |
|
95 | - return count($this->_distributionPoints); |
|
96 | - } |
|
87 | + /** |
|
88 | + * Get the number of distribution points. |
|
89 | + * |
|
90 | + * @see \Countable::count() |
|
91 | + * @return int |
|
92 | + */ |
|
93 | + public function count(): int |
|
94 | + { |
|
95 | + return count($this->_distributionPoints); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Get iterator for distribution points. |
|
100 | - * |
|
101 | - * @see \IteratorAggregate::getIterator() |
|
102 | - * @return \ArrayIterator |
|
103 | - */ |
|
104 | - public function getIterator(): \ArrayIterator |
|
105 | - { |
|
106 | - return new \ArrayIterator($this->_distributionPoints); |
|
107 | - } |
|
98 | + /** |
|
99 | + * Get iterator for distribution points. |
|
100 | + * |
|
101 | + * @see \IteratorAggregate::getIterator() |
|
102 | + * @return \ArrayIterator |
|
103 | + */ |
|
104 | + public function getIterator(): \ArrayIterator |
|
105 | + { |
|
106 | + return new \ArrayIterator($this->_distributionPoints); |
|
107 | + } |
|
108 | 108 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension; |
6 | 6 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | protected static function _fromDER($data, $critical) |
46 | 46 | { |
47 | 47 | $dps = array_map( |
48 | - function (UnspecifiedType $el) { |
|
48 | + function(UnspecifiedType $el) { |
|
49 | 49 | return DistributionPoint::fromASN1($el->asSequence()); |
50 | 50 | }, Sequence::fromDER($data)->elements()); |
51 | 51 | if (!count($dps)) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | throw new \LogicException("No distribution points."); |
69 | 69 | } |
70 | 70 | $elements = array_map( |
71 | - function (DistributionPoint $dp) { |
|
71 | + function(DistributionPoint $dp) { |
|
72 | 72 | return $dp->toASN1(); |
73 | 73 | }, $this->_distributionPoints); |
74 | 74 | return new Sequence(...$elements); |
@@ -19,139 +19,139 @@ |
||
19 | 19 | * @link https://tools.ietf.org/html/rfc5755#section-4.3.2 |
20 | 20 | */ |
21 | 21 | class TargetInformationExtension extends Extension implements |
22 | - \Countable, |
|
23 | - \IteratorAggregate |
|
22 | + \Countable, |
|
23 | + \IteratorAggregate |
|
24 | 24 | { |
25 | - /** |
|
26 | - * Targets elements. |
|
27 | - * |
|
28 | - * @var Targets[] $_targets |
|
29 | - */ |
|
30 | - protected $_targets; |
|
25 | + /** |
|
26 | + * Targets elements. |
|
27 | + * |
|
28 | + * @var Targets[] $_targets |
|
29 | + */ |
|
30 | + protected $_targets; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Targets[] merged to single Targets. |
|
34 | - * |
|
35 | - * @var Targets|null |
|
36 | - */ |
|
37 | - private $_merged; |
|
32 | + /** |
|
33 | + * Targets[] merged to single Targets. |
|
34 | + * |
|
35 | + * @var Targets|null |
|
36 | + */ |
|
37 | + private $_merged; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. |
|
41 | - * |
|
42 | - * @param bool $critical |
|
43 | - * @param Targets[] $targets |
|
44 | - */ |
|
45 | - public function __construct(bool $critical, Targets ...$targets) |
|
46 | - { |
|
47 | - parent::__construct(self::OID_TARGET_INFORMATION, $critical); |
|
48 | - $this->_targets = $targets; |
|
49 | - } |
|
39 | + /** |
|
40 | + * Constructor. |
|
41 | + * |
|
42 | + * @param bool $critical |
|
43 | + * @param Targets[] $targets |
|
44 | + */ |
|
45 | + public function __construct(bool $critical, Targets ...$targets) |
|
46 | + { |
|
47 | + parent::__construct(self::OID_TARGET_INFORMATION, $critical); |
|
48 | + $this->_targets = $targets; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Initialize from one or more Target objects. |
|
53 | - * |
|
54 | - * Extension criticality shall be set to true as specified by RFC 5755. |
|
55 | - * |
|
56 | - * @param Target[] $target |
|
57 | - * @return TargetInformationExtension |
|
58 | - */ |
|
59 | - public static function fromTargets(Target ...$target) |
|
60 | - { |
|
61 | - return new self(true, new Targets(...$target)); |
|
62 | - } |
|
51 | + /** |
|
52 | + * Initialize from one or more Target objects. |
|
53 | + * |
|
54 | + * Extension criticality shall be set to true as specified by RFC 5755. |
|
55 | + * |
|
56 | + * @param Target[] $target |
|
57 | + * @return TargetInformationExtension |
|
58 | + */ |
|
59 | + public static function fromTargets(Target ...$target) |
|
60 | + { |
|
61 | + return new self(true, new Targets(...$target)); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Reset internal state on clone. |
|
66 | - */ |
|
67 | - public function __clone() |
|
68 | - { |
|
69 | - $this->_merged = null; |
|
70 | - } |
|
64 | + /** |
|
65 | + * Reset internal state on clone. |
|
66 | + */ |
|
67 | + public function __clone() |
|
68 | + { |
|
69 | + $this->_merged = null; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * |
|
74 | - * {@inheritdoc} |
|
75 | - * @return self |
|
76 | - */ |
|
77 | - protected static function _fromDER($data, $critical) |
|
78 | - { |
|
79 | - $targets = array_map( |
|
80 | - function (UnspecifiedType $el) { |
|
81 | - return Targets::fromASN1($el->asSequence()); |
|
82 | - }, Sequence::fromDER($data)->elements()); |
|
83 | - return new self($critical, ...$targets); |
|
84 | - } |
|
72 | + /** |
|
73 | + * |
|
74 | + * {@inheritdoc} |
|
75 | + * @return self |
|
76 | + */ |
|
77 | + protected static function _fromDER($data, $critical) |
|
78 | + { |
|
79 | + $targets = array_map( |
|
80 | + function (UnspecifiedType $el) { |
|
81 | + return Targets::fromASN1($el->asSequence()); |
|
82 | + }, Sequence::fromDER($data)->elements()); |
|
83 | + return new self($critical, ...$targets); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get all targets. |
|
88 | - * |
|
89 | - * @return Targets |
|
90 | - */ |
|
91 | - public function targets(): Targets |
|
92 | - { |
|
93 | - if (!isset($this->_merged)) { |
|
94 | - $a = array(); |
|
95 | - foreach ($this->_targets as $targets) { |
|
96 | - $a = array_merge($a, $targets->all()); |
|
97 | - } |
|
98 | - $this->_merged = new Targets(...$a); |
|
99 | - } |
|
100 | - return $this->_merged; |
|
101 | - } |
|
86 | + /** |
|
87 | + * Get all targets. |
|
88 | + * |
|
89 | + * @return Targets |
|
90 | + */ |
|
91 | + public function targets(): Targets |
|
92 | + { |
|
93 | + if (!isset($this->_merged)) { |
|
94 | + $a = array(); |
|
95 | + foreach ($this->_targets as $targets) { |
|
96 | + $a = array_merge($a, $targets->all()); |
|
97 | + } |
|
98 | + $this->_merged = new Targets(...$a); |
|
99 | + } |
|
100 | + return $this->_merged; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Get all name targets. |
|
105 | - * |
|
106 | - * @return Target[] |
|
107 | - */ |
|
108 | - public function names(): array |
|
109 | - { |
|
110 | - return $this->targets()->nameTargets(); |
|
111 | - } |
|
103 | + /** |
|
104 | + * Get all name targets. |
|
105 | + * |
|
106 | + * @return Target[] |
|
107 | + */ |
|
108 | + public function names(): array |
|
109 | + { |
|
110 | + return $this->targets()->nameTargets(); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Get all group targets. |
|
115 | - * |
|
116 | - * @return Target[] |
|
117 | - */ |
|
118 | - public function groups(): array |
|
119 | - { |
|
120 | - return $this->targets()->groupTargets(); |
|
121 | - } |
|
113 | + /** |
|
114 | + * Get all group targets. |
|
115 | + * |
|
116 | + * @return Target[] |
|
117 | + */ |
|
118 | + public function groups(): array |
|
119 | + { |
|
120 | + return $this->targets()->groupTargets(); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * |
|
125 | - * @see \X509\Certificate\Extension\Extension::_valueASN1() |
|
126 | - * @return Sequence |
|
127 | - */ |
|
128 | - protected function _valueASN1(): Sequence |
|
129 | - { |
|
130 | - $elements = array_map( |
|
131 | - function (Targets $targets) { |
|
132 | - return $targets->toASN1(); |
|
133 | - }, $this->_targets); |
|
134 | - return new Sequence(...$elements); |
|
135 | - } |
|
123 | + /** |
|
124 | + * |
|
125 | + * @see \X509\Certificate\Extension\Extension::_valueASN1() |
|
126 | + * @return Sequence |
|
127 | + */ |
|
128 | + protected function _valueASN1(): Sequence |
|
129 | + { |
|
130 | + $elements = array_map( |
|
131 | + function (Targets $targets) { |
|
132 | + return $targets->toASN1(); |
|
133 | + }, $this->_targets); |
|
134 | + return new Sequence(...$elements); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * |
|
139 | - * @see \Countable::count() |
|
140 | - * @return int |
|
141 | - */ |
|
142 | - public function count(): int |
|
143 | - { |
|
144 | - return count($this->targets()); |
|
145 | - } |
|
137 | + /** |
|
138 | + * |
|
139 | + * @see \Countable::count() |
|
140 | + * @return int |
|
141 | + */ |
|
142 | + public function count(): int |
|
143 | + { |
|
144 | + return count($this->targets()); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Get iterator for targets. |
|
149 | - * |
|
150 | - * @see \IteratorAggregate::getIterator() |
|
151 | - * @return \ArrayIterator |
|
152 | - */ |
|
153 | - public function getIterator(): \ArrayIterator |
|
154 | - { |
|
155 | - return new \ArrayIterator($this->targets()->all()); |
|
156 | - } |
|
147 | + /** |
|
148 | + * Get iterator for targets. |
|
149 | + * |
|
150 | + * @see \IteratorAggregate::getIterator() |
|
151 | + * @return \ArrayIterator |
|
152 | + */ |
|
153 | + public function getIterator(): \ArrayIterator |
|
154 | + { |
|
155 | + return new \ArrayIterator($this->targets()->all()); |
|
156 | + } |
|
157 | 157 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension; |
6 | 6 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected static function _fromDER($data, $critical) |
78 | 78 | { |
79 | 79 | $targets = array_map( |
80 | - function (UnspecifiedType $el) { |
|
80 | + function(UnspecifiedType $el) { |
|
81 | 81 | return Targets::fromASN1($el->asSequence()); |
82 | 82 | }, Sequence::fromDER($data)->elements()); |
83 | 83 | return new self($critical, ...$targets); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | protected function _valueASN1(): Sequence |
129 | 129 | { |
130 | 130 | $elements = array_map( |
131 | - function (Targets $targets) { |
|
131 | + function(Targets $targets) { |
|
132 | 132 | return $targets->toASN1(); |
133 | 133 | }, $this->_targets); |
134 | 134 | return new Sequence(...$elements); |
@@ -14,133 +14,133 @@ |
||
14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.12 |
15 | 15 | */ |
16 | 16 | class ExtendedKeyUsageExtension extends Extension implements |
17 | - \Countable, |
|
18 | - \IteratorAggregate |
|
17 | + \Countable, |
|
18 | + \IteratorAggregate |
|
19 | 19 | { |
20 | - const OID_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; |
|
21 | - const OID_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; |
|
22 | - const OID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; |
|
23 | - const OID_EMAIL_PROTECTION = "1.3.6.1.5.5.7.3.4"; |
|
24 | - const OID_IPSEC_END_SYSTEM = "1.3.6.1.5.5.7.3.5"; |
|
25 | - const OID_IPSEC_TUNNEL = "1.3.6.1.5.5.7.3.6"; |
|
26 | - const OID_IPSEC_USER = "1.3.6.1.5.5.7.3.7"; |
|
27 | - const OID_TIME_STAMPING = "1.3.6.1.5.5.7.3.8"; |
|
28 | - const OID_OCSP_SIGNING = "1.3.6.1.5.5.7.3.9"; |
|
29 | - const OID_DVCS = "1.3.6.1.5.5.7.3.10"; |
|
30 | - const OID_SBGP_CERT_AA_SERVER_AUTH = "1.3.6.1.5.5.7.3.11"; |
|
31 | - const OID_SCVP_RESPONDER = "1.3.6.1.5.5.7.3.12"; |
|
32 | - const OID_EAP_OVER_PPP = "1.3.6.1.5.5.7.3.13"; |
|
33 | - const OID_EAP_OVER_LAN = "1.3.6.1.5.5.7.3.14"; |
|
34 | - const OID_SCVP_SERVER = "1.3.6.1.5.5.7.3.15"; |
|
35 | - const OID_SCVP_CLIENT = "1.3.6.1.5.5.7.3.16"; |
|
36 | - const OID_IPSEC_IKE = "1.3.6.1.5.5.7.3.17"; |
|
37 | - const OID_CAPWAP_AC = "1.3.6.1.5.5.7.3.18"; |
|
38 | - const OID_CAPWAP_WTP = "1.3.6.1.5.5.7.3.19"; |
|
39 | - const OID_SIP_DOMAIN = "1.3.6.1.5.5.7.3.20"; |
|
40 | - const OID_SECURE_SHELL_CLIENT = "1.3.6.1.5.5.7.3.21"; |
|
41 | - const OID_SECURE_SHELL_SERVER = "1.3.6.1.5.5.7.3.22"; |
|
42 | - const OID_SEND_ROUTER = "1.3.6.1.5.5.7.3.23"; |
|
43 | - const OID_SEND_PROXY = "1.3.6.1.5.5.7.3.24"; |
|
44 | - const OID_SEND_OWNER = "1.3.6.1.5.5.7.3.25"; |
|
45 | - const OID_SEND_PROXIED_OWNER = "1.3.6.1.5.5.7.3.26"; |
|
46 | - const OID_CMC_CA = "1.3.6.1.5.5.7.3.27"; |
|
47 | - const OID_CMC_RA = "1.3.6.1.5.5.7.3.28"; |
|
48 | - const OID_CMC_ARCHIVE = "1.3.6.1.5.5.7.3.29"; |
|
20 | + const OID_SERVER_AUTH = "1.3.6.1.5.5.7.3.1"; |
|
21 | + const OID_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2"; |
|
22 | + const OID_CODE_SIGNING = "1.3.6.1.5.5.7.3.3"; |
|
23 | + const OID_EMAIL_PROTECTION = "1.3.6.1.5.5.7.3.4"; |
|
24 | + const OID_IPSEC_END_SYSTEM = "1.3.6.1.5.5.7.3.5"; |
|
25 | + const OID_IPSEC_TUNNEL = "1.3.6.1.5.5.7.3.6"; |
|
26 | + const OID_IPSEC_USER = "1.3.6.1.5.5.7.3.7"; |
|
27 | + const OID_TIME_STAMPING = "1.3.6.1.5.5.7.3.8"; |
|
28 | + const OID_OCSP_SIGNING = "1.3.6.1.5.5.7.3.9"; |
|
29 | + const OID_DVCS = "1.3.6.1.5.5.7.3.10"; |
|
30 | + const OID_SBGP_CERT_AA_SERVER_AUTH = "1.3.6.1.5.5.7.3.11"; |
|
31 | + const OID_SCVP_RESPONDER = "1.3.6.1.5.5.7.3.12"; |
|
32 | + const OID_EAP_OVER_PPP = "1.3.6.1.5.5.7.3.13"; |
|
33 | + const OID_EAP_OVER_LAN = "1.3.6.1.5.5.7.3.14"; |
|
34 | + const OID_SCVP_SERVER = "1.3.6.1.5.5.7.3.15"; |
|
35 | + const OID_SCVP_CLIENT = "1.3.6.1.5.5.7.3.16"; |
|
36 | + const OID_IPSEC_IKE = "1.3.6.1.5.5.7.3.17"; |
|
37 | + const OID_CAPWAP_AC = "1.3.6.1.5.5.7.3.18"; |
|
38 | + const OID_CAPWAP_WTP = "1.3.6.1.5.5.7.3.19"; |
|
39 | + const OID_SIP_DOMAIN = "1.3.6.1.5.5.7.3.20"; |
|
40 | + const OID_SECURE_SHELL_CLIENT = "1.3.6.1.5.5.7.3.21"; |
|
41 | + const OID_SECURE_SHELL_SERVER = "1.3.6.1.5.5.7.3.22"; |
|
42 | + const OID_SEND_ROUTER = "1.3.6.1.5.5.7.3.23"; |
|
43 | + const OID_SEND_PROXY = "1.3.6.1.5.5.7.3.24"; |
|
44 | + const OID_SEND_OWNER = "1.3.6.1.5.5.7.3.25"; |
|
45 | + const OID_SEND_PROXIED_OWNER = "1.3.6.1.5.5.7.3.26"; |
|
46 | + const OID_CMC_CA = "1.3.6.1.5.5.7.3.27"; |
|
47 | + const OID_CMC_RA = "1.3.6.1.5.5.7.3.28"; |
|
48 | + const OID_CMC_ARCHIVE = "1.3.6.1.5.5.7.3.29"; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Purpose OID's. |
|
52 | - * |
|
53 | - * @var string[] $_purposes |
|
54 | - */ |
|
55 | - protected $_purposes; |
|
50 | + /** |
|
51 | + * Purpose OID's. |
|
52 | + * |
|
53 | + * @var string[] $_purposes |
|
54 | + */ |
|
55 | + protected $_purposes; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Constructor. |
|
59 | - * |
|
60 | - * @param bool $critical |
|
61 | - * @param string[] $purposes |
|
62 | - */ |
|
63 | - public function __construct(bool $critical, ...$purposes) |
|
64 | - { |
|
65 | - parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
66 | - $this->_purposes = $purposes; |
|
67 | - } |
|
57 | + /** |
|
58 | + * Constructor. |
|
59 | + * |
|
60 | + * @param bool $critical |
|
61 | + * @param string[] $purposes |
|
62 | + */ |
|
63 | + public function __construct(bool $critical, ...$purposes) |
|
64 | + { |
|
65 | + parent::__construct(self::OID_EXT_KEY_USAGE, $critical); |
|
66 | + $this->_purposes = $purposes; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * |
|
71 | - * {@inheritdoc} |
|
72 | - * @return self |
|
73 | - */ |
|
74 | - protected static function _fromDER($data, $critical) |
|
75 | - { |
|
76 | - $purposes = array_map( |
|
77 | - function (UnspecifiedType $el) { |
|
78 | - return $el->asObjectIdentifier()->oid(); |
|
79 | - }, Sequence::fromDER($data)->elements()); |
|
80 | - return new self($critical, ...$purposes); |
|
81 | - } |
|
69 | + /** |
|
70 | + * |
|
71 | + * {@inheritdoc} |
|
72 | + * @return self |
|
73 | + */ |
|
74 | + protected static function _fromDER($data, $critical) |
|
75 | + { |
|
76 | + $purposes = array_map( |
|
77 | + function (UnspecifiedType $el) { |
|
78 | + return $el->asObjectIdentifier()->oid(); |
|
79 | + }, Sequence::fromDER($data)->elements()); |
|
80 | + return new self($critical, ...$purposes); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Whether purposes are present. |
|
85 | - * |
|
86 | - * If multiple purposes are checked, all must be present. |
|
87 | - * |
|
88 | - * @param string[] $oids |
|
89 | - * @return bool |
|
90 | - */ |
|
91 | - public function has(...$oids): bool |
|
92 | - { |
|
93 | - foreach ($oids as $oid) { |
|
94 | - if (!in_array($oid, $this->_purposes)) { |
|
95 | - return false; |
|
96 | - } |
|
97 | - } |
|
98 | - return true; |
|
99 | - } |
|
83 | + /** |
|
84 | + * Whether purposes are present. |
|
85 | + * |
|
86 | + * If multiple purposes are checked, all must be present. |
|
87 | + * |
|
88 | + * @param string[] $oids |
|
89 | + * @return bool |
|
90 | + */ |
|
91 | + public function has(...$oids): bool |
|
92 | + { |
|
93 | + foreach ($oids as $oid) { |
|
94 | + if (!in_array($oid, $this->_purposes)) { |
|
95 | + return false; |
|
96 | + } |
|
97 | + } |
|
98 | + return true; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get key usage purpose OID's. |
|
103 | - * |
|
104 | - * @return string[] |
|
105 | - */ |
|
106 | - public function purposes(): array |
|
107 | - { |
|
108 | - return $this->_purposes; |
|
109 | - } |
|
101 | + /** |
|
102 | + * Get key usage purpose OID's. |
|
103 | + * |
|
104 | + * @return string[] |
|
105 | + */ |
|
106 | + public function purposes(): array |
|
107 | + { |
|
108 | + return $this->_purposes; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * |
|
113 | - * {@inheritdoc} |
|
114 | - * @return Sequence |
|
115 | - */ |
|
116 | - protected function _valueASN1(): Sequence |
|
117 | - { |
|
118 | - $elements = array_map( |
|
119 | - function ($oid) { |
|
120 | - return new ObjectIdentifier($oid); |
|
121 | - }, $this->_purposes); |
|
122 | - return new Sequence(...$elements); |
|
123 | - } |
|
111 | + /** |
|
112 | + * |
|
113 | + * {@inheritdoc} |
|
114 | + * @return Sequence |
|
115 | + */ |
|
116 | + protected function _valueASN1(): Sequence |
|
117 | + { |
|
118 | + $elements = array_map( |
|
119 | + function ($oid) { |
|
120 | + return new ObjectIdentifier($oid); |
|
121 | + }, $this->_purposes); |
|
122 | + return new Sequence(...$elements); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Get the number of purposes. |
|
127 | - * |
|
128 | - * @see \Countable::count() |
|
129 | - * @return int |
|
130 | - */ |
|
131 | - public function count(): int |
|
132 | - { |
|
133 | - return count($this->_purposes); |
|
134 | - } |
|
125 | + /** |
|
126 | + * Get the number of purposes. |
|
127 | + * |
|
128 | + * @see \Countable::count() |
|
129 | + * @return int |
|
130 | + */ |
|
131 | + public function count(): int |
|
132 | + { |
|
133 | + return count($this->_purposes); |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Get iterator for usage purposes. |
|
138 | - * |
|
139 | - * @see \IteratorAggregate::getIterator() |
|
140 | - * @return \ArrayIterator |
|
141 | - */ |
|
142 | - public function getIterator(): \ArrayIterator |
|
143 | - { |
|
144 | - return new \ArrayIterator($this->_purposes); |
|
145 | - } |
|
136 | + /** |
|
137 | + * Get iterator for usage purposes. |
|
138 | + * |
|
139 | + * @see \IteratorAggregate::getIterator() |
|
140 | + * @return \ArrayIterator |
|
141 | + */ |
|
142 | + public function getIterator(): \ArrayIterator |
|
143 | + { |
|
144 | + return new \ArrayIterator($this->_purposes); |
|
145 | + } |
|
146 | 146 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace X509\Certificate\Extension; |
6 | 6 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected static function _fromDER($data, $critical) |
75 | 75 | { |
76 | 76 | $purposes = array_map( |
77 | - function (UnspecifiedType $el) { |
|
77 | + function(UnspecifiedType $el) { |
|
78 | 78 | return $el->asObjectIdentifier()->oid(); |
79 | 79 | }, Sequence::fromDER($data)->elements()); |
80 | 80 | return new self($critical, ...$purposes); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | protected function _valueASN1(): Sequence |
117 | 117 | { |
118 | 118 | $elements = array_map( |
119 | - function ($oid) { |
|
119 | + function($oid) { |
|
120 | 120 | return new ObjectIdentifier($oid); |
121 | 121 | }, $this->_purposes); |
122 | 122 | return new Sequence(...$elements); |