@@ -13,170 +13,170 @@ |
||
13 | 13 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.5 |
14 | 14 | */ |
15 | 15 | class PolicyMappingsExtension extends Extension implements |
16 | - \Countable, |
|
17 | - \IteratorAggregate |
|
16 | + \Countable, |
|
17 | + \IteratorAggregate |
|
18 | 18 | { |
19 | - /** |
|
20 | - * Policy mappings. |
|
21 | - * |
|
22 | - * @var PolicyMapping[] $_mappings |
|
23 | - */ |
|
24 | - protected $_mappings; |
|
19 | + /** |
|
20 | + * Policy mappings. |
|
21 | + * |
|
22 | + * @var PolicyMapping[] $_mappings |
|
23 | + */ |
|
24 | + protected $_mappings; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param bool $critical |
|
30 | - * @param PolicyMapping ...$mappings One or more PolicyMapping objects |
|
31 | - */ |
|
32 | - public function __construct($critical, PolicyMapping ...$mappings) |
|
33 | - { |
|
34 | - parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
35 | - $this->_mappings = $mappings; |
|
36 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param bool $critical |
|
30 | + * @param PolicyMapping ...$mappings One or more PolicyMapping objects |
|
31 | + */ |
|
32 | + public function __construct($critical, PolicyMapping ...$mappings) |
|
33 | + { |
|
34 | + parent::__construct(self::OID_POLICY_MAPPINGS, $critical); |
|
35 | + $this->_mappings = $mappings; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * |
|
40 | - * {@inheritdoc} |
|
41 | - * @return self |
|
42 | - */ |
|
43 | - protected static function _fromDER($data, $critical) |
|
44 | - { |
|
45 | - $mappings = array_map( |
|
46 | - function (UnspecifiedType $el) { |
|
47 | - return PolicyMapping::fromASN1($el->asSequence()); |
|
48 | - }, Sequence::fromDER($data)->elements()); |
|
49 | - if (!count($mappings)) { |
|
50 | - throw new \UnexpectedValueException( |
|
51 | - "PolicyMappings must have at least one mapping."); |
|
52 | - } |
|
53 | - return new self($critical, ...$mappings); |
|
54 | - } |
|
38 | + /** |
|
39 | + * |
|
40 | + * {@inheritdoc} |
|
41 | + * @return self |
|
42 | + */ |
|
43 | + protected static function _fromDER($data, $critical) |
|
44 | + { |
|
45 | + $mappings = array_map( |
|
46 | + function (UnspecifiedType $el) { |
|
47 | + return PolicyMapping::fromASN1($el->asSequence()); |
|
48 | + }, Sequence::fromDER($data)->elements()); |
|
49 | + if (!count($mappings)) { |
|
50 | + throw new \UnexpectedValueException( |
|
51 | + "PolicyMappings must have at least one mapping."); |
|
52 | + } |
|
53 | + return new self($critical, ...$mappings); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * |
|
58 | - * {@inheritdoc} |
|
59 | - * @return Sequence |
|
60 | - */ |
|
61 | - protected function _valueASN1() |
|
62 | - { |
|
63 | - if (!count($this->_mappings)) { |
|
64 | - throw new \LogicException("No mappings."); |
|
65 | - } |
|
66 | - $elements = array_map( |
|
67 | - function (PolicyMapping $mapping) { |
|
68 | - return $mapping->toASN1(); |
|
69 | - }, $this->_mappings); |
|
70 | - return new Sequence(...$elements); |
|
71 | - } |
|
56 | + /** |
|
57 | + * |
|
58 | + * {@inheritdoc} |
|
59 | + * @return Sequence |
|
60 | + */ |
|
61 | + protected function _valueASN1() |
|
62 | + { |
|
63 | + if (!count($this->_mappings)) { |
|
64 | + throw new \LogicException("No mappings."); |
|
65 | + } |
|
66 | + $elements = array_map( |
|
67 | + function (PolicyMapping $mapping) { |
|
68 | + return $mapping->toASN1(); |
|
69 | + }, $this->_mappings); |
|
70 | + return new Sequence(...$elements); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Get all mappings. |
|
75 | - * |
|
76 | - * @return PolicyMapping[] |
|
77 | - */ |
|
78 | - public function mappings() |
|
79 | - { |
|
80 | - return $this->_mappings; |
|
81 | - } |
|
73 | + /** |
|
74 | + * Get all mappings. |
|
75 | + * |
|
76 | + * @return PolicyMapping[] |
|
77 | + */ |
|
78 | + public function mappings() |
|
79 | + { |
|
80 | + return $this->_mappings; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Get mappings flattened into a single array of arrays of subject domains |
|
85 | - * keyed by issuer domain. |
|
86 | - * |
|
87 | - * Eg. if policy mappings contains multiple mappings with the same issuer |
|
88 | - * domain policy, their corresponding subject domain policies are placed |
|
89 | - * under the same key. |
|
90 | - * |
|
91 | - * @return (string[])[] |
|
92 | - */ |
|
93 | - public function flattenedMappings() |
|
94 | - { |
|
95 | - $mappings = array(); |
|
96 | - foreach ($this->_mappings as $mapping) { |
|
97 | - $idp = $mapping->issuerDomainPolicy(); |
|
98 | - if (!isset($mappings[$idp])) { |
|
99 | - $mappings[$idp] = array(); |
|
100 | - } |
|
101 | - array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
102 | - } |
|
103 | - return $mappings; |
|
104 | - } |
|
83 | + /** |
|
84 | + * Get mappings flattened into a single array of arrays of subject domains |
|
85 | + * keyed by issuer domain. |
|
86 | + * |
|
87 | + * Eg. if policy mappings contains multiple mappings with the same issuer |
|
88 | + * domain policy, their corresponding subject domain policies are placed |
|
89 | + * under the same key. |
|
90 | + * |
|
91 | + * @return (string[])[] |
|
92 | + */ |
|
93 | + public function flattenedMappings() |
|
94 | + { |
|
95 | + $mappings = array(); |
|
96 | + foreach ($this->_mappings as $mapping) { |
|
97 | + $idp = $mapping->issuerDomainPolicy(); |
|
98 | + if (!isset($mappings[$idp])) { |
|
99 | + $mappings[$idp] = array(); |
|
100 | + } |
|
101 | + array_push($mappings[$idp], $mapping->subjectDomainPolicy()); |
|
102 | + } |
|
103 | + return $mappings; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Get all subject domain policy OIDs that are mapped to given issuer |
|
108 | - * domain policy OID. |
|
109 | - * |
|
110 | - * @param string $oid Issuer domain policy |
|
111 | - * @return string[] List of OIDs in dotted format |
|
112 | - */ |
|
113 | - public function issuerMappings($oid) |
|
114 | - { |
|
115 | - $oids = array(); |
|
116 | - foreach ($this->_mappings as $mapping) { |
|
117 | - if ($mapping->issuerDomainPolicy() == $oid) { |
|
118 | - $oids[] = $mapping->subjectDomainPolicy(); |
|
119 | - } |
|
120 | - } |
|
121 | - return $oids; |
|
122 | - } |
|
106 | + /** |
|
107 | + * Get all subject domain policy OIDs that are mapped to given issuer |
|
108 | + * domain policy OID. |
|
109 | + * |
|
110 | + * @param string $oid Issuer domain policy |
|
111 | + * @return string[] List of OIDs in dotted format |
|
112 | + */ |
|
113 | + public function issuerMappings($oid) |
|
114 | + { |
|
115 | + $oids = array(); |
|
116 | + foreach ($this->_mappings as $mapping) { |
|
117 | + if ($mapping->issuerDomainPolicy() == $oid) { |
|
118 | + $oids[] = $mapping->subjectDomainPolicy(); |
|
119 | + } |
|
120 | + } |
|
121 | + return $oids; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Get all mapped issuer domain policy OIDs. |
|
126 | - * |
|
127 | - * @return string[] |
|
128 | - */ |
|
129 | - public function issuerDomainPolicies() |
|
130 | - { |
|
131 | - $idps = array_map( |
|
132 | - function (PolicyMapping $mapping) { |
|
133 | - return $mapping->issuerDomainPolicy(); |
|
134 | - }, $this->_mappings); |
|
135 | - return array_values(array_unique($idps)); |
|
136 | - } |
|
124 | + /** |
|
125 | + * Get all mapped issuer domain policy OIDs. |
|
126 | + * |
|
127 | + * @return string[] |
|
128 | + */ |
|
129 | + public function issuerDomainPolicies() |
|
130 | + { |
|
131 | + $idps = array_map( |
|
132 | + function (PolicyMapping $mapping) { |
|
133 | + return $mapping->issuerDomainPolicy(); |
|
134 | + }, $this->_mappings); |
|
135 | + return array_values(array_unique($idps)); |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Check whether policy mappings have anyPolicy mapped. |
|
140 | - * |
|
141 | - * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
142 | - * to or from the special value anyPolicy". |
|
143 | - * |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function hasAnyPolicyMapping() |
|
147 | - { |
|
148 | - foreach ($this->_mappings as $mapping) { |
|
149 | - if ($mapping->issuerDomainPolicy() == |
|
150 | - PolicyInformation::OID_ANY_POLICY) { |
|
151 | - return true; |
|
152 | - } |
|
153 | - if ($mapping->subjectDomainPolicy() == |
|
154 | - PolicyInformation::OID_ANY_POLICY) { |
|
155 | - return true; |
|
156 | - } |
|
157 | - } |
|
158 | - return false; |
|
159 | - } |
|
138 | + /** |
|
139 | + * Check whether policy mappings have anyPolicy mapped. |
|
140 | + * |
|
141 | + * RFC 5280 section 4.2.1.5 states that "Policies MUST NOT be mapped either |
|
142 | + * to or from the special value anyPolicy". |
|
143 | + * |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function hasAnyPolicyMapping() |
|
147 | + { |
|
148 | + foreach ($this->_mappings as $mapping) { |
|
149 | + if ($mapping->issuerDomainPolicy() == |
|
150 | + PolicyInformation::OID_ANY_POLICY) { |
|
151 | + return true; |
|
152 | + } |
|
153 | + if ($mapping->subjectDomainPolicy() == |
|
154 | + PolicyInformation::OID_ANY_POLICY) { |
|
155 | + return true; |
|
156 | + } |
|
157 | + } |
|
158 | + return false; |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * Get the number of mappings. |
|
163 | - * |
|
164 | - * @see \Countable::count() |
|
165 | - * @return int |
|
166 | - */ |
|
167 | - public function count() |
|
168 | - { |
|
169 | - return count($this->_mappings); |
|
170 | - } |
|
161 | + /** |
|
162 | + * Get the number of mappings. |
|
163 | + * |
|
164 | + * @see \Countable::count() |
|
165 | + * @return int |
|
166 | + */ |
|
167 | + public function count() |
|
168 | + { |
|
169 | + return count($this->_mappings); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Get iterator for policy mappings. |
|
174 | - * |
|
175 | - * @see \IteratorAggregate::getIterator() |
|
176 | - * @return \ArrayIterator |
|
177 | - */ |
|
178 | - public function getIterator() |
|
179 | - { |
|
180 | - return new \ArrayIterator($this->_mappings); |
|
181 | - } |
|
172 | + /** |
|
173 | + * Get iterator for policy mappings. |
|
174 | + * |
|
175 | + * @see \IteratorAggregate::getIterator() |
|
176 | + * @return \ArrayIterator |
|
177 | + */ |
|
178 | + public function getIterator() |
|
179 | + { |
|
180 | + return new \ArrayIterator($this->_mappings); |
|
181 | + } |
|
182 | 182 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | protected static function _fromDER($data, $critical) |
44 | 44 | { |
45 | 45 | $mappings = array_map( |
46 | - function (UnspecifiedType $el) { |
|
46 | + function(UnspecifiedType $el) { |
|
47 | 47 | return PolicyMapping::fromASN1($el->asSequence()); |
48 | 48 | }, Sequence::fromDER($data)->elements()); |
49 | 49 | if (!count($mappings)) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | throw new \LogicException("No mappings."); |
65 | 65 | } |
66 | 66 | $elements = array_map( |
67 | - function (PolicyMapping $mapping) { |
|
67 | + function(PolicyMapping $mapping) { |
|
68 | 68 | return $mapping->toASN1(); |
69 | 69 | }, $this->_mappings); |
70 | 70 | return new Sequence(...$elements); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function issuerDomainPolicies() |
130 | 130 | { |
131 | 131 | $idps = array_map( |
132 | - function (PolicyMapping $mapping) { |
|
132 | + function(PolicyMapping $mapping) { |
|
133 | 133 | return $mapping->issuerDomainPolicy(); |
134 | 134 | }, $this->_mappings); |
135 | 135 | return array_values(array_unique($idps)); |
@@ -12,155 +12,155 @@ |
||
12 | 12 | */ |
13 | 13 | class KeyUsageExtension extends Extension |
14 | 14 | { |
15 | - const DIGITAL_SIGNATURE = 0x100; |
|
16 | - const NON_REPUDIATION = 0x080; |
|
17 | - const KEY_ENCIPHERMENT = 0x040; |
|
18 | - const DATA_ENCIPHERMENT = 0x020; |
|
19 | - const KEY_AGREEMENT = 0x010; |
|
20 | - const KEY_CERT_SIGN = 0x008; |
|
21 | - const CRL_SIGN = 0x004; |
|
22 | - const ENCIPHER_ONLY = 0x002; |
|
23 | - const DECIPHER_ONLY = 0x001; |
|
15 | + const DIGITAL_SIGNATURE = 0x100; |
|
16 | + const NON_REPUDIATION = 0x080; |
|
17 | + const KEY_ENCIPHERMENT = 0x040; |
|
18 | + const DATA_ENCIPHERMENT = 0x020; |
|
19 | + const KEY_AGREEMENT = 0x010; |
|
20 | + const KEY_CERT_SIGN = 0x008; |
|
21 | + const CRL_SIGN = 0x004; |
|
22 | + const ENCIPHER_ONLY = 0x002; |
|
23 | + const DECIPHER_ONLY = 0x001; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Key usage flags. |
|
27 | - * |
|
28 | - * @var int $_keyUsage |
|
29 | - */ |
|
30 | - protected $_keyUsage; |
|
25 | + /** |
|
26 | + * Key usage flags. |
|
27 | + * |
|
28 | + * @var int $_keyUsage |
|
29 | + */ |
|
30 | + protected $_keyUsage; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor. |
|
34 | - * |
|
35 | - * @param bool $critical |
|
36 | - * @param int $keyUsage |
|
37 | - */ |
|
38 | - public function __construct($critical, $keyUsage) |
|
39 | - { |
|
40 | - parent::__construct(self::OID_KEY_USAGE, $critical); |
|
41 | - $this->_keyUsage = (int) $keyUsage; |
|
42 | - } |
|
32 | + /** |
|
33 | + * Constructor. |
|
34 | + * |
|
35 | + * @param bool $critical |
|
36 | + * @param int $keyUsage |
|
37 | + */ |
|
38 | + public function __construct($critical, $keyUsage) |
|
39 | + { |
|
40 | + parent::__construct(self::OID_KEY_USAGE, $critical); |
|
41 | + $this->_keyUsage = (int) $keyUsage; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * |
|
46 | - * {@inheritdoc} |
|
47 | - * @return self |
|
48 | - */ |
|
49 | - protected static function _fromDER($data, $critical) |
|
50 | - { |
|
51 | - return new self($critical, |
|
52 | - Flags::fromBitString(BitString::fromDER($data), 9)->number()); |
|
53 | - } |
|
44 | + /** |
|
45 | + * |
|
46 | + * {@inheritdoc} |
|
47 | + * @return self |
|
48 | + */ |
|
49 | + protected static function _fromDER($data, $critical) |
|
50 | + { |
|
51 | + return new self($critical, |
|
52 | + Flags::fromBitString(BitString::fromDER($data), 9)->number()); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Check whether digitalSignature flag is set. |
|
57 | - * |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function isDigitalSignature() |
|
61 | - { |
|
62 | - return $this->_flagSet(self::DIGITAL_SIGNATURE); |
|
63 | - } |
|
55 | + /** |
|
56 | + * Check whether digitalSignature flag is set. |
|
57 | + * |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function isDigitalSignature() |
|
61 | + { |
|
62 | + return $this->_flagSet(self::DIGITAL_SIGNATURE); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Check whether nonRepudiation/contentCommitment flag is set. |
|
67 | - * |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function isNonRepudiation() |
|
71 | - { |
|
72 | - return $this->_flagSet(self::NON_REPUDIATION); |
|
73 | - } |
|
65 | + /** |
|
66 | + * Check whether nonRepudiation/contentCommitment flag is set. |
|
67 | + * |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function isNonRepudiation() |
|
71 | + { |
|
72 | + return $this->_flagSet(self::NON_REPUDIATION); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Check whether keyEncipherment flag is set. |
|
77 | - * |
|
78 | - * @return bool |
|
79 | - */ |
|
80 | - public function isKeyEncipherment() |
|
81 | - { |
|
82 | - return $this->_flagSet(self::KEY_ENCIPHERMENT); |
|
83 | - } |
|
75 | + /** |
|
76 | + * Check whether keyEncipherment flag is set. |
|
77 | + * |
|
78 | + * @return bool |
|
79 | + */ |
|
80 | + public function isKeyEncipherment() |
|
81 | + { |
|
82 | + return $this->_flagSet(self::KEY_ENCIPHERMENT); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Check whether dataEncipherment flag is set. |
|
87 | - * |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function isDataEncipherment() |
|
91 | - { |
|
92 | - return $this->_flagSet(self::DATA_ENCIPHERMENT); |
|
93 | - } |
|
85 | + /** |
|
86 | + * Check whether dataEncipherment flag is set. |
|
87 | + * |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function isDataEncipherment() |
|
91 | + { |
|
92 | + return $this->_flagSet(self::DATA_ENCIPHERMENT); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Check whether keyAgreement flag is set. |
|
97 | - * |
|
98 | - * @return bool |
|
99 | - */ |
|
100 | - public function isKeyAgreement() |
|
101 | - { |
|
102 | - return $this->_flagSet(self::KEY_AGREEMENT); |
|
103 | - } |
|
95 | + /** |
|
96 | + * Check whether keyAgreement flag is set. |
|
97 | + * |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | + public function isKeyAgreement() |
|
101 | + { |
|
102 | + return $this->_flagSet(self::KEY_AGREEMENT); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Check whether keyCertSign flag is set. |
|
107 | - * |
|
108 | - * @return bool |
|
109 | - */ |
|
110 | - public function isKeyCertSign() |
|
111 | - { |
|
112 | - return $this->_flagSet(self::KEY_CERT_SIGN); |
|
113 | - } |
|
105 | + /** |
|
106 | + * Check whether keyCertSign flag is set. |
|
107 | + * |
|
108 | + * @return bool |
|
109 | + */ |
|
110 | + public function isKeyCertSign() |
|
111 | + { |
|
112 | + return $this->_flagSet(self::KEY_CERT_SIGN); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Check whether cRLSign flag is set. |
|
117 | - * |
|
118 | - * @return bool |
|
119 | - */ |
|
120 | - public function isCRLSign() |
|
121 | - { |
|
122 | - return $this->_flagSet(self::CRL_SIGN); |
|
123 | - } |
|
115 | + /** |
|
116 | + * Check whether cRLSign flag is set. |
|
117 | + * |
|
118 | + * @return bool |
|
119 | + */ |
|
120 | + public function isCRLSign() |
|
121 | + { |
|
122 | + return $this->_flagSet(self::CRL_SIGN); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Check whether encipherOnly flag is set. |
|
127 | - * |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public function isEncipherOnly() |
|
131 | - { |
|
132 | - return $this->_flagSet(self::ENCIPHER_ONLY); |
|
133 | - } |
|
125 | + /** |
|
126 | + * Check whether encipherOnly flag is set. |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public function isEncipherOnly() |
|
131 | + { |
|
132 | + return $this->_flagSet(self::ENCIPHER_ONLY); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Check whether decipherOnly flag is set. |
|
137 | - * |
|
138 | - * @return bool |
|
139 | - */ |
|
140 | - public function isDecipherOnly() |
|
141 | - { |
|
142 | - return $this->_flagSet(self::DECIPHER_ONLY); |
|
143 | - } |
|
135 | + /** |
|
136 | + * Check whether decipherOnly flag is set. |
|
137 | + * |
|
138 | + * @return bool |
|
139 | + */ |
|
140 | + public function isDecipherOnly() |
|
141 | + { |
|
142 | + return $this->_flagSet(self::DECIPHER_ONLY); |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Check whether given flag is set. |
|
147 | - * |
|
148 | - * @param int $flag |
|
149 | - * @return boolean |
|
150 | - */ |
|
151 | - protected function _flagSet($flag) |
|
152 | - { |
|
153 | - return (bool) ($this->_keyUsage & $flag); |
|
154 | - } |
|
145 | + /** |
|
146 | + * Check whether given flag is set. |
|
147 | + * |
|
148 | + * @param int $flag |
|
149 | + * @return boolean |
|
150 | + */ |
|
151 | + protected function _flagSet($flag) |
|
152 | + { |
|
153 | + return (bool) ($this->_keyUsage & $flag); |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * |
|
158 | - * {@inheritdoc} |
|
159 | - * @return BitString |
|
160 | - */ |
|
161 | - protected function _valueASN1() |
|
162 | - { |
|
163 | - $flags = new Flags($this->_keyUsage, 9); |
|
164 | - return $flags->bitString()->withoutTrailingZeroes(); |
|
165 | - } |
|
156 | + /** |
|
157 | + * |
|
158 | + * {@inheritdoc} |
|
159 | + * @return BitString |
|
160 | + */ |
|
161 | + protected function _valueASN1() |
|
162 | + { |
|
163 | + $flags = new Flags($this->_keyUsage, 9); |
|
164 | + return $flags->bitString()->withoutTrailingZeroes(); |
|
165 | + } |
|
166 | 166 | } |
@@ -12,136 +12,136 @@ |
||
12 | 12 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.4 |
13 | 13 | */ |
14 | 14 | class CertificatePoliciesExtension extends Extension implements |
15 | - \Countable, |
|
16 | - \IteratorAggregate |
|
15 | + \Countable, |
|
16 | + \IteratorAggregate |
|
17 | 17 | { |
18 | - /** |
|
19 | - * Policy information terms. |
|
20 | - * |
|
21 | - * @var PolicyInformation[] $_policies |
|
22 | - */ |
|
23 | - protected $_policies; |
|
18 | + /** |
|
19 | + * Policy information terms. |
|
20 | + * |
|
21 | + * @var PolicyInformation[] $_policies |
|
22 | + */ |
|
23 | + protected $_policies; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Constructor. |
|
27 | - * |
|
28 | - * @param bool $critical |
|
29 | - * @param PolicyInformation ...$policies |
|
30 | - */ |
|
31 | - public function __construct($critical, PolicyInformation ...$policies) |
|
32 | - { |
|
33 | - parent::__construct(Extension::OID_CERTIFICATE_POLICIES, $critical); |
|
34 | - $this->_policies = array(); |
|
35 | - foreach ($policies as $policy) { |
|
36 | - $this->_policies[$policy->oid()] = $policy; |
|
37 | - } |
|
38 | - } |
|
25 | + /** |
|
26 | + * Constructor. |
|
27 | + * |
|
28 | + * @param bool $critical |
|
29 | + * @param PolicyInformation ...$policies |
|
30 | + */ |
|
31 | + public function __construct($critical, PolicyInformation ...$policies) |
|
32 | + { |
|
33 | + parent::__construct(Extension::OID_CERTIFICATE_POLICIES, $critical); |
|
34 | + $this->_policies = array(); |
|
35 | + foreach ($policies as $policy) { |
|
36 | + $this->_policies[$policy->oid()] = $policy; |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * |
|
42 | - * {@inheritdoc} |
|
43 | - * @return self |
|
44 | - */ |
|
45 | - protected static function _fromDER($data, $critical) |
|
46 | - { |
|
47 | - $policies = array_map( |
|
48 | - function (UnspecifiedType $el) { |
|
49 | - return PolicyInformation::fromASN1($el->asSequence()); |
|
50 | - }, Sequence::fromDER($data)->elements()); |
|
51 | - if (!count($policies)) { |
|
52 | - throw new \UnexpectedValueException( |
|
53 | - "certificatePolicies must contain" . |
|
54 | - " at least one PolicyInformation."); |
|
55 | - } |
|
56 | - return new self($critical, ...$policies); |
|
57 | - } |
|
40 | + /** |
|
41 | + * |
|
42 | + * {@inheritdoc} |
|
43 | + * @return self |
|
44 | + */ |
|
45 | + protected static function _fromDER($data, $critical) |
|
46 | + { |
|
47 | + $policies = array_map( |
|
48 | + function (UnspecifiedType $el) { |
|
49 | + return PolicyInformation::fromASN1($el->asSequence()); |
|
50 | + }, Sequence::fromDER($data)->elements()); |
|
51 | + if (!count($policies)) { |
|
52 | + throw new \UnexpectedValueException( |
|
53 | + "certificatePolicies must contain" . |
|
54 | + " at least one PolicyInformation."); |
|
55 | + } |
|
56 | + return new self($critical, ...$policies); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Check whether policy information by OID is present. |
|
61 | - * |
|
62 | - * @param string $oid |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function has($oid) |
|
66 | - { |
|
67 | - return isset($this->_policies[$oid]); |
|
68 | - } |
|
59 | + /** |
|
60 | + * Check whether policy information by OID is present. |
|
61 | + * |
|
62 | + * @param string $oid |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function has($oid) |
|
66 | + { |
|
67 | + return isset($this->_policies[$oid]); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get policy information by OID. |
|
72 | - * |
|
73 | - * @param string $oid |
|
74 | - * @throws \LogicException |
|
75 | - * @return PolicyInformation |
|
76 | - */ |
|
77 | - public function get($oid) |
|
78 | - { |
|
79 | - if (!$this->has($oid)) { |
|
80 | - throw new \LogicException("Not certificate policy by OID $oid."); |
|
81 | - } |
|
82 | - return $this->_policies[$oid]; |
|
83 | - } |
|
70 | + /** |
|
71 | + * Get policy information by OID. |
|
72 | + * |
|
73 | + * @param string $oid |
|
74 | + * @throws \LogicException |
|
75 | + * @return PolicyInformation |
|
76 | + */ |
|
77 | + public function get($oid) |
|
78 | + { |
|
79 | + if (!$this->has($oid)) { |
|
80 | + throw new \LogicException("Not certificate policy by OID $oid."); |
|
81 | + } |
|
82 | + return $this->_policies[$oid]; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Check whether anyPolicy is present. |
|
87 | - * |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function hasAnyPolicy() |
|
91 | - { |
|
92 | - return $this->has(PolicyInformation::OID_ANY_POLICY); |
|
93 | - } |
|
85 | + /** |
|
86 | + * Check whether anyPolicy is present. |
|
87 | + * |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function hasAnyPolicy() |
|
91 | + { |
|
92 | + return $this->has(PolicyInformation::OID_ANY_POLICY); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Get anyPolicy information. |
|
97 | - * |
|
98 | - * @throws \LogicException If anyPolicy is not present. |
|
99 | - * @return PolicyInformation |
|
100 | - */ |
|
101 | - public function anyPolicy() |
|
102 | - { |
|
103 | - if (!$this->hasAnyPolicy()) { |
|
104 | - throw new \LogicException("No anyPolicy."); |
|
105 | - } |
|
106 | - return $this->get(PolicyInformation::OID_ANY_POLICY); |
|
107 | - } |
|
95 | + /** |
|
96 | + * Get anyPolicy information. |
|
97 | + * |
|
98 | + * @throws \LogicException If anyPolicy is not present. |
|
99 | + * @return PolicyInformation |
|
100 | + */ |
|
101 | + public function anyPolicy() |
|
102 | + { |
|
103 | + if (!$this->hasAnyPolicy()) { |
|
104 | + throw new \LogicException("No anyPolicy."); |
|
105 | + } |
|
106 | + return $this->get(PolicyInformation::OID_ANY_POLICY); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * |
|
111 | - * {@inheritdoc} |
|
112 | - * @return Sequence |
|
113 | - */ |
|
114 | - protected function _valueASN1() |
|
115 | - { |
|
116 | - if (!count($this->_policies)) { |
|
117 | - throw new \LogicException("No policies."); |
|
118 | - } |
|
119 | - $elements = array_map( |
|
120 | - function (PolicyInformation $pi) { |
|
121 | - return $pi->toASN1(); |
|
122 | - }, array_values($this->_policies)); |
|
123 | - return new Sequence(...$elements); |
|
124 | - } |
|
109 | + /** |
|
110 | + * |
|
111 | + * {@inheritdoc} |
|
112 | + * @return Sequence |
|
113 | + */ |
|
114 | + protected function _valueASN1() |
|
115 | + { |
|
116 | + if (!count($this->_policies)) { |
|
117 | + throw new \LogicException("No policies."); |
|
118 | + } |
|
119 | + $elements = array_map( |
|
120 | + function (PolicyInformation $pi) { |
|
121 | + return $pi->toASN1(); |
|
122 | + }, array_values($this->_policies)); |
|
123 | + return new Sequence(...$elements); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Get the number of policies. |
|
128 | - * |
|
129 | - * @see \Countable::count() |
|
130 | - * @return int |
|
131 | - */ |
|
132 | - public function count() |
|
133 | - { |
|
134 | - return count($this->_policies); |
|
135 | - } |
|
126 | + /** |
|
127 | + * Get the number of policies. |
|
128 | + * |
|
129 | + * @see \Countable::count() |
|
130 | + * @return int |
|
131 | + */ |
|
132 | + public function count() |
|
133 | + { |
|
134 | + return count($this->_policies); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Get iterator for policy information terms. |
|
139 | - * |
|
140 | - * @see \IteratorAggregate::getIterator() |
|
141 | - * @return \ArrayIterator |
|
142 | - */ |
|
143 | - public function getIterator() |
|
144 | - { |
|
145 | - return new \ArrayIterator($this->_policies); |
|
146 | - } |
|
137 | + /** |
|
138 | + * Get iterator for policy information terms. |
|
139 | + * |
|
140 | + * @see \IteratorAggregate::getIterator() |
|
141 | + * @return \ArrayIterator |
|
142 | + */ |
|
143 | + public function getIterator() |
|
144 | + { |
|
145 | + return new \ArrayIterator($this->_policies); |
|
146 | + } |
|
147 | 147 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | protected static function _fromDER($data, $critical) |
46 | 46 | { |
47 | 47 | $policies = array_map( |
48 | - function (UnspecifiedType $el) { |
|
48 | + function(UnspecifiedType $el) { |
|
49 | 49 | return PolicyInformation::fromASN1($el->asSequence()); |
50 | 50 | }, Sequence::fromDER($data)->elements()); |
51 | 51 | if (!count($policies)) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | throw new \LogicException("No policies."); |
118 | 118 | } |
119 | 119 | $elements = array_map( |
120 | - function (PolicyInformation $pi) { |
|
120 | + function(PolicyInformation $pi) { |
|
121 | 121 | return $pi->toASN1(); |
122 | 122 | }, array_values($this->_policies)); |
123 | 123 | return new Sequence(...$elements); |
@@ -12,53 +12,53 @@ |
||
12 | 12 | */ |
13 | 13 | class SubjectAlternativeNameExtension extends Extension |
14 | 14 | { |
15 | - /** |
|
16 | - * Names. |
|
17 | - * |
|
18 | - * @var GeneralNames $_names |
|
19 | - */ |
|
20 | - protected $_names; |
|
15 | + /** |
|
16 | + * Names. |
|
17 | + * |
|
18 | + * @var GeneralNames $_names |
|
19 | + */ |
|
20 | + protected $_names; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Constructor. |
|
24 | - * |
|
25 | - * @param bool $critical |
|
26 | - * @param GeneralNames $names |
|
27 | - */ |
|
28 | - public function __construct($critical, GeneralNames $names) |
|
29 | - { |
|
30 | - parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical); |
|
31 | - $this->_names = $names; |
|
32 | - } |
|
22 | + /** |
|
23 | + * Constructor. |
|
24 | + * |
|
25 | + * @param bool $critical |
|
26 | + * @param GeneralNames $names |
|
27 | + */ |
|
28 | + public function __construct($critical, GeneralNames $names) |
|
29 | + { |
|
30 | + parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical); |
|
31 | + $this->_names = $names; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * {@inheritdoc} |
|
37 | - * @return self |
|
38 | - */ |
|
39 | - protected static function _fromDER($data, $critical) |
|
40 | - { |
|
41 | - return new self($critical, |
|
42 | - GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
43 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * {@inheritdoc} |
|
37 | + * @return self |
|
38 | + */ |
|
39 | + protected static function _fromDER($data, $critical) |
|
40 | + { |
|
41 | + return new self($critical, |
|
42 | + GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get names. |
|
47 | - * |
|
48 | - * @return GeneralNames |
|
49 | - */ |
|
50 | - public function names() |
|
51 | - { |
|
52 | - return $this->_names; |
|
53 | - } |
|
45 | + /** |
|
46 | + * Get names. |
|
47 | + * |
|
48 | + * @return GeneralNames |
|
49 | + */ |
|
50 | + public function names() |
|
51 | + { |
|
52 | + return $this->_names; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * |
|
57 | - * {@inheritdoc} |
|
58 | - * @return Sequence |
|
59 | - */ |
|
60 | - protected function _valueASN1() |
|
61 | - { |
|
62 | - return $this->_names->toASN1(); |
|
63 | - } |
|
55 | + /** |
|
56 | + * |
|
57 | + * {@inheritdoc} |
|
58 | + * @return Sequence |
|
59 | + */ |
|
60 | + protected function _valueASN1() |
|
61 | + { |
|
62 | + return $this->_names->toASN1(); |
|
63 | + } |
|
64 | 64 | } |
@@ -12,53 +12,53 @@ |
||
12 | 12 | */ |
13 | 13 | class IssuerAlternativeNameExtension extends Extension |
14 | 14 | { |
15 | - /** |
|
16 | - * Names. |
|
17 | - * |
|
18 | - * @var GeneralNames |
|
19 | - */ |
|
20 | - protected $_names; |
|
15 | + /** |
|
16 | + * Names. |
|
17 | + * |
|
18 | + * @var GeneralNames |
|
19 | + */ |
|
20 | + protected $_names; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Constructor. |
|
24 | - * |
|
25 | - * @param bool $critical |
|
26 | - * @param GeneralNames $names |
|
27 | - */ |
|
28 | - public function __construct($critical, GeneralNames $names) |
|
29 | - { |
|
30 | - parent::__construct(self::OID_ISSUER_ALT_NAME, $critical); |
|
31 | - $this->_names = $names; |
|
32 | - } |
|
22 | + /** |
|
23 | + * Constructor. |
|
24 | + * |
|
25 | + * @param bool $critical |
|
26 | + * @param GeneralNames $names |
|
27 | + */ |
|
28 | + public function __construct($critical, GeneralNames $names) |
|
29 | + { |
|
30 | + parent::__construct(self::OID_ISSUER_ALT_NAME, $critical); |
|
31 | + $this->_names = $names; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * {@inheritdoc} |
|
37 | - * @return self |
|
38 | - */ |
|
39 | - protected static function _fromDER($data, $critical) |
|
40 | - { |
|
41 | - return new self($critical, |
|
42 | - GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
43 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * {@inheritdoc} |
|
37 | + * @return self |
|
38 | + */ |
|
39 | + protected static function _fromDER($data, $critical) |
|
40 | + { |
|
41 | + return new self($critical, |
|
42 | + GeneralNames::fromASN1(Sequence::fromDER($data))); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get names. |
|
47 | - * |
|
48 | - * @return GeneralNames |
|
49 | - */ |
|
50 | - public function names() |
|
51 | - { |
|
52 | - return $this->_names; |
|
53 | - } |
|
45 | + /** |
|
46 | + * Get names. |
|
47 | + * |
|
48 | + * @return GeneralNames |
|
49 | + */ |
|
50 | + public function names() |
|
51 | + { |
|
52 | + return $this->_names; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * |
|
57 | - * {@inheritdoc} |
|
58 | - * @return Sequence |
|
59 | - */ |
|
60 | - protected function _valueASN1() |
|
61 | - { |
|
62 | - return $this->_names->toASN1(); |
|
63 | - } |
|
55 | + /** |
|
56 | + * |
|
57 | + * {@inheritdoc} |
|
58 | + * @return Sequence |
|
59 | + */ |
|
60 | + protected function _valueASN1() |
|
61 | + { |
|
62 | + return $this->_names->toASN1(); |
|
63 | + } |
|
64 | 64 | } |
@@ -14,83 +14,83 @@ |
||
14 | 14 | */ |
15 | 15 | class NoticeReference |
16 | 16 | { |
17 | - /** |
|
18 | - * Organization. |
|
19 | - * |
|
20 | - * @var DisplayText $_organization |
|
21 | - */ |
|
22 | - protected $_organization; |
|
17 | + /** |
|
18 | + * Organization. |
|
19 | + * |
|
20 | + * @var DisplayText $_organization |
|
21 | + */ |
|
22 | + protected $_organization; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Notification reference numbers. |
|
26 | - * |
|
27 | - * @var int[] $_numbers |
|
28 | - */ |
|
29 | - protected $_numbers; |
|
24 | + /** |
|
25 | + * Notification reference numbers. |
|
26 | + * |
|
27 | + * @var int[] $_numbers |
|
28 | + */ |
|
29 | + protected $_numbers; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor. |
|
33 | - * |
|
34 | - * @param DisplayText $organization |
|
35 | - * @param int ...$numbers |
|
36 | - */ |
|
37 | - public function __construct(DisplayText $organization, ...$numbers) |
|
38 | - { |
|
39 | - $this->_organization = $organization; |
|
40 | - $this->_numbers = $numbers; |
|
41 | - } |
|
31 | + /** |
|
32 | + * Constructor. |
|
33 | + * |
|
34 | + * @param DisplayText $organization |
|
35 | + * @param int ...$numbers |
|
36 | + */ |
|
37 | + public function __construct(DisplayText $organization, ...$numbers) |
|
38 | + { |
|
39 | + $this->_organization = $organization; |
|
40 | + $this->_numbers = $numbers; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Initialize from ASN.1. |
|
45 | - * |
|
46 | - * @param Sequence $seq |
|
47 | - * @return self |
|
48 | - */ |
|
49 | - public static function fromASN1(Sequence $seq) |
|
50 | - { |
|
51 | - $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
52 | - $numbers = array_map( |
|
53 | - function (UnspecifiedType $el) { |
|
54 | - return $el->asInteger()->number(); |
|
55 | - }, |
|
56 | - $seq->at(1) |
|
57 | - ->asSequence() |
|
58 | - ->elements()); |
|
59 | - return new self($org, ...$numbers); |
|
60 | - } |
|
43 | + /** |
|
44 | + * Initialize from ASN.1. |
|
45 | + * |
|
46 | + * @param Sequence $seq |
|
47 | + * @return self |
|
48 | + */ |
|
49 | + public static function fromASN1(Sequence $seq) |
|
50 | + { |
|
51 | + $org = DisplayText::fromASN1($seq->at(0)->asString()); |
|
52 | + $numbers = array_map( |
|
53 | + function (UnspecifiedType $el) { |
|
54 | + return $el->asInteger()->number(); |
|
55 | + }, |
|
56 | + $seq->at(1) |
|
57 | + ->asSequence() |
|
58 | + ->elements()); |
|
59 | + return new self($org, ...$numbers); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get reference organization. |
|
64 | - * |
|
65 | - * @return DisplayText |
|
66 | - */ |
|
67 | - public function organization() |
|
68 | - { |
|
69 | - return $this->_organization; |
|
70 | - } |
|
62 | + /** |
|
63 | + * Get reference organization. |
|
64 | + * |
|
65 | + * @return DisplayText |
|
66 | + */ |
|
67 | + public function organization() |
|
68 | + { |
|
69 | + return $this->_organization; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get reference numbers. |
|
74 | - * |
|
75 | - * @return int[] |
|
76 | - */ |
|
77 | - public function numbers() |
|
78 | - { |
|
79 | - return $this->_numbers; |
|
80 | - } |
|
72 | + /** |
|
73 | + * Get reference numbers. |
|
74 | + * |
|
75 | + * @return int[] |
|
76 | + */ |
|
77 | + public function numbers() |
|
78 | + { |
|
79 | + return $this->_numbers; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Generate ASN.1 structure. |
|
84 | - * |
|
85 | - * @return Sequence |
|
86 | - */ |
|
87 | - public function toASN1() |
|
88 | - { |
|
89 | - $org = $this->_organization->toASN1(); |
|
90 | - $nums = array_map( |
|
91 | - function ($number) { |
|
92 | - return new Integer($number); |
|
93 | - }, $this->_numbers); |
|
94 | - return new Sequence($org, new Sequence(...$nums)); |
|
95 | - } |
|
82 | + /** |
|
83 | + * Generate ASN.1 structure. |
|
84 | + * |
|
85 | + * @return Sequence |
|
86 | + */ |
|
87 | + public function toASN1() |
|
88 | + { |
|
89 | + $org = $this->_organization->toASN1(); |
|
90 | + $nums = array_map( |
|
91 | + function ($number) { |
|
92 | + return new Integer($number); |
|
93 | + }, $this->_numbers); |
|
94 | + return new Sequence($org, new Sequence(...$nums)); |
|
95 | + } |
|
96 | 96 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $org = DisplayText::fromASN1($seq->at(0)->asString()); |
52 | 52 | $numbers = array_map( |
53 | - function (UnspecifiedType $el) { |
|
53 | + function(UnspecifiedType $el) { |
|
54 | 54 | return $el->asInteger()->number(); |
55 | 55 | }, |
56 | 56 | $seq->at(1) |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $org = $this->_organization->toASN1(); |
90 | 90 | $nums = array_map( |
91 | - function ($number) { |
|
91 | + function($number) { |
|
92 | 92 | return new Integer($number); |
93 | 93 | }, $this->_numbers); |
94 | 94 | return new Sequence($org, new Sequence(...$nums)); |
@@ -13,51 +13,51 @@ |
||
13 | 13 | */ |
14 | 14 | class CPSQualifier extends PolicyQualifierInfo |
15 | 15 | { |
16 | - /** |
|
17 | - * URI. |
|
18 | - * |
|
19 | - * @var string $_uri |
|
20 | - */ |
|
21 | - protected $_uri; |
|
16 | + /** |
|
17 | + * URI. |
|
18 | + * |
|
19 | + * @var string $_uri |
|
20 | + */ |
|
21 | + protected $_uri; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor. |
|
25 | - * |
|
26 | - * @param string $uri |
|
27 | - */ |
|
28 | - public function __construct($uri) |
|
29 | - { |
|
30 | - $this->_oid = self::OID_CPS; |
|
31 | - $this->_uri = $uri; |
|
32 | - } |
|
23 | + /** |
|
24 | + * Constructor. |
|
25 | + * |
|
26 | + * @param string $uri |
|
27 | + */ |
|
28 | + public function __construct($uri) |
|
29 | + { |
|
30 | + $this->_oid = self::OID_CPS; |
|
31 | + $this->_uri = $uri; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * |
|
36 | - * @param UnspecifiedType $el |
|
37 | - * @return self |
|
38 | - */ |
|
39 | - public static function fromQualifierASN1(UnspecifiedType $el) |
|
40 | - { |
|
41 | - return new self($el->asString()->string()); |
|
42 | - } |
|
34 | + /** |
|
35 | + * |
|
36 | + * @param UnspecifiedType $el |
|
37 | + * @return self |
|
38 | + */ |
|
39 | + public static function fromQualifierASN1(UnspecifiedType $el) |
|
40 | + { |
|
41 | + return new self($el->asString()->string()); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get URI. |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function uri() |
|
50 | - { |
|
51 | - return $this->_uri; |
|
52 | - } |
|
44 | + /** |
|
45 | + * Get URI. |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function uri() |
|
50 | + { |
|
51 | + return $this->_uri; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * |
|
56 | - * {@inheritdoc} |
|
57 | - * @return IA5String |
|
58 | - */ |
|
59 | - protected function _qualifierASN1() |
|
60 | - { |
|
61 | - return new IA5String($this->_uri); |
|
62 | - } |
|
54 | + /** |
|
55 | + * |
|
56 | + * {@inheritdoc} |
|
57 | + * @return IA5String |
|
58 | + */ |
|
59 | + protected function _qualifierASN1() |
|
60 | + { |
|
61 | + return new IA5String($this->_uri); |
|
62 | + } |
|
63 | 63 | } |
@@ -14,114 +14,114 @@ |
||
14 | 14 | */ |
15 | 15 | class UserNoticeQualifier extends PolicyQualifierInfo |
16 | 16 | { |
17 | - /** |
|
18 | - * Explicit notice text. |
|
19 | - * |
|
20 | - * @var DisplayText $_text |
|
21 | - */ |
|
22 | - protected $_text; |
|
17 | + /** |
|
18 | + * Explicit notice text. |
|
19 | + * |
|
20 | + * @var DisplayText $_text |
|
21 | + */ |
|
22 | + protected $_text; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Notice reference. |
|
26 | - * |
|
27 | - * @var NoticeReference $_ref |
|
28 | - */ |
|
29 | - protected $_ref; |
|
24 | + /** |
|
25 | + * Notice reference. |
|
26 | + * |
|
27 | + * @var NoticeReference $_ref |
|
28 | + */ |
|
29 | + protected $_ref; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor. |
|
33 | - * |
|
34 | - * @param DisplayText|null $text |
|
35 | - * @param NoticeReference|null $ref |
|
36 | - */ |
|
37 | - public function __construct(DisplayText $text = null, NoticeReference $ref = null) |
|
38 | - { |
|
39 | - $this->_oid = self::OID_UNOTICE; |
|
40 | - $this->_text = $text; |
|
41 | - $this->_ref = $ref; |
|
42 | - } |
|
31 | + /** |
|
32 | + * Constructor. |
|
33 | + * |
|
34 | + * @param DisplayText|null $text |
|
35 | + * @param NoticeReference|null $ref |
|
36 | + */ |
|
37 | + public function __construct(DisplayText $text = null, NoticeReference $ref = null) |
|
38 | + { |
|
39 | + $this->_oid = self::OID_UNOTICE; |
|
40 | + $this->_text = $text; |
|
41 | + $this->_ref = $ref; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * |
|
46 | - * @param UnspecifiedType $el |
|
47 | - * @return self |
|
48 | - */ |
|
49 | - public static function fromQualifierASN1(UnspecifiedType $el) |
|
50 | - { |
|
51 | - $seq = $el->asSequence(); |
|
52 | - $ref = null; |
|
53 | - $text = null; |
|
54 | - $idx = 0; |
|
55 | - if ($seq->has($idx, Element::TYPE_SEQUENCE)) { |
|
56 | - $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence()); |
|
57 | - } |
|
58 | - if ($seq->has($idx, Element::TYPE_STRING)) { |
|
59 | - $text = DisplayText::fromASN1($seq->at($idx)->asString()); |
|
60 | - } |
|
61 | - return new self($text, $ref); |
|
62 | - } |
|
44 | + /** |
|
45 | + * |
|
46 | + * @param UnspecifiedType $el |
|
47 | + * @return self |
|
48 | + */ |
|
49 | + public static function fromQualifierASN1(UnspecifiedType $el) |
|
50 | + { |
|
51 | + $seq = $el->asSequence(); |
|
52 | + $ref = null; |
|
53 | + $text = null; |
|
54 | + $idx = 0; |
|
55 | + if ($seq->has($idx, Element::TYPE_SEQUENCE)) { |
|
56 | + $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence()); |
|
57 | + } |
|
58 | + if ($seq->has($idx, Element::TYPE_STRING)) { |
|
59 | + $text = DisplayText::fromASN1($seq->at($idx)->asString()); |
|
60 | + } |
|
61 | + return new self($text, $ref); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Whether explicit text is present. |
|
66 | - * |
|
67 | - * @return bool |
|
68 | - */ |
|
69 | - public function hasExplicitText() |
|
70 | - { |
|
71 | - return isset($this->_text); |
|
72 | - } |
|
64 | + /** |
|
65 | + * Whether explicit text is present. |
|
66 | + * |
|
67 | + * @return bool |
|
68 | + */ |
|
69 | + public function hasExplicitText() |
|
70 | + { |
|
71 | + return isset($this->_text); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Get explicit text. |
|
76 | - * |
|
77 | - * @return DisplayText |
|
78 | - */ |
|
79 | - public function explicitText() |
|
80 | - { |
|
81 | - if (!$this->hasExplicitText()) { |
|
82 | - throw new \LogicException("explicitText not set."); |
|
83 | - } |
|
84 | - return $this->_text; |
|
85 | - } |
|
74 | + /** |
|
75 | + * Get explicit text. |
|
76 | + * |
|
77 | + * @return DisplayText |
|
78 | + */ |
|
79 | + public function explicitText() |
|
80 | + { |
|
81 | + if (!$this->hasExplicitText()) { |
|
82 | + throw new \LogicException("explicitText not set."); |
|
83 | + } |
|
84 | + return $this->_text; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Whether notice reference is present. |
|
89 | - * |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function hasNoticeRef() |
|
93 | - { |
|
94 | - return isset($this->_ref); |
|
95 | - } |
|
87 | + /** |
|
88 | + * Whether notice reference is present. |
|
89 | + * |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function hasNoticeRef() |
|
93 | + { |
|
94 | + return isset($this->_ref); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Get notice reference. |
|
99 | - * |
|
100 | - * @throws \RuntimeException |
|
101 | - * @return NoticeReference |
|
102 | - */ |
|
103 | - public function noticeRef() |
|
104 | - { |
|
105 | - if (!$this->hasNoticeRef()) { |
|
106 | - throw new \LogicException("noticeRef not set."); |
|
107 | - } |
|
108 | - return $this->_ref; |
|
109 | - } |
|
97 | + /** |
|
98 | + * Get notice reference. |
|
99 | + * |
|
100 | + * @throws \RuntimeException |
|
101 | + * @return NoticeReference |
|
102 | + */ |
|
103 | + public function noticeRef() |
|
104 | + { |
|
105 | + if (!$this->hasNoticeRef()) { |
|
106 | + throw new \LogicException("noticeRef not set."); |
|
107 | + } |
|
108 | + return $this->_ref; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * |
|
113 | - * {@inheritdoc} |
|
114 | - * @return Sequence |
|
115 | - */ |
|
116 | - protected function _qualifierASN1() |
|
117 | - { |
|
118 | - $elements = array(); |
|
119 | - if (isset($this->_ref)) { |
|
120 | - $elements[] = $this->_ref->toASN1(); |
|
121 | - } |
|
122 | - if (isset($this->_text)) { |
|
123 | - $elements[] = $this->_text->toASN1(); |
|
124 | - } |
|
125 | - return new Sequence(...$elements); |
|
126 | - } |
|
111 | + /** |
|
112 | + * |
|
113 | + * {@inheritdoc} |
|
114 | + * @return Sequence |
|
115 | + */ |
|
116 | + protected function _qualifierASN1() |
|
117 | + { |
|
118 | + $elements = array(); |
|
119 | + if (isset($this->_ref)) { |
|
120 | + $elements[] = $this->_ref->toASN1(); |
|
121 | + } |
|
122 | + if (isset($this->_text)) { |
|
123 | + $elements[] = $this->_text->toASN1(); |
|
124 | + } |
|
125 | + return new Sequence(...$elements); |
|
126 | + } |
|
127 | 127 | } |
@@ -17,93 +17,93 @@ |
||
17 | 17 | */ |
18 | 18 | class DisplayText |
19 | 19 | { |
20 | - /** |
|
21 | - * Text. |
|
22 | - * |
|
23 | - * @var string $_text |
|
24 | - */ |
|
25 | - protected $_text; |
|
20 | + /** |
|
21 | + * Text. |
|
22 | + * |
|
23 | + * @var string $_text |
|
24 | + */ |
|
25 | + protected $_text; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Element tag. |
|
29 | - * |
|
30 | - * @var int $_tag |
|
31 | - */ |
|
32 | - protected $_tag; |
|
27 | + /** |
|
28 | + * Element tag. |
|
29 | + * |
|
30 | + * @var int $_tag |
|
31 | + */ |
|
32 | + protected $_tag; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor. |
|
36 | - * |
|
37 | - * @param string $text |
|
38 | - * @param int $tag |
|
39 | - */ |
|
40 | - public function __construct($text, $tag) |
|
41 | - { |
|
42 | - $this->_text = $text; |
|
43 | - $this->_tag = $tag; |
|
44 | - } |
|
34 | + /** |
|
35 | + * Constructor. |
|
36 | + * |
|
37 | + * @param string $text |
|
38 | + * @param int $tag |
|
39 | + */ |
|
40 | + public function __construct($text, $tag) |
|
41 | + { |
|
42 | + $this->_text = $text; |
|
43 | + $this->_tag = $tag; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Initialize from ASN.1. |
|
48 | - * |
|
49 | - * @param StringType $el |
|
50 | - * @return self |
|
51 | - */ |
|
52 | - public static function fromASN1(StringType $el) |
|
53 | - { |
|
54 | - return new self($el->string(), $el->tag()); |
|
55 | - } |
|
46 | + /** |
|
47 | + * Initialize from ASN.1. |
|
48 | + * |
|
49 | + * @param StringType $el |
|
50 | + * @return self |
|
51 | + */ |
|
52 | + public static function fromASN1(StringType $el) |
|
53 | + { |
|
54 | + return new self($el->string(), $el->tag()); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Initialize from a UTF-8 string. |
|
59 | - * |
|
60 | - * @param string $str |
|
61 | - * @return self |
|
62 | - */ |
|
63 | - public static function fromString($str) |
|
64 | - { |
|
65 | - return new self($str, Element::TYPE_UTF8_STRING); |
|
66 | - } |
|
57 | + /** |
|
58 | + * Initialize from a UTF-8 string. |
|
59 | + * |
|
60 | + * @param string $str |
|
61 | + * @return self |
|
62 | + */ |
|
63 | + public static function fromString($str) |
|
64 | + { |
|
65 | + return new self($str, Element::TYPE_UTF8_STRING); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Get the text. |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function string() |
|
74 | - { |
|
75 | - return $this->_text; |
|
76 | - } |
|
68 | + /** |
|
69 | + * Get the text. |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function string() |
|
74 | + { |
|
75 | + return $this->_text; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Generate ASN.1 element. |
|
80 | - * |
|
81 | - * @throws \UnexpectedValueException |
|
82 | - * @return StringType |
|
83 | - */ |
|
84 | - public function toASN1() |
|
85 | - { |
|
86 | - switch ($this->_tag) { |
|
87 | - case Element::TYPE_IA5_STRING: |
|
88 | - return new IA5String($this->_text); |
|
89 | - case Element::TYPE_VISIBLE_STRING: |
|
90 | - return new VisibleString($this->_text); |
|
91 | - case Element::TYPE_BMP_STRING: |
|
92 | - return new BMPString($this->_text); |
|
93 | - case Element::TYPE_UTF8_STRING: |
|
94 | - return new UTF8String($this->_text); |
|
95 | - default: |
|
96 | - throw new \UnexpectedValueException( |
|
97 | - "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
98 | - } |
|
99 | - } |
|
78 | + /** |
|
79 | + * Generate ASN.1 element. |
|
80 | + * |
|
81 | + * @throws \UnexpectedValueException |
|
82 | + * @return StringType |
|
83 | + */ |
|
84 | + public function toASN1() |
|
85 | + { |
|
86 | + switch ($this->_tag) { |
|
87 | + case Element::TYPE_IA5_STRING: |
|
88 | + return new IA5String($this->_text); |
|
89 | + case Element::TYPE_VISIBLE_STRING: |
|
90 | + return new VisibleString($this->_text); |
|
91 | + case Element::TYPE_BMP_STRING: |
|
92 | + return new BMPString($this->_text); |
|
93 | + case Element::TYPE_UTF8_STRING: |
|
94 | + return new UTF8String($this->_text); |
|
95 | + default: |
|
96 | + throw new \UnexpectedValueException( |
|
97 | + "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function __toString() |
|
106 | - { |
|
107 | - return $this->string(); |
|
108 | - } |
|
101 | + /** |
|
102 | + * |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function __toString() |
|
106 | + { |
|
107 | + return $this->string(); |
|
108 | + } |
|
109 | 109 | } |
@@ -84,17 +84,17 @@ |
||
84 | 84 | public function toASN1() |
85 | 85 | { |
86 | 86 | switch ($this->_tag) { |
87 | - case Element::TYPE_IA5_STRING: |
|
88 | - return new IA5String($this->_text); |
|
89 | - case Element::TYPE_VISIBLE_STRING: |
|
90 | - return new VisibleString($this->_text); |
|
91 | - case Element::TYPE_BMP_STRING: |
|
92 | - return new BMPString($this->_text); |
|
93 | - case Element::TYPE_UTF8_STRING: |
|
94 | - return new UTF8String($this->_text); |
|
95 | - default: |
|
96 | - throw new \UnexpectedValueException( |
|
97 | - "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
87 | + case Element::TYPE_IA5_STRING: |
|
88 | + return new IA5String($this->_text); |
|
89 | + case Element::TYPE_VISIBLE_STRING: |
|
90 | + return new VisibleString($this->_text); |
|
91 | + case Element::TYPE_BMP_STRING: |
|
92 | + return new BMPString($this->_text); |
|
93 | + case Element::TYPE_UTF8_STRING: |
|
94 | + return new UTF8String($this->_text); |
|
95 | + default: |
|
96 | + throw new \UnexpectedValueException( |
|
97 | + "Type " . Element::tagToName($this->_tag) . " not supported."); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 |