@@ -15,170 +15,170 @@ |
||
15 | 15 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.5 |
16 | 16 | */ |
17 | 17 | class PolicyMappingsExtension extends Extension implements |
18 | - \Countable, |
|
19 | - \IteratorAggregate |
|
18 | + \Countable, |
|
19 | + \IteratorAggregate |
|
20 | 20 | { |
21 | - /** |
|
22 | - * Policy mappings. |
|
23 | - * |
|
24 | - * @var PolicyMapping[] $_mappings |
|
25 | - */ |
|
26 | - protected $_mappings; |
|
21 | + /** |
|
22 | + * Policy mappings. |
|
23 | + * |
|
24 | + * @var PolicyMapping[] $_mappings |
|
25 | + */ |
|
26 | + protected $_mappings; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Constructor. |
|
30 | - * |
|
31 | - * @param bool $critical |
|
32 | - * @param PolicyMapping[] $mappings One or more PolicyMapping objects |
|
33 | - */ |
|
34 | - public function __construct(bool $critical, PolicyMapping ...$mappings) |
|
35 | - { |
|
36 | - parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
37 | - $this->_mappings = $mappings; |
|
38 | - } |
|
28 | + /** |
|
29 | + * Constructor. |
|
30 | + * |
|
31 | + * @param bool $critical |
|
32 | + * @param PolicyMapping[] $mappings One or more PolicyMapping objects |
|
33 | + */ |
|
34 | + public function __construct(bool $critical, PolicyMapping ...$mappings) |
|
35 | + { |
|
36 | + parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
37 | + $this->_mappings = $mappings; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * |
|
42 | - * {@inheritdoc} |
|
43 | - * @return self |
|
44 | - */ |
|
45 | - protected static function _fromDER($data, $critical) |
|
46 | - { |
|
47 | - $mappings = array_map( |
|
48 | - function (UnspecifiedType $el) { |
|
49 | - return PolicyMapping::fromASN1($el->asSequence()); |
|
50 | - }, Sequence::fromDER($data)->elements()); |
|
51 | - if (!count($mappings)) { |
|
52 | - throw new \UnexpectedValueException( |
|
53 | - "PolicyMappings must have at least one mapping."); |
|
54 | - } |
|
55 | - return new self($critical, ...$mappings); |
|
56 | - } |
|
40 | + /** |
|
41 | + * |
|
42 | + * {@inheritdoc} |
|
43 | + * @return self |
|
44 | + */ |
|
45 | + protected static function _fromDER($data, $critical) |
|
46 | + { |
|
47 | + $mappings = array_map( |
|
48 | + function (UnspecifiedType $el) { |
|
49 | + return PolicyMapping::fromASN1($el->asSequence()); |
|
50 | + }, Sequence::fromDER($data)->elements()); |
|
51 | + if (!count($mappings)) { |
|
52 | + throw new \UnexpectedValueException( |
|
53 | + "PolicyMappings must have at least one mapping."); |
|
54 | + } |
|
55 | + return new self($critical, ...$mappings); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * |
|
60 | - * {@inheritdoc} |
|
61 | - * @return Sequence |
|
62 | - */ |
|
63 | - protected function _valueASN1(): Sequence |
|
64 | - { |
|
65 | - if (!count($this->_mappings)) { |
|
66 | - throw new \LogicException("No mappings."); |
|
67 | - } |
|
68 | - $elements = array_map( |
|
69 | - function (PolicyMapping $mapping) { |
|
70 | - return $mapping->toASN1(); |
|
71 | - }, $this->_mappings); |
|
72 | - return new Sequence(...$elements); |
|
73 | - } |
|
58 | + /** |
|
59 | + * |
|
60 | + * {@inheritdoc} |
|
61 | + * @return Sequence |
|
62 | + */ |
|
63 | + protected function _valueASN1(): Sequence |
|
64 | + { |
|
65 | + if (!count($this->_mappings)) { |
|
66 | + throw new \LogicException("No mappings."); |
|
67 | + } |
|
68 | + $elements = array_map( |
|
69 | + function (PolicyMapping $mapping) { |
|
70 | + return $mapping->toASN1(); |
|
71 | + }, $this->_mappings); |
|
72 | + return new Sequence(...$elements); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Get all mappings. |
|
77 | - * |
|
78 | - * @return PolicyMapping[] |
|
79 | - */ |
|
80 | - public function mappings(): array |
|
81 | - { |
|
82 | - return $this->_mappings; |
|
83 | - } |
|
75 | + /** |
|
76 | + * Get all mappings. |
|
77 | + * |
|
78 | + * @return PolicyMapping[] |
|
79 | + */ |
|
80 | + public function mappings(): array |
|
81 | + { |
|
82 | + return $this->_mappings; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Get mappings flattened into a single array of arrays of subject domains |
|
87 | - * keyed by issuer domain. |
|
88 | - * |
|
89 | - * Eg. if policy mappings contains multiple mappings with the same issuer |
|
90 | - * domain policy, their corresponding subject domain policies are placed |
|
91 | - * under the same key. |
|
92 | - * |
|
93 | - * @return (string[])[] |
|
94 | - */ |
|
95 | - public function flattenedMappings(): array |
|
96 | - { |
|
97 | - $mappings = array(); |
|
98 | - foreach ($this->_mappings as $mapping) { |
|
99 | - $idp = $mapping->issuerDomainPolicy(); |
|
100 | - if (!isset($mappings[$idp])) { |
|
101 | - $mappings[$idp] = array(); |
|
102 | - } |
|
103 | - array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
104 | - } |
|
105 | - return $mappings; |
|
106 | - } |
|
85 | + /** |
|
86 | + * Get mappings flattened into a single array of arrays of subject domains |
|
87 | + * keyed by issuer domain. |
|
88 | + * |
|
89 | + * Eg. if policy mappings contains multiple mappings with the same issuer |
|
90 | + * domain policy, their corresponding subject domain policies are placed |
|
91 | + * under the same key. |
|
92 | + * |
|
93 | + * @return (string[])[] |
|
94 | + */ |
|
95 | + public function flattenedMappings(): array |
|
96 | + { |
|
97 | + $mappings = array(); |
|
98 | + foreach ($this->_mappings as $mapping) { |
|
99 | + $idp = $mapping->issuerDomainPolicy(); |
|
100 | + if (!isset($mappings[$idp])) { |
|
101 | + $mappings[$idp] = array(); |
|
102 | + } |
|
103 | + array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
104 | + } |
|
105 | + return $mappings; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Get all subject domain policy OIDs that are mapped to given issuer |
|
110 | - * domain policy OID. |
|
111 | - * |
|
112 | - * @param string $oid Issuer domain policy |
|
113 | - * @return string[] List of OIDs in dotted format |
|
114 | - */ |
|
115 | - public function issuerMappings(string $oid): array |
|
116 | - { |
|
117 | - $oids = array(); |
|
118 | - foreach ($this->_mappings as $mapping) { |
|
119 | - if ($mapping->issuerDomainPolicy() == $oid) { |
|
120 | - $oids[] = $mapping->subjectDomainPolicy(); |
|
121 | - } |
|
122 | - } |
|
123 | - return $oids; |
|
124 | - } |
|
108 | + /** |
|
109 | + * Get all subject domain policy OIDs that are mapped to given issuer |
|
110 | + * domain policy OID. |
|
111 | + * |
|
112 | + * @param string $oid Issuer domain policy |
|
113 | + * @return string[] List of OIDs in dotted format |
|
114 | + */ |
|
115 | + public function issuerMappings(string $oid): array |
|
116 | + { |
|
117 | + $oids = array(); |
|
118 | + foreach ($this->_mappings as $mapping) { |
|
119 | + if ($mapping->issuerDomainPolicy() == $oid) { |
|
120 | + $oids[] = $mapping->subjectDomainPolicy(); |
|
121 | + } |
|
122 | + } |
|
123 | + return $oids; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Get all mapped issuer domain policy OIDs. |
|
128 | - * |
|
129 | - * @return string[] |
|
130 | - */ |
|
131 | - public function issuerDomainPolicies(): array |
|
132 | - { |
|
133 | - $idps = array_map( |
|
134 | - function (PolicyMapping $mapping) { |
|
135 | - return $mapping->issuerDomainPolicy(); |
|
136 | - }, $this->_mappings); |
|
137 | - return array_values(array_unique($idps)); |
|
138 | - } |
|
126 | + /** |
|
127 | + * Get all mapped issuer domain policy OIDs. |
|
128 | + * |
|
129 | + * @return string[] |
|
130 | + */ |
|
131 | + public function issuerDomainPolicies(): array |
|
132 | + { |
|
133 | + $idps = array_map( |
|
134 | + function (PolicyMapping $mapping) { |
|
135 | + return $mapping->issuerDomainPolicy(); |
|
136 | + }, $this->_mappings); |
|
137 | + return array_values(array_unique($idps)); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Check whether policy mappings have anyPolicy mapped. |
|
142 | - * |
|
143 | - * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
144 | - * to or from the special value anyPolicy". |
|
145 | - * |
|
146 | - * @return bool |
|
147 | - */ |
|
148 | - public function hasAnyPolicyMapping(): bool |
|
149 | - { |
|
150 | - foreach ($this->_mappings as $mapping) { |
|
151 | - if ($mapping->issuerDomainPolicy() == |
|
152 | - PolicyInformation::OID_ANY_POLICY) { |
|
153 | - return true; |
|
154 | - } |
|
155 | - if ($mapping->subjectDomainPolicy() == |
|
156 | - PolicyInformation::OID_ANY_POLICY) { |
|
157 | - return true; |
|
158 | - } |
|
159 | - } |
|
160 | - return false; |
|
161 | - } |
|
140 | + /** |
|
141 | + * Check whether policy mappings have anyPolicy mapped. |
|
142 | + * |
|
143 | + * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
144 | + * to or from the special value anyPolicy". |
|
145 | + * |
|
146 | + * @return bool |
|
147 | + */ |
|
148 | + public function hasAnyPolicyMapping(): bool |
|
149 | + { |
|
150 | + foreach ($this->_mappings as $mapping) { |
|
151 | + if ($mapping->issuerDomainPolicy() == |
|
152 | + PolicyInformation::OID_ANY_POLICY) { |
|
153 | + return true; |
|
154 | + } |
|
155 | + if ($mapping->subjectDomainPolicy() == |
|
156 | + PolicyInformation::OID_ANY_POLICY) { |
|
157 | + return true; |
|
158 | + } |
|
159 | + } |
|
160 | + return false; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * Get the number of mappings. |
|
165 | - * |
|
166 | - * @see \Countable::count() |
|
167 | - * @return int |
|
168 | - */ |
|
169 | - public function count(): int |
|
170 | - { |
|
171 | - return count($this->_mappings); |
|
172 | - } |
|
163 | + /** |
|
164 | + * Get the number of mappings. |
|
165 | + * |
|
166 | + * @see \Countable::count() |
|
167 | + * @return int |
|
168 | + */ |
|
169 | + public function count(): int |
|
170 | + { |
|
171 | + return count($this->_mappings); |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * Get iterator for policy mappings. |
|
176 | - * |
|
177 | - * @see \IteratorAggregate::getIterator() |
|
178 | - * @return \ArrayIterator |
|
179 | - */ |
|
180 | - public function getIterator(): \ArrayIterator |
|
181 | - { |
|
182 | - return new \ArrayIterator($this->_mappings); |
|
183 | - } |
|
174 | + /** |
|
175 | + * Get iterator for policy mappings. |
|
176 | + * |
|
177 | + * @see \IteratorAggregate::getIterator() |
|
178 | + * @return \ArrayIterator |
|
179 | + */ |
|
180 | + public function getIterator(): \ArrayIterator |
|
181 | + { |
|
182 | + return new \ArrayIterator($this->_mappings); |
|
183 | + } |
|
184 | 184 | } |
@@ -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 | $mappings = array_map( |
48 | - function (UnspecifiedType $el) { |
|
48 | + function(UnspecifiedType $el) { |
|
49 | 49 | return PolicyMapping::fromASN1($el->asSequence()); |
50 | 50 | }, Sequence::fromDER($data)->elements()); |
51 | 51 | if (!count($mappings)) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | throw new \LogicException("No mappings."); |
67 | 67 | } |
68 | 68 | $elements = array_map( |
69 | - function (PolicyMapping $mapping) { |
|
69 | + function(PolicyMapping $mapping) { |
|
70 | 70 | return $mapping->toASN1(); |
71 | 71 | }, $this->_mappings); |
72 | 72 | return new Sequence(...$elements); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public function issuerDomainPolicies(): array |
132 | 132 | { |
133 | 133 | $idps = array_map( |
134 | - function (PolicyMapping $mapping) { |
|
134 | + function(PolicyMapping $mapping) { |
|
135 | 135 | return $mapping->issuerDomainPolicy(); |
136 | 136 | }, $this->_mappings); |
137 | 137 | return array_values(array_unique($idps)); |
@@ -14,53 +14,53 @@ |
||
14 | 14 | */ |
15 | 15 | class IssuerAlternativeNameExtension extends Extension |
16 | 16 | { |
17 | - /** |
|
18 | - * Names. |
|
19 | - * |
|
20 | - * @var GeneralNames |
|
21 | - */ |
|
22 | - protected $_names; |
|
17 | + /** |
|
18 | + * Names. |
|
19 | + * |
|
20 | + * @var GeneralNames |
|
21 | + */ |
|
22 | + protected $_names; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor. |
|
26 | - * |
|
27 | - * @param bool $critical |
|
28 | - * @param GeneralNames $names |
|
29 | - */ |
|
30 | - public function __construct(bool $critical, GeneralNames $names) |
|
31 | - { |
|
32 | - parent::__construct(self::OID_ISSUER_ALT_NAME, $critical); |
|
33 | - $this->_names = $names; |
|
34 | - } |
|
24 | + /** |
|
25 | + * Constructor. |
|
26 | + * |
|
27 | + * @param bool $critical |
|
28 | + * @param GeneralNames $names |
|
29 | + */ |
|
30 | + public function __construct(bool $critical, GeneralNames $names) |
|
31 | + { |
|
32 | + parent::__construct(self::OID_ISSUER_ALT_NAME, $critical); |
|
33 | + $this->_names = $names; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * |
|
38 | - * {@inheritdoc} |
|
39 | - * @return self |
|
40 | - */ |
|
41 | - protected static function _fromDER($data, $critical) |
|
42 | - { |
|
43 | - return new self($critical, |
|
44 | - GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
45 | - } |
|
36 | + /** |
|
37 | + * |
|
38 | + * {@inheritdoc} |
|
39 | + * @return self |
|
40 | + */ |
|
41 | + protected static function _fromDER($data, $critical) |
|
42 | + { |
|
43 | + return new self($critical, |
|
44 | + GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get names. |
|
49 | - * |
|
50 | - * @return GeneralNames |
|
51 | - */ |
|
52 | - public function names(): GeneralNames |
|
53 | - { |
|
54 | - return $this->_names; |
|
55 | - } |
|
47 | + /** |
|
48 | + * Get names. |
|
49 | + * |
|
50 | + * @return GeneralNames |
|
51 | + */ |
|
52 | + public function names(): GeneralNames |
|
53 | + { |
|
54 | + return $this->_names; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * |
|
59 | - * {@inheritdoc} |
|
60 | - * @return Sequence |
|
61 | - */ |
|
62 | - protected function _valueASN1(): Sequence |
|
63 | - { |
|
64 | - return $this->_names->toASN1(); |
|
65 | - } |
|
57 | + /** |
|
58 | + * |
|
59 | + * {@inheritdoc} |
|
60 | + * @return Sequence |
|
61 | + */ |
|
62 | + protected function _valueASN1(): Sequence |
|
63 | + { |
|
64 | + return $this->_names->toASN1(); |
|
65 | + } |
|
66 | 66 | } |
@@ -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 |
@@ -11,32 +11,32 @@ |
||
11 | 11 | */ |
12 | 12 | class UnknownExtension extends Extension |
13 | 13 | { |
14 | - /** |
|
15 | - * Extension value. |
|
16 | - * |
|
17 | - * @var Element $_element |
|
18 | - */ |
|
19 | - protected $_element; |
|
14 | + /** |
|
15 | + * Extension value. |
|
16 | + * |
|
17 | + * @var Element $_element |
|
18 | + */ |
|
19 | + protected $_element; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Constructor. |
|
23 | - * |
|
24 | - * @param string $oid |
|
25 | - * @param bool $critical |
|
26 | - * @param Element $data |
|
27 | - */ |
|
28 | - public function __construct(string $oid, bool $critical, Element $data) |
|
29 | - { |
|
30 | - parent::__construct($oid, $critical); |
|
31 | - $this->_element = $data; |
|
32 | - } |
|
21 | + /** |
|
22 | + * Constructor. |
|
23 | + * |
|
24 | + * @param string $oid |
|
25 | + * @param bool $critical |
|
26 | + * @param Element $data |
|
27 | + */ |
|
28 | + public function __construct(string $oid, bool $critical, Element $data) |
|
29 | + { |
|
30 | + parent::__construct($oid, $critical); |
|
31 | + $this->_element = $data; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * {@inheritdoc} |
|
37 | - */ |
|
38 | - protected function _valueASN1() |
|
39 | - { |
|
40 | - return $this->_element; |
|
41 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * {@inheritdoc} |
|
37 | + */ |
|
38 | + protected function _valueASN1() |
|
39 | + { |
|
40 | + return $this->_element; |
|
41 | + } |
|
42 | 42 | } |
@@ -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 |
@@ -13,52 +13,52 @@ |
||
13 | 13 | */ |
14 | 14 | class SubjectKeyIdentifierExtension extends Extension |
15 | 15 | { |
16 | - /** |
|
17 | - * Key identifier. |
|
18 | - * |
|
19 | - * @var string $_keyIdentifier |
|
20 | - */ |
|
21 | - protected $_keyIdentifier; |
|
16 | + /** |
|
17 | + * Key identifier. |
|
18 | + * |
|
19 | + * @var string $_keyIdentifier |
|
20 | + */ |
|
21 | + protected $_keyIdentifier; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor. |
|
25 | - * |
|
26 | - * @param bool $critical |
|
27 | - * @param string $keyIdentifier |
|
28 | - */ |
|
29 | - public function __construct(bool $critical, string $keyIdentifier) |
|
30 | - { |
|
31 | - parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
|
32 | - $this->_keyIdentifier = $keyIdentifier; |
|
33 | - } |
|
23 | + /** |
|
24 | + * Constructor. |
|
25 | + * |
|
26 | + * @param bool $critical |
|
27 | + * @param string $keyIdentifier |
|
28 | + */ |
|
29 | + public function __construct(bool $critical, string $keyIdentifier) |
|
30 | + { |
|
31 | + parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
|
32 | + $this->_keyIdentifier = $keyIdentifier; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * |
|
37 | - * {@inheritdoc} |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - protected static function _fromDER($data, $critical) |
|
41 | - { |
|
42 | - return new self($critical, OctetString::fromDER($data)->string()); |
|
43 | - } |
|
35 | + /** |
|
36 | + * |
|
37 | + * {@inheritdoc} |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + protected static function _fromDER($data, $critical) |
|
41 | + { |
|
42 | + return new self($critical, OctetString::fromDER($data)->string()); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get key identifier. |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function keyIdentifier(): string |
|
51 | - { |
|
52 | - return $this->_keyIdentifier; |
|
53 | - } |
|
45 | + /** |
|
46 | + * Get key identifier. |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function keyIdentifier(): string |
|
51 | + { |
|
52 | + return $this->_keyIdentifier; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * |
|
57 | - * {@inheritdoc} |
|
58 | - * @return OctetString |
|
59 | - */ |
|
60 | - protected function _valueASN1(): OctetString |
|
61 | - { |
|
62 | - return new OctetString($this->_keyIdentifier); |
|
63 | - } |
|
55 | + /** |
|
56 | + * |
|
57 | + * {@inheritdoc} |
|
58 | + * @return OctetString |
|
59 | + */ |
|
60 | + protected function _valueASN1(): OctetString |
|
61 | + { |
|
62 | + return new OctetString($this->_keyIdentifier); |
|
63 | + } |
|
64 | 64 | } |
@@ -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 |
@@ -13,51 +13,51 @@ |
||
13 | 13 | */ |
14 | 14 | class InhibitAnyPolicyExtension extends Extension |
15 | 15 | { |
16 | - /** |
|
17 | - * |
|
18 | - * @var int $_skipCerts |
|
19 | - */ |
|
20 | - protected $_skipCerts; |
|
16 | + /** |
|
17 | + * |
|
18 | + * @var int $_skipCerts |
|
19 | + */ |
|
20 | + protected $_skipCerts; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Constructor. |
|
24 | - * |
|
25 | - * @param bool $critical |
|
26 | - * @param int $skip_certs |
|
27 | - */ |
|
28 | - public function __construct(bool $critical, $skip_certs) |
|
29 | - { |
|
30 | - parent::__construct(self::OID_INHIBIT_ANY_POLICY, $critical); |
|
31 | - $this->_skipCerts = $skip_certs; |
|
32 | - } |
|
22 | + /** |
|
23 | + * Constructor. |
|
24 | + * |
|
25 | + * @param bool $critical |
|
26 | + * @param int $skip_certs |
|
27 | + */ |
|
28 | + public function __construct(bool $critical, $skip_certs) |
|
29 | + { |
|
30 | + parent::__construct(self::OID_INHIBIT_ANY_POLICY, $critical); |
|
31 | + $this->_skipCerts = $skip_certs; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * {@inheritdoc} |
|
37 | - * @return self |
|
38 | - */ |
|
39 | - protected static function _fromDER($data, $critical) |
|
40 | - { |
|
41 | - return new self($critical, Integer::fromDER($data)->number()); |
|
42 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * {@inheritdoc} |
|
37 | + * @return self |
|
38 | + */ |
|
39 | + protected static function _fromDER($data, $critical) |
|
40 | + { |
|
41 | + return new self($critical, Integer::fromDER($data)->number()); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get value. |
|
46 | - * |
|
47 | - * @return int |
|
48 | - */ |
|
49 | - public function skipCerts() |
|
50 | - { |
|
51 | - return $this->_skipCerts; |
|
52 | - } |
|
44 | + /** |
|
45 | + * Get value. |
|
46 | + * |
|
47 | + * @return int |
|
48 | + */ |
|
49 | + public function skipCerts() |
|
50 | + { |
|
51 | + return $this->_skipCerts; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * |
|
56 | - * {@inheritdoc} |
|
57 | - * @return Integer |
|
58 | - */ |
|
59 | - protected function _valueASN1(): \ASN1\Type\Primitive\Integer |
|
60 | - { |
|
61 | - return new Integer($this->_skipCerts); |
|
62 | - } |
|
54 | + /** |
|
55 | + * |
|
56 | + * {@inheritdoc} |
|
57 | + * @return Integer |
|
58 | + */ |
|
59 | + protected function _valueASN1(): \ASN1\Type\Primitive\Integer |
|
60 | + { |
|
61 | + return new Integer($this->_skipCerts); |
|
62 | + } |
|
63 | 63 | } |
@@ -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 |
@@ -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)); |
@@ -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); |
@@ -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 |