@@ -14,85 +14,85 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class PolicyQualifierInfo |
16 | 16 | { |
17 | - /** |
|
18 | - * OID for the CPS Pointer qualifier. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - const OID_CPS = "1.3.6.1.5.5.7.2.1"; |
|
17 | + /** |
|
18 | + * OID for the CPS Pointer qualifier. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + const OID_CPS = "1.3.6.1.5.5.7.2.1"; |
|
23 | 23 | |
24 | - /** |
|
25 | - * OID for the user notice qualifier. |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - const OID_UNOTICE = "1.3.6.1.5.5.7.2.2"; |
|
24 | + /** |
|
25 | + * OID for the user notice qualifier. |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + const OID_UNOTICE = "1.3.6.1.5.5.7.2.2"; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Qualifier identifier. |
|
33 | - * |
|
34 | - * @var string $_oid |
|
35 | - */ |
|
36 | - protected $_oid; |
|
31 | + /** |
|
32 | + * Qualifier identifier. |
|
33 | + * |
|
34 | + * @var string $_oid |
|
35 | + */ |
|
36 | + protected $_oid; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Generate ASN.1 for the 'qualifier' field. |
|
40 | - * |
|
41 | - * @return \ASN1\Element |
|
42 | - */ |
|
43 | - abstract protected function _qualifierASN1(); |
|
38 | + /** |
|
39 | + * Generate ASN.1 for the 'qualifier' field. |
|
40 | + * |
|
41 | + * @return \ASN1\Element |
|
42 | + */ |
|
43 | + abstract protected function _qualifierASN1(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * Initialize from qualifier ASN.1 element. |
|
47 | - * |
|
48 | - * @param UnspecifiedType $el |
|
49 | - * @return self |
|
50 | - */ |
|
51 | - public static function fromQualifierASN1(UnspecifiedType $el) |
|
52 | - { |
|
53 | - throw new \BadMethodCallException( |
|
54 | - __FUNCTION__ . " must be implemented in the derived class."); |
|
55 | - } |
|
45 | + /** |
|
46 | + * Initialize from qualifier ASN.1 element. |
|
47 | + * |
|
48 | + * @param UnspecifiedType $el |
|
49 | + * @return self |
|
50 | + */ |
|
51 | + public static function fromQualifierASN1(UnspecifiedType $el) |
|
52 | + { |
|
53 | + throw new \BadMethodCallException( |
|
54 | + __FUNCTION__ . " must be implemented in the derived class."); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Initialize from ASN.1. |
|
59 | - * |
|
60 | - * @param Sequence $seq |
|
61 | - * @throws \UnexpectedValueException |
|
62 | - * @return self |
|
63 | - */ |
|
64 | - public static function fromASN1(Sequence $seq) |
|
65 | - { |
|
66 | - $oid = $seq->at(0) |
|
67 | - ->asObjectIdentifier() |
|
68 | - ->oid(); |
|
69 | - switch ($oid) { |
|
70 | - case self::OID_CPS: |
|
71 | - return CPSQualifier::fromQualifierASN1($seq->at(1)); |
|
72 | - case self::OID_UNOTICE: |
|
73 | - return UserNoticeQualifier::fromQualifierASN1($seq->at(1)); |
|
74 | - } |
|
75 | - throw new \UnexpectedValueException("Qualifier $oid not supported."); |
|
76 | - } |
|
57 | + /** |
|
58 | + * Initialize from ASN.1. |
|
59 | + * |
|
60 | + * @param Sequence $seq |
|
61 | + * @throws \UnexpectedValueException |
|
62 | + * @return self |
|
63 | + */ |
|
64 | + public static function fromASN1(Sequence $seq) |
|
65 | + { |
|
66 | + $oid = $seq->at(0) |
|
67 | + ->asObjectIdentifier() |
|
68 | + ->oid(); |
|
69 | + switch ($oid) { |
|
70 | + case self::OID_CPS: |
|
71 | + return CPSQualifier::fromQualifierASN1($seq->at(1)); |
|
72 | + case self::OID_UNOTICE: |
|
73 | + return UserNoticeQualifier::fromQualifierASN1($seq->at(1)); |
|
74 | + } |
|
75 | + throw new \UnexpectedValueException("Qualifier $oid not supported."); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Get qualifier identifier. |
|
80 | - * |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function oid() |
|
84 | - { |
|
85 | - return $this->_oid; |
|
86 | - } |
|
78 | + /** |
|
79 | + * Get qualifier identifier. |
|
80 | + * |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function oid() |
|
84 | + { |
|
85 | + return $this->_oid; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Generate ASN.1 structure. |
|
90 | - * |
|
91 | - * @return Sequence |
|
92 | - */ |
|
93 | - public function toASN1() |
|
94 | - { |
|
95 | - return new Sequence(new ObjectIdentifier($this->_oid), |
|
96 | - $this->_qualifierASN1()); |
|
97 | - } |
|
88 | + /** |
|
89 | + * Generate ASN.1 structure. |
|
90 | + * |
|
91 | + * @return Sequence |
|
92 | + */ |
|
93 | + public function toASN1() |
|
94 | + { |
|
95 | + return new Sequence(new ObjectIdentifier($this->_oid), |
|
96 | + $this->_qualifierASN1()); |
|
97 | + } |
|
98 | 98 | } |
@@ -12,274 +12,274 @@ |
||
12 | 12 | */ |
13 | 13 | class PathValidationConfig |
14 | 14 | { |
15 | - /** |
|
16 | - * Maximum allowed certification path length. |
|
17 | - * |
|
18 | - * @var int $_maxLength |
|
19 | - */ |
|
20 | - protected $_maxLength; |
|
15 | + /** |
|
16 | + * Maximum allowed certification path length. |
|
17 | + * |
|
18 | + * @var int $_maxLength |
|
19 | + */ |
|
20 | + protected $_maxLength; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Reference time. |
|
24 | - * |
|
25 | - * @var \DateTimeImmutable $_dateTime |
|
26 | - */ |
|
27 | - protected $_dateTime; |
|
22 | + /** |
|
23 | + * Reference time. |
|
24 | + * |
|
25 | + * @var \DateTimeImmutable $_dateTime |
|
26 | + */ |
|
27 | + protected $_dateTime; |
|
28 | 28 | |
29 | - /** |
|
30 | - * List of acceptable policy identifiers. |
|
31 | - * |
|
32 | - * @var string[] $_policySet |
|
33 | - */ |
|
34 | - protected $_policySet; |
|
29 | + /** |
|
30 | + * List of acceptable policy identifiers. |
|
31 | + * |
|
32 | + * @var string[] $_policySet |
|
33 | + */ |
|
34 | + protected $_policySet; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Trust anchor certificate. |
|
38 | - * |
|
39 | - * If not set, path validation uses the first certificate of the path. |
|
40 | - * |
|
41 | - * @var Certificate|null $_trustAnchor |
|
42 | - */ |
|
43 | - protected $_trustAnchor; |
|
36 | + /** |
|
37 | + * Trust anchor certificate. |
|
38 | + * |
|
39 | + * If not set, path validation uses the first certificate of the path. |
|
40 | + * |
|
41 | + * @var Certificate|null $_trustAnchor |
|
42 | + */ |
|
43 | + protected $_trustAnchor; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Whether policy mapping in inhibited. |
|
47 | - * |
|
48 | - * Setting this to true disallows policy mapping. |
|
49 | - * |
|
50 | - * @var bool $_policyMappingInhibit |
|
51 | - */ |
|
52 | - protected $_policyMappingInhibit; |
|
45 | + /** |
|
46 | + * Whether policy mapping in inhibited. |
|
47 | + * |
|
48 | + * Setting this to true disallows policy mapping. |
|
49 | + * |
|
50 | + * @var bool $_policyMappingInhibit |
|
51 | + */ |
|
52 | + protected $_policyMappingInhibit; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Whether the path must be valid for at least one policy in the |
|
56 | - * initial policy set. |
|
57 | - * |
|
58 | - * @var bool $_explicitPolicy |
|
59 | - */ |
|
60 | - protected $_explicitPolicy; |
|
54 | + /** |
|
55 | + * Whether the path must be valid for at least one policy in the |
|
56 | + * initial policy set. |
|
57 | + * |
|
58 | + * @var bool $_explicitPolicy |
|
59 | + */ |
|
60 | + protected $_explicitPolicy; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Whether anyPolicy OID processing should be inhibited. |
|
64 | - * |
|
65 | - * Setting this to true disallows the usage of anyPolicy. |
|
66 | - * |
|
67 | - * @var bool $_anyPolicyInhibit |
|
68 | - */ |
|
69 | - protected $_anyPolicyInhibit; |
|
62 | + /** |
|
63 | + * Whether anyPolicy OID processing should be inhibited. |
|
64 | + * |
|
65 | + * Setting this to true disallows the usage of anyPolicy. |
|
66 | + * |
|
67 | + * @var bool $_anyPolicyInhibit |
|
68 | + */ |
|
69 | + protected $_anyPolicyInhibit; |
|
70 | 70 | |
71 | - /** |
|
72 | - * |
|
73 | - * @todo Implement |
|
74 | - * @var mixed $_permittedSubtrees |
|
75 | - */ |
|
76 | - protected $_permittedSubtrees; |
|
71 | + /** |
|
72 | + * |
|
73 | + * @todo Implement |
|
74 | + * @var mixed $_permittedSubtrees |
|
75 | + */ |
|
76 | + protected $_permittedSubtrees; |
|
77 | 77 | |
78 | - /** |
|
79 | - * |
|
80 | - * @todo Implement |
|
81 | - * @var mixed $_excludedSubtrees |
|
82 | - */ |
|
83 | - protected $_excludedSubtrees; |
|
78 | + /** |
|
79 | + * |
|
80 | + * @todo Implement |
|
81 | + * @var mixed $_excludedSubtrees |
|
82 | + */ |
|
83 | + protected $_excludedSubtrees; |
|
84 | 84 | |
85 | - /** |
|
86 | - * Constructor. |
|
87 | - * |
|
88 | - * @param \DateTimeImmutable $dt Reference date and time |
|
89 | - * @param int $max_length Maximum certification path length |
|
90 | - */ |
|
91 | - public function __construct(\DateTimeImmutable $dt, $max_length) |
|
92 | - { |
|
93 | - $this->_dateTime = $dt; |
|
94 | - $this->_maxLength = (int) $max_length; |
|
95 | - $this->_policySet = array((string) PolicyInformation::OID_ANY_POLICY); |
|
96 | - $this->_policyMappingInhibit = false; |
|
97 | - $this->_explicitPolicy = false; |
|
98 | - $this->_anyPolicyInhibit = false; |
|
99 | - } |
|
85 | + /** |
|
86 | + * Constructor. |
|
87 | + * |
|
88 | + * @param \DateTimeImmutable $dt Reference date and time |
|
89 | + * @param int $max_length Maximum certification path length |
|
90 | + */ |
|
91 | + public function __construct(\DateTimeImmutable $dt, $max_length) |
|
92 | + { |
|
93 | + $this->_dateTime = $dt; |
|
94 | + $this->_maxLength = (int) $max_length; |
|
95 | + $this->_policySet = array((string) PolicyInformation::OID_ANY_POLICY); |
|
96 | + $this->_policyMappingInhibit = false; |
|
97 | + $this->_explicitPolicy = false; |
|
98 | + $this->_anyPolicyInhibit = false; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get default configuration. |
|
103 | - * |
|
104 | - * @return self |
|
105 | - */ |
|
106 | - public static function defaultConfig() |
|
107 | - { |
|
108 | - return new self(new \DateTimeImmutable(), 3); |
|
109 | - } |
|
101 | + /** |
|
102 | + * Get default configuration. |
|
103 | + * |
|
104 | + * @return self |
|
105 | + */ |
|
106 | + public static function defaultConfig() |
|
107 | + { |
|
108 | + return new self(new \DateTimeImmutable(), 3); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Get self with maximum path length. |
|
113 | - * |
|
114 | - * @param int $length |
|
115 | - * @return self |
|
116 | - */ |
|
117 | - public function withMaxLength($length) |
|
118 | - { |
|
119 | - $obj = clone $this; |
|
120 | - $obj->_maxLength = $length; |
|
121 | - return $obj; |
|
122 | - } |
|
111 | + /** |
|
112 | + * Get self with maximum path length. |
|
113 | + * |
|
114 | + * @param int $length |
|
115 | + * @return self |
|
116 | + */ |
|
117 | + public function withMaxLength($length) |
|
118 | + { |
|
119 | + $obj = clone $this; |
|
120 | + $obj->_maxLength = $length; |
|
121 | + return $obj; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Get self with reference date and time. |
|
126 | - * |
|
127 | - * @param \DateTimeImmutable $dt |
|
128 | - * @return self |
|
129 | - */ |
|
130 | - public function withDateTime(\DateTimeImmutable $dt) |
|
131 | - { |
|
132 | - $obj = clone $this; |
|
133 | - $obj->_dateTime = $dt; |
|
134 | - return $obj; |
|
135 | - } |
|
124 | + /** |
|
125 | + * Get self with reference date and time. |
|
126 | + * |
|
127 | + * @param \DateTimeImmutable $dt |
|
128 | + * @return self |
|
129 | + */ |
|
130 | + public function withDateTime(\DateTimeImmutable $dt) |
|
131 | + { |
|
132 | + $obj = clone $this; |
|
133 | + $obj->_dateTime = $dt; |
|
134 | + return $obj; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Get self with trust anchor certificate. |
|
139 | - * |
|
140 | - * @param Certificate $ca |
|
141 | - * @return self |
|
142 | - */ |
|
143 | - public function withTrustAnchor(Certificate $ca) |
|
144 | - { |
|
145 | - $obj = clone $this; |
|
146 | - $obj->_trustAnchor = $ca; |
|
147 | - return $obj; |
|
148 | - } |
|
137 | + /** |
|
138 | + * Get self with trust anchor certificate. |
|
139 | + * |
|
140 | + * @param Certificate $ca |
|
141 | + * @return self |
|
142 | + */ |
|
143 | + public function withTrustAnchor(Certificate $ca) |
|
144 | + { |
|
145 | + $obj = clone $this; |
|
146 | + $obj->_trustAnchor = $ca; |
|
147 | + return $obj; |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Get self with initial-policy-mapping-inhibit set. |
|
152 | - * |
|
153 | - * @param bool $flag |
|
154 | - * @return self |
|
155 | - */ |
|
156 | - public function withPolicyMappingInhibit($flag) |
|
157 | - { |
|
158 | - $obj = clone $this; |
|
159 | - $obj->_policyMappingInhibit = (bool) $flag; |
|
160 | - return $obj; |
|
161 | - } |
|
150 | + /** |
|
151 | + * Get self with initial-policy-mapping-inhibit set. |
|
152 | + * |
|
153 | + * @param bool $flag |
|
154 | + * @return self |
|
155 | + */ |
|
156 | + public function withPolicyMappingInhibit($flag) |
|
157 | + { |
|
158 | + $obj = clone $this; |
|
159 | + $obj->_policyMappingInhibit = (bool) $flag; |
|
160 | + return $obj; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * Get self with initial-explicit-policy set. |
|
165 | - * |
|
166 | - * @param bool $flag |
|
167 | - * @return self |
|
168 | - */ |
|
169 | - public function withExplicitPolicy($flag) |
|
170 | - { |
|
171 | - $obj = clone $this; |
|
172 | - $obj->_explicitPolicy = (bool) $flag; |
|
173 | - return $obj; |
|
174 | - } |
|
163 | + /** |
|
164 | + * Get self with initial-explicit-policy set. |
|
165 | + * |
|
166 | + * @param bool $flag |
|
167 | + * @return self |
|
168 | + */ |
|
169 | + public function withExplicitPolicy($flag) |
|
170 | + { |
|
171 | + $obj = clone $this; |
|
172 | + $obj->_explicitPolicy = (bool) $flag; |
|
173 | + return $obj; |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * Get self with initial-any-policy-inhibit set. |
|
178 | - * |
|
179 | - * @param bool $flag |
|
180 | - * @return self |
|
181 | - */ |
|
182 | - public function withAnyPolicyInhibit($flag) |
|
183 | - { |
|
184 | - $obj = clone $this; |
|
185 | - $obj->_anyPolicyInhibit = (bool) $flag; |
|
186 | - return $obj; |
|
187 | - } |
|
176 | + /** |
|
177 | + * Get self with initial-any-policy-inhibit set. |
|
178 | + * |
|
179 | + * @param bool $flag |
|
180 | + * @return self |
|
181 | + */ |
|
182 | + public function withAnyPolicyInhibit($flag) |
|
183 | + { |
|
184 | + $obj = clone $this; |
|
185 | + $obj->_anyPolicyInhibit = (bool) $flag; |
|
186 | + return $obj; |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Get self with user-initial-policy-set set to policy OIDs. |
|
191 | - * |
|
192 | - * @param string ...$policies List of policy OIDs |
|
193 | - * @return self |
|
194 | - */ |
|
195 | - public function withPolicySet(...$policies) |
|
196 | - { |
|
197 | - $obj = clone $this; |
|
198 | - $obj->_policySet = $policies; |
|
199 | - return $obj; |
|
200 | - } |
|
189 | + /** |
|
190 | + * Get self with user-initial-policy-set set to policy OIDs. |
|
191 | + * |
|
192 | + * @param string ...$policies List of policy OIDs |
|
193 | + * @return self |
|
194 | + */ |
|
195 | + public function withPolicySet(...$policies) |
|
196 | + { |
|
197 | + $obj = clone $this; |
|
198 | + $obj->_policySet = $policies; |
|
199 | + return $obj; |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * Get maximum certification path length. |
|
204 | - * |
|
205 | - * @return int |
|
206 | - */ |
|
207 | - public function maxLength() |
|
208 | - { |
|
209 | - return $this->_maxLength; |
|
210 | - } |
|
202 | + /** |
|
203 | + * Get maximum certification path length. |
|
204 | + * |
|
205 | + * @return int |
|
206 | + */ |
|
207 | + public function maxLength() |
|
208 | + { |
|
209 | + return $this->_maxLength; |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * Get reference date and time. |
|
214 | - * |
|
215 | - * @return \DateTimeImmutable |
|
216 | - */ |
|
217 | - public function dateTime() |
|
218 | - { |
|
219 | - return $this->_dateTime; |
|
220 | - } |
|
212 | + /** |
|
213 | + * Get reference date and time. |
|
214 | + * |
|
215 | + * @return \DateTimeImmutable |
|
216 | + */ |
|
217 | + public function dateTime() |
|
218 | + { |
|
219 | + return $this->_dateTime; |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Get user-initial-policy-set. |
|
224 | - * |
|
225 | - * @return string[] Array of OID's |
|
226 | - */ |
|
227 | - public function policySet() |
|
228 | - { |
|
229 | - return $this->_policySet; |
|
230 | - } |
|
222 | + /** |
|
223 | + * Get user-initial-policy-set. |
|
224 | + * |
|
225 | + * @return string[] Array of OID's |
|
226 | + */ |
|
227 | + public function policySet() |
|
228 | + { |
|
229 | + return $this->_policySet; |
|
230 | + } |
|
231 | 231 | |
232 | - /** |
|
233 | - * Check whether trust anchor certificate is set. |
|
234 | - * |
|
235 | - * @return bool |
|
236 | - */ |
|
237 | - public function hasTrustAnchor() |
|
238 | - { |
|
239 | - return isset($this->_trustAnchor); |
|
240 | - } |
|
232 | + /** |
|
233 | + * Check whether trust anchor certificate is set. |
|
234 | + * |
|
235 | + * @return bool |
|
236 | + */ |
|
237 | + public function hasTrustAnchor() |
|
238 | + { |
|
239 | + return isset($this->_trustAnchor); |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * Get trust anchor certificate. |
|
244 | - * |
|
245 | - * @throws \LogicException |
|
246 | - * @return Certificate |
|
247 | - */ |
|
248 | - public function trustAnchor() |
|
249 | - { |
|
250 | - if (!$this->hasTrustAnchor()) { |
|
251 | - throw new \LogicException("No trust anchor."); |
|
252 | - } |
|
253 | - return $this->_trustAnchor; |
|
254 | - } |
|
242 | + /** |
|
243 | + * Get trust anchor certificate. |
|
244 | + * |
|
245 | + * @throws \LogicException |
|
246 | + * @return Certificate |
|
247 | + */ |
|
248 | + public function trustAnchor() |
|
249 | + { |
|
250 | + if (!$this->hasTrustAnchor()) { |
|
251 | + throw new \LogicException("No trust anchor."); |
|
252 | + } |
|
253 | + return $this->_trustAnchor; |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Get initial-policy-mapping-inhibit. |
|
258 | - * |
|
259 | - * @return bool |
|
260 | - */ |
|
261 | - public function policyMappingInhibit() |
|
262 | - { |
|
263 | - return $this->_policyMappingInhibit; |
|
264 | - } |
|
256 | + /** |
|
257 | + * Get initial-policy-mapping-inhibit. |
|
258 | + * |
|
259 | + * @return bool |
|
260 | + */ |
|
261 | + public function policyMappingInhibit() |
|
262 | + { |
|
263 | + return $this->_policyMappingInhibit; |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Get initial-explicit-policy. |
|
268 | - * |
|
269 | - * @return bool |
|
270 | - */ |
|
271 | - public function explicitPolicy() |
|
272 | - { |
|
273 | - return $this->_explicitPolicy; |
|
274 | - } |
|
266 | + /** |
|
267 | + * Get initial-explicit-policy. |
|
268 | + * |
|
269 | + * @return bool |
|
270 | + */ |
|
271 | + public function explicitPolicy() |
|
272 | + { |
|
273 | + return $this->_explicitPolicy; |
|
274 | + } |
|
275 | 275 | |
276 | - /** |
|
277 | - * Get initial-any-policy-inhibit. |
|
278 | - * |
|
279 | - * @return bool |
|
280 | - */ |
|
281 | - public function anyPolicyInhibit() |
|
282 | - { |
|
283 | - return $this->_anyPolicyInhibit; |
|
284 | - } |
|
276 | + /** |
|
277 | + * Get initial-any-policy-inhibit. |
|
278 | + * |
|
279 | + * @return bool |
|
280 | + */ |
|
281 | + public function anyPolicyInhibit() |
|
282 | + { |
|
283 | + return $this->_anyPolicyInhibit; |
|
284 | + } |
|
285 | 285 | } |