GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Pull Request — master (#1)
by thomas
05:34
created
lib/X509/AttributeCertificate/Holder.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -19,281 +19,281 @@
 block discarded – undo
19 19
  */
20 20
 class Holder
21 21
 {
22
-    /**
23
-     * Holder PKC's issuer and serial.
24
-     *
25
-     * @var IssuerSerial|null $_baseCertificateID
26
-     */
27
-    protected $_baseCertificateID;
22
+	/**
23
+	 * Holder PKC's issuer and serial.
24
+	 *
25
+	 * @var IssuerSerial|null $_baseCertificateID
26
+	 */
27
+	protected $_baseCertificateID;
28 28
     
29
-    /**
30
-     * Holder PKC's subject.
31
-     *
32
-     * @var GeneralNames|null $_entityName
33
-     */
34
-    protected $_entityName;
29
+	/**
30
+	 * Holder PKC's subject.
31
+	 *
32
+	 * @var GeneralNames|null $_entityName
33
+	 */
34
+	protected $_entityName;
35 35
     
36
-    /**
37
-     * Linked object.
38
-     *
39
-     * @var ObjectDigestInfo|null $_objectDigestInfo
40
-     */
41
-    protected $_objectDigestInfo;
36
+	/**
37
+	 * Linked object.
38
+	 *
39
+	 * @var ObjectDigestInfo|null $_objectDigestInfo
40
+	 */
41
+	protected $_objectDigestInfo;
42 42
     
43
-    /**
44
-     * Constructor.
45
-     *
46
-     * @param IssuerSerial|null $issuer_serial
47
-     * @param GeneralNames|null $entity_name
48
-     */
49
-    public function __construct(IssuerSerial $issuer_serial = null,
50
-        GeneralNames $entity_name = null)
51
-    {
52
-        $this->_baseCertificateID = $issuer_serial;
53
-        $this->_entityName = $entity_name;
54
-    }
43
+	/**
44
+	 * Constructor.
45
+	 *
46
+	 * @param IssuerSerial|null $issuer_serial
47
+	 * @param GeneralNames|null $entity_name
48
+	 */
49
+	public function __construct(IssuerSerial $issuer_serial = null,
50
+		GeneralNames $entity_name = null)
51
+	{
52
+		$this->_baseCertificateID = $issuer_serial;
53
+		$this->_entityName = $entity_name;
54
+	}
55 55
     
56
-    /**
57
-     * Initialize from a holder's public key certificate.
58
-     *
59
-     * @param Certificate $cert
60
-     * @return self
61
-     */
62
-    public static function fromPKC(Certificate $cert)
63
-    {
64
-        return new self(IssuerSerial::fromPKC($cert));
65
-    }
56
+	/**
57
+	 * Initialize from a holder's public key certificate.
58
+	 *
59
+	 * @param Certificate $cert
60
+	 * @return self
61
+	 */
62
+	public static function fromPKC(Certificate $cert)
63
+	{
64
+		return new self(IssuerSerial::fromPKC($cert));
65
+	}
66 66
     
67
-    /**
68
-     * Initialize from ASN.1.
69
-     *
70
-     * @param Sequence $seq
71
-     */
72
-    public static function fromASN1(Sequence $seq)
73
-    {
74
-        $cert_id = null;
75
-        $entity_name = null;
76
-        $digest_info = null;
77
-        if ($seq->hasTagged(0)) {
78
-            $cert_id = IssuerSerial::fromASN1(
79
-                $seq->getTagged(0)
80
-                    ->asImplicit(Element::TYPE_SEQUENCE)
81
-                    ->asSequence());
82
-        }
83
-        if ($seq->hasTagged(1)) {
84
-            $entity_name = GeneralNames::fromASN1(
85
-                $seq->getTagged(1)
86
-                    ->asImplicit(Element::TYPE_SEQUENCE)
87
-                    ->asSequence());
88
-        }
89
-        if ($seq->hasTagged(2)) {
90
-            $digest_info = ObjectDigestInfo::fromASN1(
91
-                $seq->getTagged(2)
92
-                    ->asImplicit(Element::TYPE_SEQUENCE)
93
-                    ->asSequence());
94
-        }
95
-        $obj = new self($cert_id, $entity_name);
96
-        $obj->_objectDigestInfo = $digest_info;
97
-        return $obj;
98
-    }
67
+	/**
68
+	 * Initialize from ASN.1.
69
+	 *
70
+	 * @param Sequence $seq
71
+	 */
72
+	public static function fromASN1(Sequence $seq)
73
+	{
74
+		$cert_id = null;
75
+		$entity_name = null;
76
+		$digest_info = null;
77
+		if ($seq->hasTagged(0)) {
78
+			$cert_id = IssuerSerial::fromASN1(
79
+				$seq->getTagged(0)
80
+					->asImplicit(Element::TYPE_SEQUENCE)
81
+					->asSequence());
82
+		}
83
+		if ($seq->hasTagged(1)) {
84
+			$entity_name = GeneralNames::fromASN1(
85
+				$seq->getTagged(1)
86
+					->asImplicit(Element::TYPE_SEQUENCE)
87
+					->asSequence());
88
+		}
89
+		if ($seq->hasTagged(2)) {
90
+			$digest_info = ObjectDigestInfo::fromASN1(
91
+				$seq->getTagged(2)
92
+					->asImplicit(Element::TYPE_SEQUENCE)
93
+					->asSequence());
94
+		}
95
+		$obj = new self($cert_id, $entity_name);
96
+		$obj->_objectDigestInfo = $digest_info;
97
+		return $obj;
98
+	}
99 99
     
100
-    /**
101
-     * Get self with base certificate ID.
102
-     *
103
-     * @param IssuerSerial $issuer
104
-     * @return self
105
-     */
106
-    public function withBaseCertificateID(IssuerSerial $issuer)
107
-    {
108
-        $obj = clone $this;
109
-        $obj->_baseCertificateID = $issuer;
110
-        return $obj;
111
-    }
100
+	/**
101
+	 * Get self with base certificate ID.
102
+	 *
103
+	 * @param IssuerSerial $issuer
104
+	 * @return self
105
+	 */
106
+	public function withBaseCertificateID(IssuerSerial $issuer)
107
+	{
108
+		$obj = clone $this;
109
+		$obj->_baseCertificateID = $issuer;
110
+		return $obj;
111
+	}
112 112
     
113
-    /**
114
-     * Get self with entity name.
115
-     *
116
-     * @param GeneralNames $names
117
-     * @return self
118
-     */
119
-    public function withEntityName(GeneralNames $names)
120
-    {
121
-        $obj = clone $this;
122
-        $obj->_entityName = $names;
123
-        return $obj;
124
-    }
113
+	/**
114
+	 * Get self with entity name.
115
+	 *
116
+	 * @param GeneralNames $names
117
+	 * @return self
118
+	 */
119
+	public function withEntityName(GeneralNames $names)
120
+	{
121
+		$obj = clone $this;
122
+		$obj->_entityName = $names;
123
+		return $obj;
124
+	}
125 125
     
126
-    /**
127
-     * Get self with object digest info.
128
-     *
129
-     * @param ObjectDigestInfo $odi
130
-     * @return self
131
-     */
132
-    public function withObjectDigestInfo(ObjectDigestInfo $odi)
133
-    {
134
-        $obj = clone $this;
135
-        $obj->_objectDigestInfo = $odi;
136
-        return $obj;
137
-    }
126
+	/**
127
+	 * Get self with object digest info.
128
+	 *
129
+	 * @param ObjectDigestInfo $odi
130
+	 * @return self
131
+	 */
132
+	public function withObjectDigestInfo(ObjectDigestInfo $odi)
133
+	{
134
+		$obj = clone $this;
135
+		$obj->_objectDigestInfo = $odi;
136
+		return $obj;
137
+	}
138 138
     
139
-    /**
140
-     * Check whether base certificate ID is present.
141
-     *
142
-     * @return bool
143
-     */
144
-    public function hasBaseCertificateID()
145
-    {
146
-        return isset($this->_baseCertificateID);
147
-    }
139
+	/**
140
+	 * Check whether base certificate ID is present.
141
+	 *
142
+	 * @return bool
143
+	 */
144
+	public function hasBaseCertificateID()
145
+	{
146
+		return isset($this->_baseCertificateID);
147
+	}
148 148
     
149
-    /**
150
-     * Get base certificate ID.
151
-     *
152
-     * @throws \LogicException
153
-     * @return IssuerSerial
154
-     */
155
-    public function baseCertificateID(): IssuerSerial
156
-    {
157
-        if (!$this->hasBaseCertificateID()) {
158
-            throw new \LogicException("baseCertificateID not set.");
159
-        }
160
-        return $this->_baseCertificateID;
161
-    }
149
+	/**
150
+	 * Get base certificate ID.
151
+	 *
152
+	 * @throws \LogicException
153
+	 * @return IssuerSerial
154
+	 */
155
+	public function baseCertificateID(): IssuerSerial
156
+	{
157
+		if (!$this->hasBaseCertificateID()) {
158
+			throw new \LogicException("baseCertificateID not set.");
159
+		}
160
+		return $this->_baseCertificateID;
161
+	}
162 162
     
163
-    /**
164
-     * Check whether entity name is present.
165
-     *
166
-     * @return bool
167
-     */
168
-    public function hasEntityName(): bool
169
-    {
170
-        return isset($this->_entityName);
171
-    }
163
+	/**
164
+	 * Check whether entity name is present.
165
+	 *
166
+	 * @return bool
167
+	 */
168
+	public function hasEntityName(): bool
169
+	{
170
+		return isset($this->_entityName);
171
+	}
172 172
     
173
-    /**
174
-     * Get entity name.
175
-     *
176
-     * @throws \LogicException
177
-     * @return GeneralNames
178
-     */
179
-    public function entityName(): GeneralNames
180
-    {
181
-        if (!$this->hasEntityName()) {
182
-            throw new \LogicException("entityName not set.");
183
-        }
184
-        return $this->_entityName;
185
-    }
173
+	/**
174
+	 * Get entity name.
175
+	 *
176
+	 * @throws \LogicException
177
+	 * @return GeneralNames
178
+	 */
179
+	public function entityName(): GeneralNames
180
+	{
181
+		if (!$this->hasEntityName()) {
182
+			throw new \LogicException("entityName not set.");
183
+		}
184
+		return $this->_entityName;
185
+	}
186 186
     
187
-    /**
188
-     * Check whether object digest info is present.
189
-     *
190
-     * @return bool
191
-     */
192
-    public function hasObjectDigestInfo(): bool
193
-    {
194
-        return isset($this->_objectDigestInfo);
195
-    }
187
+	/**
188
+	 * Check whether object digest info is present.
189
+	 *
190
+	 * @return bool
191
+	 */
192
+	public function hasObjectDigestInfo(): bool
193
+	{
194
+		return isset($this->_objectDigestInfo);
195
+	}
196 196
     
197
-    /**
198
-     * Get object digest info.
199
-     *
200
-     * @throws \LogicException
201
-     * @return ObjectDigestInfo
202
-     */
203
-    public function objectDigestInfo(): ObjectDigestInfo
204
-    {
205
-        if (!$this->hasObjectDigestInfo()) {
206
-            throw new \LogicException("objectDigestInfo not set.");
207
-        }
208
-        return $this->_objectDigestInfo;
209
-    }
197
+	/**
198
+	 * Get object digest info.
199
+	 *
200
+	 * @throws \LogicException
201
+	 * @return ObjectDigestInfo
202
+	 */
203
+	public function objectDigestInfo(): ObjectDigestInfo
204
+	{
205
+		if (!$this->hasObjectDigestInfo()) {
206
+			throw new \LogicException("objectDigestInfo not set.");
207
+		}
208
+		return $this->_objectDigestInfo;
209
+	}
210 210
     
211
-    /**
212
-     * Generate ASN.1 structure.
213
-     *
214
-     * @return Sequence
215
-     */
216
-    public function toASN1(): Sequence
217
-    {
218
-        $elements = [];
219
-        if (isset($this->_baseCertificateID)) {
220
-            $elements[] = new ImplicitlyTaggedType(0,
221
-                $this->_baseCertificateID->toASN1());
222
-        }
223
-        if (isset($this->_entityName)) {
224
-            $elements[] = new ImplicitlyTaggedType(1,
225
-                $this->_entityName->toASN1());
226
-        }
227
-        if (isset($this->_objectDigestInfo)) {
228
-            $elements[] = new ImplicitlyTaggedType(2,
229
-                $this->_objectDigestInfo->toASN1());
230
-        }
231
-        return new Sequence(...$elements);
232
-    }
211
+	/**
212
+	 * Generate ASN.1 structure.
213
+	 *
214
+	 * @return Sequence
215
+	 */
216
+	public function toASN1(): Sequence
217
+	{
218
+		$elements = [];
219
+		if (isset($this->_baseCertificateID)) {
220
+			$elements[] = new ImplicitlyTaggedType(0,
221
+				$this->_baseCertificateID->toASN1());
222
+		}
223
+		if (isset($this->_entityName)) {
224
+			$elements[] = new ImplicitlyTaggedType(1,
225
+				$this->_entityName->toASN1());
226
+		}
227
+		if (isset($this->_objectDigestInfo)) {
228
+			$elements[] = new ImplicitlyTaggedType(2,
229
+				$this->_objectDigestInfo->toASN1());
230
+		}
231
+		return new Sequence(...$elements);
232
+	}
233 233
     
234
-    /**
235
-     * Check whether Holder identifies given certificate.
236
-     *
237
-     * @param Certificate $cert
238
-     * @return boolean
239
-     */
240
-    public function identifiesPKC(Certificate $cert): bool
241
-    {
242
-        // if neither baseCertificateID nor entityName are present
243
-        if (!$this->_baseCertificateID && !$this->_entityName) {
244
-            return false;
245
-        }
246
-        // if baseCertificateID is present, but doesn't match
247
-        if ($this->_baseCertificateID &&
248
-             !$this->_baseCertificateID->identifiesPKC($cert)) {
249
-            return false;
250
-        }
251
-        // if entityName is present, but doesn't match
252
-        if ($this->_entityName && !$this->_checkEntityName($cert)) {
253
-            return false;
254
-        }
255
-        return true;
256
-    }
234
+	/**
235
+	 * Check whether Holder identifies given certificate.
236
+	 *
237
+	 * @param Certificate $cert
238
+	 * @return boolean
239
+	 */
240
+	public function identifiesPKC(Certificate $cert): bool
241
+	{
242
+		// if neither baseCertificateID nor entityName are present
243
+		if (!$this->_baseCertificateID && !$this->_entityName) {
244
+			return false;
245
+		}
246
+		// if baseCertificateID is present, but doesn't match
247
+		if ($this->_baseCertificateID &&
248
+			 !$this->_baseCertificateID->identifiesPKC($cert)) {
249
+			return false;
250
+		}
251
+		// if entityName is present, but doesn't match
252
+		if ($this->_entityName && !$this->_checkEntityName($cert)) {
253
+			return false;
254
+		}
255
+		return true;
256
+	}
257 257
     
258
-    /**
259
-     * Check whether entityName matches the given certificate.
260
-     *
261
-     * @param Certificate $cert
262
-     * @return boolean
263
-     */
264
-    private function _checkEntityName(Certificate $cert): bool
265
-    {
266
-        $name = $this->_entityName->firstDN();
267
-        if ($cert->tbsCertificate()
268
-            ->subject()
269
-            ->equals($name)) {
270
-            return true;
271
-        }
272
-        $exts = $cert->tbsCertificate()->extensions();
273
-        if ($exts->hasSubjectAlternativeName()) {
274
-            $ext = $exts->subjectAlternativeName();
275
-            if ($this->_checkEntityAlternativeNames($ext->names())) {
276
-                return true;
277
-            }
278
-        }
279
-        return false;
280
-    }
258
+	/**
259
+	 * Check whether entityName matches the given certificate.
260
+	 *
261
+	 * @param Certificate $cert
262
+	 * @return boolean
263
+	 */
264
+	private function _checkEntityName(Certificate $cert): bool
265
+	{
266
+		$name = $this->_entityName->firstDN();
267
+		if ($cert->tbsCertificate()
268
+			->subject()
269
+			->equals($name)) {
270
+			return true;
271
+		}
272
+		$exts = $cert->tbsCertificate()->extensions();
273
+		if ($exts->hasSubjectAlternativeName()) {
274
+			$ext = $exts->subjectAlternativeName();
275
+			if ($this->_checkEntityAlternativeNames($ext->names())) {
276
+				return true;
277
+			}
278
+		}
279
+		return false;
280
+	}
281 281
     
282
-    /**
283
-     * Check whether any of the subject alternative names match entityName.
284
-     *
285
-     * @param GeneralNames $san
286
-     * @return boolean
287
-     */
288
-    private function _checkEntityAlternativeNames(GeneralNames $san): bool
289
-    {
290
-        // only directory names supported for now
291
-        $name = $this->_entityName->firstDN();
292
-        foreach ($san->allOf(GeneralName::TAG_DIRECTORY_NAME) as $dn) {
293
-            if ($dn instanceof DirectoryName && $dn->dn()->equals($name)) {
294
-                return true;
295
-            }
296
-        }
297
-        return false;
298
-    }
282
+	/**
283
+	 * Check whether any of the subject alternative names match entityName.
284
+	 *
285
+	 * @param GeneralNames $san
286
+	 * @return boolean
287
+	 */
288
+	private function _checkEntityAlternativeNames(GeneralNames $san): bool
289
+	{
290
+		// only directory names supported for now
291
+		$name = $this->_entityName->firstDN();
292
+		foreach ($san->allOf(GeneralName::TAG_DIRECTORY_NAME) as $dn) {
293
+			if ($dn instanceof DirectoryName && $dn->dn()->equals($name)) {
294
+				return true;
295
+			}
296
+		}
297
+		return false;
298
+	}
299 299
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/IetfAttrSyntax.php 1 patch
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -19,203 +19,203 @@
 block discarded – undo
19 19
  * @link https://tools.ietf.org/html/rfc5755#section-4.4
20 20
  */
21 21
 abstract class IetfAttrSyntax extends AttributeValue implements 
22
-    \Countable,
23
-    \IteratorAggregate
22
+	\Countable,
23
+	\IteratorAggregate
24 24
 {
25
-    /**
26
-     * Policy authority.
27
-     *
28
-     * @var GeneralNames|null $_policyAuthority
29
-     */
30
-    protected $_policyAuthority;
25
+	/**
26
+	 * Policy authority.
27
+	 *
28
+	 * @var GeneralNames|null $_policyAuthority
29
+	 */
30
+	protected $_policyAuthority;
31 31
     
32
-    /**
33
-     * Values.
34
-     *
35
-     * @var IetfAttrValue[] $_values
36
-     */
37
-    protected $_values;
32
+	/**
33
+	 * Values.
34
+	 *
35
+	 * @var IetfAttrValue[] $_values
36
+	 */
37
+	protected $_values;
38 38
     
39
-    /**
40
-     * Constructor.
41
-     *
42
-     * @param IetfAttrValue[] $values
43
-     */
44
-    public function __construct(IetfAttrValue ...$values)
45
-    {
46
-        $this->_policyAuthority = null;
47
-        $this->_values = $values;
48
-    }
39
+	/**
40
+	 * Constructor.
41
+	 *
42
+	 * @param IetfAttrValue[] $values
43
+	 */
44
+	public function __construct(IetfAttrValue ...$values)
45
+	{
46
+		$this->_policyAuthority = null;
47
+		$this->_values = $values;
48
+	}
49 49
     
50
-    /**
51
-     *
52
-     * @param UnspecifiedType $el
53
-     * @return self
54
-     */
55
-    public static function fromASN1(UnspecifiedType $el)
56
-    {
57
-        $seq = $el->asSequence();
58
-        $authority = null;
59
-        $idx = 0;
60
-        if ($seq->hasTagged(0)) {
61
-            $authority = GeneralNames::fromASN1(
62
-                $seq->getTagged(0)
63
-                    ->asImplicit(Element::TYPE_SEQUENCE)
64
-                    ->asSequence());
65
-            ++$idx;
66
-        }
67
-        $values = array_map(
68
-            function (UnspecifiedType $el) {
69
-                return IetfAttrValue::fromASN1($el);
70
-            },
71
-            $seq->at($idx)
72
-                ->asSequence()
73
-                ->elements());
74
-        $obj = new static(...$values);
75
-        $obj->_policyAuthority = $authority;
76
-        return $obj;
77
-    }
50
+	/**
51
+	 *
52
+	 * @param UnspecifiedType $el
53
+	 * @return self
54
+	 */
55
+	public static function fromASN1(UnspecifiedType $el)
56
+	{
57
+		$seq = $el->asSequence();
58
+		$authority = null;
59
+		$idx = 0;
60
+		if ($seq->hasTagged(0)) {
61
+			$authority = GeneralNames::fromASN1(
62
+				$seq->getTagged(0)
63
+					->asImplicit(Element::TYPE_SEQUENCE)
64
+					->asSequence());
65
+			++$idx;
66
+		}
67
+		$values = array_map(
68
+			function (UnspecifiedType $el) {
69
+				return IetfAttrValue::fromASN1($el);
70
+			},
71
+			$seq->at($idx)
72
+				->asSequence()
73
+				->elements());
74
+		$obj = new static(...$values);
75
+		$obj->_policyAuthority = $authority;
76
+		return $obj;
77
+	}
78 78
     
79
-    /**
80
-     * Get self with policy authority.
81
-     *
82
-     * @param GeneralNames $names
83
-     * @return self
84
-     */
85
-    public function withPolicyAuthority(GeneralNames $names)
86
-    {
87
-        $obj = clone $this;
88
-        $obj->_policyAuthority = $names;
89
-        return $obj;
90
-    }
79
+	/**
80
+	 * Get self with policy authority.
81
+	 *
82
+	 * @param GeneralNames $names
83
+	 * @return self
84
+	 */
85
+	public function withPolicyAuthority(GeneralNames $names)
86
+	{
87
+		$obj = clone $this;
88
+		$obj->_policyAuthority = $names;
89
+		return $obj;
90
+	}
91 91
     
92
-    /**
93
-     * Check whether policy authority is present.
94
-     *
95
-     * @return bool
96
-     */
97
-    public function hasPolicyAuthority(): bool
98
-    {
99
-        return isset($this->_policyAuthority);
100
-    }
92
+	/**
93
+	 * Check whether policy authority is present.
94
+	 *
95
+	 * @return bool
96
+	 */
97
+	public function hasPolicyAuthority(): bool
98
+	{
99
+		return isset($this->_policyAuthority);
100
+	}
101 101
     
102
-    /**
103
-     * Get policy authority.
104
-     *
105
-     * @throws \LogicException
106
-     * @return GeneralNames
107
-     */
108
-    public function policyAuthority(): GeneralNames
109
-    {
110
-        if (!$this->hasPolicyAuthority()) {
111
-            throw new \LogicException("policyAuthority not set.");
112
-        }
113
-        return $this->_policyAuthority;
114
-    }
102
+	/**
103
+	 * Get policy authority.
104
+	 *
105
+	 * @throws \LogicException
106
+	 * @return GeneralNames
107
+	 */
108
+	public function policyAuthority(): GeneralNames
109
+	{
110
+		if (!$this->hasPolicyAuthority()) {
111
+			throw new \LogicException("policyAuthority not set.");
112
+		}
113
+		return $this->_policyAuthority;
114
+	}
115 115
     
116
-    /**
117
-     * Get values.
118
-     *
119
-     * @return IetfAttrValue[]
120
-     */
121
-    public function values(): array
122
-    {
123
-        return $this->_values;
124
-    }
116
+	/**
117
+	 * Get values.
118
+	 *
119
+	 * @return IetfAttrValue[]
120
+	 */
121
+	public function values(): array
122
+	{
123
+		return $this->_values;
124
+	}
125 125
     
126
-    /**
127
-     * Get first value.
128
-     *
129
-     * @throws \LogicException
130
-     * @return IetfAttrValue
131
-     */
132
-    public function first(): IetfAttrValue
133
-    {
134
-        if (!count($this->_values)) {
135
-            throw new \LogicException("No values.");
136
-        }
137
-        return $this->_values[0];
138
-    }
126
+	/**
127
+	 * Get first value.
128
+	 *
129
+	 * @throws \LogicException
130
+	 * @return IetfAttrValue
131
+	 */
132
+	public function first(): IetfAttrValue
133
+	{
134
+		if (!count($this->_values)) {
135
+			throw new \LogicException("No values.");
136
+		}
137
+		return $this->_values[0];
138
+	}
139 139
     
140
-    /**
141
-     *
142
-     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
143
-     * @return Sequence
144
-     */
145
-    public function toASN1(): Sequence
146
-    {
147
-        $elements = array();
148
-        if (isset($this->_policyAuthority)) {
149
-            $elements[] = new ImplicitlyTaggedType(0,
150
-                $this->_policyAuthority->toASN1());
151
-        }
152
-        $values = array_map(
153
-            function (IetfAttrValue $val) {
154
-                return $val->toASN1();
155
-            }, $this->_values);
156
-        $elements[] = new Sequence(...$values);
157
-        return new Sequence(...$elements);
158
-    }
140
+	/**
141
+	 *
142
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
143
+	 * @return Sequence
144
+	 */
145
+	public function toASN1(): Sequence
146
+	{
147
+		$elements = array();
148
+		if (isset($this->_policyAuthority)) {
149
+			$elements[] = new ImplicitlyTaggedType(0,
150
+				$this->_policyAuthority->toASN1());
151
+		}
152
+		$values = array_map(
153
+			function (IetfAttrValue $val) {
154
+				return $val->toASN1();
155
+			}, $this->_values);
156
+		$elements[] = new Sequence(...$values);
157
+		return new Sequence(...$elements);
158
+	}
159 159
     
160
-    /**
161
-     *
162
-     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
163
-     * @return string
164
-     */
165
-    public function stringValue(): string
166
-    {
167
-        return "#" . bin2hex($this->toASN1()->toDER());
168
-    }
160
+	/**
161
+	 *
162
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
163
+	 * @return string
164
+	 */
165
+	public function stringValue(): string
166
+	{
167
+		return "#" . bin2hex($this->toASN1()->toDER());
168
+	}
169 169
     
170
-    /**
171
-     *
172
-     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
173
-     * @return BinaryMatch
174
-     */
175
-    public function equalityMatchingRule(): BinaryMatch
176
-    {
177
-        return new BinaryMatch();
178
-    }
170
+	/**
171
+	 *
172
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
173
+	 * @return BinaryMatch
174
+	 */
175
+	public function equalityMatchingRule(): BinaryMatch
176
+	{
177
+		return new BinaryMatch();
178
+	}
179 179
     
180
-    /**
181
-     *
182
-     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
183
-     * @return string
184
-     */
185
-    public function rfc2253String(): string
186
-    {
187
-        return $this->stringValue();
188
-    }
180
+	/**
181
+	 *
182
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
183
+	 * @return string
184
+	 */
185
+	public function rfc2253String(): string
186
+	{
187
+		return $this->stringValue();
188
+	}
189 189
     
190
-    /**
191
-     *
192
-     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
193
-     * @return string
194
-     */
195
-    protected function _transcodedString(): string
196
-    {
197
-        return $this->stringValue();
198
-    }
190
+	/**
191
+	 *
192
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
193
+	 * @return string
194
+	 */
195
+	protected function _transcodedString(): string
196
+	{
197
+		return $this->stringValue();
198
+	}
199 199
     
200
-    /**
201
-     * Get number of values.
202
-     *
203
-     * @see \Countable::count()
204
-     * @return int
205
-     */
206
-    public function count(): int
207
-    {
208
-        return count($this->_values);
209
-    }
200
+	/**
201
+	 * Get number of values.
202
+	 *
203
+	 * @see \Countable::count()
204
+	 * @return int
205
+	 */
206
+	public function count(): int
207
+	{
208
+		return count($this->_values);
209
+	}
210 210
     
211
-    /**
212
-     * Get iterator for values.
213
-     *
214
-     * @see \IteratorAggregate::getIterator()
215
-     * @return \ArrayIterator
216
-     */
217
-    public function getIterator(): \ArrayIterator
218
-    {
219
-        return new \ArrayIterator($this->_values);
220
-    }
211
+	/**
212
+	 * Get iterator for values.
213
+	 *
214
+	 * @see \IteratorAggregate::getIterator()
215
+	 * @return \ArrayIterator
216
+	 */
217
+	public function getIterator(): \ArrayIterator
218
+	{
219
+		return new \ArrayIterator($this->_values);
220
+	}
221 221
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/SvceAuthInfo.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -20,156 +20,156 @@
 block discarded – undo
20 20
  */
21 21
 abstract class SvceAuthInfo extends AttributeValue
22 22
 {
23
-    /**
24
-     * Service.
25
-     *
26
-     * @var GeneralName $_service
27
-     */
28
-    protected $_service;
23
+	/**
24
+	 * Service.
25
+	 *
26
+	 * @var GeneralName $_service
27
+	 */
28
+	protected $_service;
29 29
     
30
-    /**
31
-     * Ident.
32
-     *
33
-     * @var GeneralName $_ident
34
-     */
35
-    protected $_ident;
30
+	/**
31
+	 * Ident.
32
+	 *
33
+	 * @var GeneralName $_ident
34
+	 */
35
+	protected $_ident;
36 36
     
37
-    /**
38
-     * Auth info.
39
-     *
40
-     * @var string|null $_authInfo
41
-     */
42
-    protected $_authInfo;
37
+	/**
38
+	 * Auth info.
39
+	 *
40
+	 * @var string|null $_authInfo
41
+	 */
42
+	protected $_authInfo;
43 43
     
44
-    /**
45
-     * Constructor.
46
-     *
47
-     * @param GeneralName $service
48
-     * @param GeneralName $ident
49
-     * @param string|null $auth_info
50
-     */
51
-    public function __construct(GeneralName $service, GeneralName $ident,
52
-        string $auth_info = null)
53
-    {
54
-        $this->_service = $service;
55
-        $this->_ident = $ident;
56
-        $this->_authInfo = $auth_info;
57
-    }
44
+	/**
45
+	 * Constructor.
46
+	 *
47
+	 * @param GeneralName $service
48
+	 * @param GeneralName $ident
49
+	 * @param string|null $auth_info
50
+	 */
51
+	public function __construct(GeneralName $service, GeneralName $ident,
52
+		string $auth_info = null)
53
+	{
54
+		$this->_service = $service;
55
+		$this->_ident = $ident;
56
+		$this->_authInfo = $auth_info;
57
+	}
58 58
     
59
-    /**
60
-     *
61
-     * @param UnspecifiedType $el
62
-     * @return self
63
-     */
64
-    public static function fromASN1(UnspecifiedType $el)
65
-    {
66
-        $seq = $el->asSequence();
67
-        $service = GeneralName::fromASN1($seq->at(0)->asTagged());
68
-        $ident = GeneralName::fromASN1($seq->at(1)->asTagged());
69
-        $auth_info = null;
70
-        if ($seq->has(2, Element::TYPE_OCTET_STRING)) {
71
-            $auth_info = $seq->at(2)
72
-                ->asString()
73
-                ->string();
74
-        }
75
-        return new static($service, $ident, $auth_info);
76
-    }
59
+	/**
60
+	 *
61
+	 * @param UnspecifiedType $el
62
+	 * @return self
63
+	 */
64
+	public static function fromASN1(UnspecifiedType $el)
65
+	{
66
+		$seq = $el->asSequence();
67
+		$service = GeneralName::fromASN1($seq->at(0)->asTagged());
68
+		$ident = GeneralName::fromASN1($seq->at(1)->asTagged());
69
+		$auth_info = null;
70
+		if ($seq->has(2, Element::TYPE_OCTET_STRING)) {
71
+			$auth_info = $seq->at(2)
72
+				->asString()
73
+				->string();
74
+		}
75
+		return new static($service, $ident, $auth_info);
76
+	}
77 77
     
78
-    /**
79
-     * Get service name.
80
-     *
81
-     * @return GeneralName
82
-     */
83
-    public function service(): GeneralName
84
-    {
85
-        return $this->_service;
86
-    }
78
+	/**
79
+	 * Get service name.
80
+	 *
81
+	 * @return GeneralName
82
+	 */
83
+	public function service(): GeneralName
84
+	{
85
+		return $this->_service;
86
+	}
87 87
     
88
-    /**
89
-     * Get ident.
90
-     *
91
-     * @return GeneralName
92
-     */
93
-    public function ident(): GeneralName
94
-    {
95
-        return $this->_ident;
96
-    }
88
+	/**
89
+	 * Get ident.
90
+	 *
91
+	 * @return GeneralName
92
+	 */
93
+	public function ident(): GeneralName
94
+	{
95
+		return $this->_ident;
96
+	}
97 97
     
98
-    /**
99
-     * Check whether authentication info is present.
100
-     *
101
-     * @return bool
102
-     */
103
-    public function hasAuthInfo(): bool
104
-    {
105
-        return isset($this->_authInfo);
106
-    }
98
+	/**
99
+	 * Check whether authentication info is present.
100
+	 *
101
+	 * @return bool
102
+	 */
103
+	public function hasAuthInfo(): bool
104
+	{
105
+		return isset($this->_authInfo);
106
+	}
107 107
     
108
-    /**
109
-     * Get authentication info.
110
-     *
111
-     * @throws \LogicException
112
-     * @return string
113
-     */
114
-    public function authInfo(): string
115
-    {
116
-        if (!$this->hasAuthInfo()) {
117
-            throw new \LogicException("authInfo not set.");
118
-        }
119
-        return $this->_authInfo;
120
-    }
108
+	/**
109
+	 * Get authentication info.
110
+	 *
111
+	 * @throws \LogicException
112
+	 * @return string
113
+	 */
114
+	public function authInfo(): string
115
+	{
116
+		if (!$this->hasAuthInfo()) {
117
+			throw new \LogicException("authInfo not set.");
118
+		}
119
+		return $this->_authInfo;
120
+	}
121 121
     
122
-    /**
123
-     *
124
-     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
125
-     * @return Sequence
126
-     */
127
-    public function toASN1(): Sequence
128
-    {
129
-        $elements = array($this->_service->toASN1(), $this->_ident->toASN1());
130
-        if (isset($this->_authInfo)) {
131
-            $elements[] = new OctetString($this->_authInfo);
132
-        }
133
-        return new Sequence(...$elements);
134
-    }
122
+	/**
123
+	 *
124
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
125
+	 * @return Sequence
126
+	 */
127
+	public function toASN1(): Sequence
128
+	{
129
+		$elements = array($this->_service->toASN1(), $this->_ident->toASN1());
130
+		if (isset($this->_authInfo)) {
131
+			$elements[] = new OctetString($this->_authInfo);
132
+		}
133
+		return new Sequence(...$elements);
134
+	}
135 135
     
136
-    /**
137
-     *
138
-     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
139
-     * @return string
140
-     */
141
-    public function stringValue(): string
142
-    {
143
-        return "#" . bin2hex($this->toASN1()->toDER());
144
-    }
136
+	/**
137
+	 *
138
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
139
+	 * @return string
140
+	 */
141
+	public function stringValue(): string
142
+	{
143
+		return "#" . bin2hex($this->toASN1()->toDER());
144
+	}
145 145
     
146
-    /**
147
-     *
148
-     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
149
-     * @return BinaryMatch
150
-     */
151
-    public function equalityMatchingRule(): BinaryMatch
152
-    {
153
-        return new BinaryMatch();
154
-    }
146
+	/**
147
+	 *
148
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
149
+	 * @return BinaryMatch
150
+	 */
151
+	public function equalityMatchingRule(): BinaryMatch
152
+	{
153
+		return new BinaryMatch();
154
+	}
155 155
     
156
-    /**
157
-     *
158
-     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
159
-     * @return string
160
-     */
161
-    public function rfc2253String(): string
162
-    {
163
-        return $this->stringValue();
164
-    }
156
+	/**
157
+	 *
158
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
159
+	 * @return string
160
+	 */
161
+	public function rfc2253String(): string
162
+	{
163
+		return $this->stringValue();
164
+	}
165 165
     
166
-    /**
167
-     *
168
-     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
169
-     * @return string
170
-     */
171
-    protected function _transcodedString(): string
172
-    {
173
-        return $this->stringValue();
174
-    }
166
+	/**
167
+	 *
168
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
169
+	 * @return string
170
+	 */
171
+	protected function _transcodedString(): string
172
+	{
173
+		return $this->stringValue();
174
+	}
175 175
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/GroupAttributeValue.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
  */
12 12
 class GroupAttributeValue extends IetfAttrSyntax
13 13
 {
14
-    const OID = "1.3.6.1.5.5.7.10.4";
14
+	const OID = "1.3.6.1.5.5.7.10.4";
15 15
     
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param IetfAttrValue[] $values
20
-     */
21
-    public function __construct(IetfAttrValue ...$values)
22
-    {
23
-        parent::__construct(...$values);
24
-        $this->_oid = self::OID;
25
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param IetfAttrValue[] $values
20
+	 */
21
+	public function __construct(IetfAttrValue ...$values)
22
+	{
23
+		parent::__construct(...$values);
24
+		$this->_oid = self::OID;
25
+	}
26 26
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/IetfAttrValue.php 1 patch
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -17,161 +17,161 @@
 block discarded – undo
17 17
  */
18 18
 class IetfAttrValue
19 19
 {
20
-    /**
21
-     * Element type tag.
22
-     *
23
-     * @var int $_type
24
-     */
25
-    protected $_type;
20
+	/**
21
+	 * Element type tag.
22
+	 *
23
+	 * @var int $_type
24
+	 */
25
+	protected $_type;
26 26
     
27
-    /**
28
-     * Value.
29
-     *
30
-     * @var string $_value
31
-     */
32
-    protected $_value;
27
+	/**
28
+	 * Value.
29
+	 *
30
+	 * @var string $_value
31
+	 */
32
+	protected $_value;
33 33
     
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param string $value
38
-     * @param int $type
39
-     */
40
-    public function __construct(string $value, int $type)
41
-    {
42
-        $this->_type = $type;
43
-        $this->_value = $value;
44
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param string $value
38
+	 * @param int $type
39
+	 */
40
+	public function __construct(string $value, int $type)
41
+	{
42
+		$this->_type = $type;
43
+		$this->_value = $value;
44
+	}
45 45
     
46
-    /**
47
-     * Initialize from ASN.1.
48
-     *
49
-     * @param UnspecifiedType $el
50
-     * @throws \UnexpectedValueException
51
-     * @return self
52
-     */
53
-    public static function fromASN1(UnspecifiedType $el)
54
-    {
55
-        switch ($el->tag()) {
56
-            case Element::TYPE_OCTET_STRING:
57
-            case Element::TYPE_UTF8_STRING:
58
-                return new self($el->asString()->string(), $el->tag());
59
-            case Element::TYPE_OBJECT_IDENTIFIER:
60
-                return new self($el->asObjectIdentifier()->oid(), $el->tag());
61
-        }
62
-        throw new \UnexpectedValueException(
63
-            "Type " . Element::tagToName($el->tag()) . " not supported.");
64
-    }
46
+	/**
47
+	 * Initialize from ASN.1.
48
+	 *
49
+	 * @param UnspecifiedType $el
50
+	 * @throws \UnexpectedValueException
51
+	 * @return self
52
+	 */
53
+	public static function fromASN1(UnspecifiedType $el)
54
+	{
55
+		switch ($el->tag()) {
56
+			case Element::TYPE_OCTET_STRING:
57
+			case Element::TYPE_UTF8_STRING:
58
+				return new self($el->asString()->string(), $el->tag());
59
+			case Element::TYPE_OBJECT_IDENTIFIER:
60
+				return new self($el->asObjectIdentifier()->oid(), $el->tag());
61
+		}
62
+		throw new \UnexpectedValueException(
63
+			"Type " . Element::tagToName($el->tag()) . " not supported.");
64
+	}
65 65
     
66
-    /**
67
-     * Initialize from octet string.
68
-     *
69
-     * @param string $octets
70
-     * @return self
71
-     */
72
-    public static function fromOctets(string $octets)
73
-    {
74
-        return new self($octets, Element::TYPE_OCTET_STRING);
75
-    }
66
+	/**
67
+	 * Initialize from octet string.
68
+	 *
69
+	 * @param string $octets
70
+	 * @return self
71
+	 */
72
+	public static function fromOctets(string $octets)
73
+	{
74
+		return new self($octets, Element::TYPE_OCTET_STRING);
75
+	}
76 76
     
77
-    /**
78
-     * Initialize from UTF-8 string.
79
-     *
80
-     * @param string $str
81
-     * @return self
82
-     */
83
-    public static function fromString(string $str)
84
-    {
85
-        return new self($str, Element::TYPE_UTF8_STRING);
86
-    }
77
+	/**
78
+	 * Initialize from UTF-8 string.
79
+	 *
80
+	 * @param string $str
81
+	 * @return self
82
+	 */
83
+	public static function fromString(string $str)
84
+	{
85
+		return new self($str, Element::TYPE_UTF8_STRING);
86
+	}
87 87
     
88
-    /**
89
-     * Initialize from OID.
90
-     *
91
-     * @param string $oid
92
-     * @return self
93
-     */
94
-    public static function fromOID(string $oid)
95
-    {
96
-        return new self($oid, Element::TYPE_OBJECT_IDENTIFIER);
97
-    }
88
+	/**
89
+	 * Initialize from OID.
90
+	 *
91
+	 * @param string $oid
92
+	 * @return self
93
+	 */
94
+	public static function fromOID(string $oid)
95
+	{
96
+		return new self($oid, Element::TYPE_OBJECT_IDENTIFIER);
97
+	}
98 98
     
99
-    /**
100
-     * Get type tag.
101
-     *
102
-     * @return int
103
-     */
104
-    public function type(): int
105
-    {
106
-        return $this->_type;
107
-    }
99
+	/**
100
+	 * Get type tag.
101
+	 *
102
+	 * @return int
103
+	 */
104
+	public function type(): int
105
+	{
106
+		return $this->_type;
107
+	}
108 108
     
109
-    /**
110
-     * Whether value type is octets.
111
-     *
112
-     * @return bool
113
-     */
114
-    public function isOctets(): bool
115
-    {
116
-        return $this->_type === Element::TYPE_OCTET_STRING;
117
-    }
109
+	/**
110
+	 * Whether value type is octets.
111
+	 *
112
+	 * @return bool
113
+	 */
114
+	public function isOctets(): bool
115
+	{
116
+		return $this->_type === Element::TYPE_OCTET_STRING;
117
+	}
118 118
     
119
-    /**
120
-     * Whether value type is OID.
121
-     *
122
-     * @return bool
123
-     */
124
-    public function isOID(): bool
125
-    {
126
-        return $this->_type === Element::TYPE_OBJECT_IDENTIFIER;
127
-    }
119
+	/**
120
+	 * Whether value type is OID.
121
+	 *
122
+	 * @return bool
123
+	 */
124
+	public function isOID(): bool
125
+	{
126
+		return $this->_type === Element::TYPE_OBJECT_IDENTIFIER;
127
+	}
128 128
     
129
-    /**
130
-     * Whether value type is string.
131
-     *
132
-     * @return bool
133
-     */
134
-    public function isString(): bool
135
-    {
136
-        return $this->_type === Element::TYPE_UTF8_STRING;
137
-    }
129
+	/**
130
+	 * Whether value type is string.
131
+	 *
132
+	 * @return bool
133
+	 */
134
+	public function isString(): bool
135
+	{
136
+		return $this->_type === Element::TYPE_UTF8_STRING;
137
+	}
138 138
     
139
-    /**
140
-     * Get value.
141
-     *
142
-     * @return string
143
-     */
144
-    public function value(): string
145
-    {
146
-        return $this->_value;
147
-    }
139
+	/**
140
+	 * Get value.
141
+	 *
142
+	 * @return string
143
+	 */
144
+	public function value(): string
145
+	{
146
+		return $this->_value;
147
+	}
148 148
     
149
-    /**
150
-     * Generate ASN.1 structure.
151
-     *
152
-     * @throws \LogicException
153
-     * @return Element
154
-     */
155
-    public function toASN1(): Element
156
-    {
157
-        switch ($this->_type) {
158
-            case Element::TYPE_OCTET_STRING:
159
-                return new OctetString($this->_value);
160
-            case Element::TYPE_UTF8_STRING:
161
-                return new UTF8String($this->_value);
162
-            case Element::TYPE_OBJECT_IDENTIFIER:
163
-                return new ObjectIdentifier($this->_value);
164
-        }
165
-        throw new \LogicException(
166
-            "Type " . Element::tagToName($this->_type) . " not supported.");
167
-    }
149
+	/**
150
+	 * Generate ASN.1 structure.
151
+	 *
152
+	 * @throws \LogicException
153
+	 * @return Element
154
+	 */
155
+	public function toASN1(): Element
156
+	{
157
+		switch ($this->_type) {
158
+			case Element::TYPE_OCTET_STRING:
159
+				return new OctetString($this->_value);
160
+			case Element::TYPE_UTF8_STRING:
161
+				return new UTF8String($this->_value);
162
+			case Element::TYPE_OBJECT_IDENTIFIER:
163
+				return new ObjectIdentifier($this->_value);
164
+		}
165
+		throw new \LogicException(
166
+			"Type " . Element::tagToName($this->_type) . " not supported.");
167
+	}
168 168
     
169
-    /**
170
-     *
171
-     * @return string
172
-     */
173
-    public function __toString()
174
-    {
175
-        return $this->_value;
176
-    }
169
+	/**
170
+	 *
171
+	 * @return string
172
+	 */
173
+	public function __toString()
174
+	{
175
+		return $this->_value;
176
+	}
177 177
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/ChargingIdentityAttributeValue.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
  */
12 12
 class ChargingIdentityAttributeValue extends IetfAttrSyntax
13 13
 {
14
-    const OID = "1.3.6.1.5.5.7.10.3";
14
+	const OID = "1.3.6.1.5.5.7.10.3";
15 15
     
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param IetfAttrValue[] $values
20
-     */
21
-    public function __construct(IetfAttrValue ...$values)
22
-    {
23
-        parent::__construct(...$values);
24
-        $this->_oid = self::OID;
25
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param IetfAttrValue[] $values
20
+	 */
21
+	public function __construct(IetfAttrValue ...$values)
22
+	{
23
+		parent::__construct(...$values);
24
+		$this->_oid = self::OID;
25
+	}
26 26
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/RoleAttributeValue.php 1 patch
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -23,154 +23,154 @@
 block discarded – undo
23 23
  */
24 24
 class RoleAttributeValue extends AttributeValue
25 25
 {
26
-    /**
27
-     * Issuing authority.
28
-     *
29
-     * @var GeneralNames $_roleAuthority
30
-     */
31
-    protected $_roleAuthority;
26
+	/**
27
+	 * Issuing authority.
28
+	 *
29
+	 * @var GeneralNames $_roleAuthority
30
+	 */
31
+	protected $_roleAuthority;
32 32
     
33
-    /**
34
-     * Role name.
35
-     *
36
-     * @var GeneralName $_roleName
37
-     */
38
-    protected $_roleName;
33
+	/**
34
+	 * Role name.
35
+	 *
36
+	 * @var GeneralName $_roleName
37
+	 */
38
+	protected $_roleName;
39 39
     
40
-    /**
41
-     * Constructor.
42
-     *
43
-     * @param GeneralName $name Role name
44
-     * @param GeneralNames|null $authority Issuing authority
45
-     */
46
-    public function __construct(GeneralName $name, GeneralNames $authority = null)
47
-    {
48
-        $this->_roleAuthority = $authority;
49
-        $this->_roleName = $name;
50
-        $this->_oid = AttributeType::OID_ROLE;
51
-    }
40
+	/**
41
+	 * Constructor.
42
+	 *
43
+	 * @param GeneralName $name Role name
44
+	 * @param GeneralNames|null $authority Issuing authority
45
+	 */
46
+	public function __construct(GeneralName $name, GeneralNames $authority = null)
47
+	{
48
+		$this->_roleAuthority = $authority;
49
+		$this->_roleName = $name;
50
+		$this->_oid = AttributeType::OID_ROLE;
51
+	}
52 52
     
53
-    /**
54
-     * Initialize from a role string.
55
-     *
56
-     * @param string $role_name Role name in URI format
57
-     * @param GeneralNames|null $authority Issuing authority
58
-     * @return self
59
-     */
60
-    public static function fromString(string $role_name, GeneralNames $authority = null)
61
-    {
62
-        return new self(new UniformResourceIdentifier($role_name), $authority);
63
-    }
53
+	/**
54
+	 * Initialize from a role string.
55
+	 *
56
+	 * @param string $role_name Role name in URI format
57
+	 * @param GeneralNames|null $authority Issuing authority
58
+	 * @return self
59
+	 */
60
+	public static function fromString(string $role_name, GeneralNames $authority = null)
61
+	{
62
+		return new self(new UniformResourceIdentifier($role_name), $authority);
63
+	}
64 64
     
65
-    /**
66
-     *
67
-     * @param UnspecifiedType $el
68
-     * @return self
69
-     */
70
-    public static function fromASN1(UnspecifiedType $el)
71
-    {
72
-        $seq = $el->asSequence();
73
-        $authority = null;
74
-        if ($seq->hasTagged(0)) {
75
-            $authority = GeneralNames::fromASN1(
76
-                $seq->getTagged(0)
77
-                    ->asImplicit(Element::TYPE_SEQUENCE)
78
-                    ->asSequence());
79
-        }
80
-        $name = GeneralName::fromASN1(
81
-            $seq->getTagged(1)
82
-                ->asExplicit()
83
-                ->asTagged());
84
-        return new self($name, $authority);
85
-    }
65
+	/**
66
+	 *
67
+	 * @param UnspecifiedType $el
68
+	 * @return self
69
+	 */
70
+	public static function fromASN1(UnspecifiedType $el)
71
+	{
72
+		$seq = $el->asSequence();
73
+		$authority = null;
74
+		if ($seq->hasTagged(0)) {
75
+			$authority = GeneralNames::fromASN1(
76
+				$seq->getTagged(0)
77
+					->asImplicit(Element::TYPE_SEQUENCE)
78
+					->asSequence());
79
+		}
80
+		$name = GeneralName::fromASN1(
81
+			$seq->getTagged(1)
82
+				->asExplicit()
83
+				->asTagged());
84
+		return new self($name, $authority);
85
+	}
86 86
     
87
-    /**
88
-     * Check whether issuing authority is present.
89
-     *
90
-     * @return bool
91
-     */
92
-    public function hasRoleAuthority(): bool
93
-    {
94
-        return isset($this->_roleAuthority);
95
-    }
87
+	/**
88
+	 * Check whether issuing authority is present.
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function hasRoleAuthority(): bool
93
+	{
94
+		return isset($this->_roleAuthority);
95
+	}
96 96
     
97
-    /**
98
-     * Get issuing authority.
99
-     *
100
-     * @throws \LogicException
101
-     * @return GeneralNames
102
-     */
103
-    public function roleAuthority(): GeneralNames
104
-    {
105
-        if (!$this->hasRoleAuthority()) {
106
-            throw new \LogicException("roleAuthority not set.");
107
-        }
108
-        return $this->_roleAuthority;
109
-    }
97
+	/**
98
+	 * Get issuing authority.
99
+	 *
100
+	 * @throws \LogicException
101
+	 * @return GeneralNames
102
+	 */
103
+	public function roleAuthority(): GeneralNames
104
+	{
105
+		if (!$this->hasRoleAuthority()) {
106
+			throw new \LogicException("roleAuthority not set.");
107
+		}
108
+		return $this->_roleAuthority;
109
+	}
110 110
     
111
-    /**
112
-     * Get role name.
113
-     *
114
-     * @return GeneralName
115
-     */
116
-    public function roleName(): GeneralName
117
-    {
118
-        return $this->_roleName;
119
-    }
111
+	/**
112
+	 * Get role name.
113
+	 *
114
+	 * @return GeneralName
115
+	 */
116
+	public function roleName(): GeneralName
117
+	{
118
+		return $this->_roleName;
119
+	}
120 120
     
121
-    /**
122
-     *
123
-     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
124
-     * @return Sequence
125
-     */
126
-    public function toASN1(): Sequence
127
-    {
128
-        $elements = array();
129
-        if (isset($this->_roleAuthority)) {
130
-            $elements[] = new ImplicitlyTaggedType(0,
131
-                $this->_roleAuthority->toASN1());
132
-        }
133
-        $elements[] = new ExplicitlyTaggedType(1, $this->_roleName->toASN1());
134
-        return new Sequence(...$elements);
135
-    }
121
+	/**
122
+	 *
123
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
124
+	 * @return Sequence
125
+	 */
126
+	public function toASN1(): Sequence
127
+	{
128
+		$elements = array();
129
+		if (isset($this->_roleAuthority)) {
130
+			$elements[] = new ImplicitlyTaggedType(0,
131
+				$this->_roleAuthority->toASN1());
132
+		}
133
+		$elements[] = new ExplicitlyTaggedType(1, $this->_roleName->toASN1());
134
+		return new Sequence(...$elements);
135
+	}
136 136
     
137
-    /**
138
-     *
139
-     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
140
-     * @return string
141
-     */
142
-    public function stringValue(): string
143
-    {
144
-        return "#" . bin2hex($this->toASN1()->toDER());
145
-    }
137
+	/**
138
+	 *
139
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
140
+	 * @return string
141
+	 */
142
+	public function stringValue(): string
143
+	{
144
+		return "#" . bin2hex($this->toASN1()->toDER());
145
+	}
146 146
     
147
-    /**
148
-     *
149
-     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
150
-     * @return BinaryMatch
151
-     */
152
-    public function equalityMatchingRule(): BinaryMatch
153
-    {
154
-        return new BinaryMatch();
155
-    }
147
+	/**
148
+	 *
149
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
150
+	 * @return BinaryMatch
151
+	 */
152
+	public function equalityMatchingRule(): BinaryMatch
153
+	{
154
+		return new BinaryMatch();
155
+	}
156 156
     
157
-    /**
158
-     *
159
-     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
160
-     * @return string
161
-     */
162
-    public function rfc2253String(): string
163
-    {
164
-        return $this->stringValue();
165
-    }
157
+	/**
158
+	 *
159
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
160
+	 * @return string
161
+	 */
162
+	public function rfc2253String(): string
163
+	{
164
+		return $this->stringValue();
165
+	}
166 166
     
167
-    /**
168
-     *
169
-     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
170
-     * @return string
171
-     */
172
-    protected function _transcodedString(): string
173
-    {
174
-        return $this->stringValue();
175
-    }
167
+	/**
168
+	 *
169
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
170
+	 * @return string
171
+	 */
172
+	protected function _transcodedString(): string
173
+	{
174
+		return $this->stringValue();
175
+	}
176 176
 }
Please login to merge, or discard this patch.
X509/AttributeCertificate/Attribute/AuthenticationInfoAttributeValue.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
  */
14 14
 class AuthenticationInfoAttributeValue extends SvceAuthInfo
15 15
 {
16
-    const OID = "1.3.6.1.5.5.7.10.1";
16
+	const OID = "1.3.6.1.5.5.7.10.1";
17 17
     
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param GeneralName $service
22
-     * @param GeneralName $ident
23
-     * @param string|null $auth_info
24
-     */
25
-    public function __construct(GeneralName $service, GeneralName $ident,
26
-        string $auth_info = null)
27
-    {
28
-        parent::__construct($service, $ident, $auth_info);
29
-        $this->_oid = self::OID;
30
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param GeneralName $service
22
+	 * @param GeneralName $ident
23
+	 * @param string|null $auth_info
24
+	 */
25
+	public function __construct(GeneralName $service, GeneralName $ident,
26
+		string $auth_info = null)
27
+	{
28
+		parent::__construct($service, $ident, $auth_info);
29
+		$this->_oid = self::OID;
30
+	}
31 31
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/AttributeCertificate.php 1 patch
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -20,203 +20,203 @@
 block discarded – undo
20 20
  */
21 21
 class AttributeCertificate
22 22
 {
23
-    /**
24
-     * Attribute certificate info.
25
-     *
26
-     * @var AttributeCertificateInfo $_acinfo
27
-     */
28
-    protected $_acinfo;
29
-    
30
-    /**
31
-     * Signature algorithm identifier.
32
-     *
33
-     * @var SignatureAlgorithmIdentifier $_signatureAlgorithm
34
-     */
35
-    protected $_signatureAlgorithm;
36
-    
37
-    /**
38
-     * Signature value.
39
-     *
40
-     * @var Signature $_signatureValue
41
-     */
42
-    protected $_signatureValue;
43
-    
44
-    /**
45
-     * Constructor.
46
-     *
47
-     * @param AttributeCertificateInfo $acinfo
48
-     * @param SignatureAlgorithmIdentifier $algo
49
-     * @param Signature $signature
50
-     */
51
-    public function __construct(AttributeCertificateInfo $acinfo,
52
-        SignatureAlgorithmIdentifier $algo, Signature $signature)
53
-    {
54
-        $this->_acinfo = $acinfo;
55
-        $this->_signatureAlgorithm = $algo;
56
-        $this->_signatureValue = $signature;
57
-    }
58
-    
59
-    /**
60
-     * Initialize from ASN.1.
61
-     *
62
-     * @param Sequence $seq
63
-     * @return self
64
-     */
65
-    public static function fromASN1(Sequence $seq)
66
-    {
67
-        $acinfo = AttributeCertificateInfo::fromASN1($seq->at(0)->asSequence());
68
-        $algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
69
-        if (!$algo instanceof SignatureAlgorithmIdentifier) {
70
-            throw new \UnexpectedValueException(
71
-                "Unsupported signature algorithm " . $algo->oid() . ".");
72
-        }
73
-        $signature = Signature::fromSignatureData(
74
-            $seq->at(2)
75
-                ->asBitString()
76
-                ->string(), $algo);
77
-        return new self($acinfo, $algo, $signature);
78
-    }
79
-    
80
-    /**
81
-     * Initialize from DER data.
82
-     *
83
-     * @param string $data
84
-     * @return self
85
-     */
86
-    public static function fromDER(string $data)
87
-    {
88
-        return self::fromASN1(Sequence::fromDER($data));
89
-    }
90
-    
91
-    /**
92
-     * Initialize from PEM.
93
-     *
94
-     * @param PEM $pem
95
-     * @throws \UnexpectedValueException
96
-     * @return self
97
-     */
98
-    public static function fromPEM(PEM $pem)
99
-    {
100
-        if ($pem->type() !== PEM::TYPE_ATTRIBUTE_CERTIFICATE) {
101
-            throw new \UnexpectedValueException("Invalid PEM type.");
102
-        }
103
-        return self::fromDER($pem->data());
104
-    }
105
-    
106
-    /**
107
-     * Get attribute certificate info.
108
-     *
109
-     * @return AttributeCertificateInfo
110
-     */
111
-    public function acinfo(): AttributeCertificateInfo
112
-    {
113
-        return $this->_acinfo;
114
-    }
115
-    
116
-    /**
117
-     * Get signature algorithm identifier.
118
-     *
119
-     * @return SignatureAlgorithmIdentifier
120
-     */
121
-    public function signatureAlgorithm(): SignatureAlgorithmIdentifier
122
-    {
123
-        return $this->_signatureAlgorithm;
124
-    }
125
-    
126
-    /**
127
-     * Get signature value.
128
-     *
129
-     * @return Signature
130
-     */
131
-    public function signatureValue(): Signature
132
-    {
133
-        return $this->_signatureValue;
134
-    }
135
-    
136
-    /**
137
-     * Get ASN.1 structure.
138
-     *
139
-     * @return Sequence
140
-     */
141
-    public function toASN1(): Sequence
142
-    {
143
-        return new Sequence($this->_acinfo->toASN1(),
144
-            $this->_signatureAlgorithm->toASN1(),
145
-            $this->_signatureValue->bitString());
146
-    }
147
-    
148
-    /**
149
-     * Get attribute certificate as a DER.
150
-     *
151
-     * @return string
152
-     */
153
-    public function toDER(): string
154
-    {
155
-        return $this->toASN1()->toDER();
156
-    }
157
-    
158
-    /**
159
-     * Get attribute certificate as a PEM.
160
-     *
161
-     * @return PEM
162
-     */
163
-    public function toPEM(): PEM
164
-    {
165
-        return new PEM(PEM::TYPE_ATTRIBUTE_CERTIFICATE, $this->toDER());
166
-    }
167
-    
168
-    /**
169
-     * Check whether attribute certificate is issued to the subject identified
170
-     * by given public key certificate.
171
-     *
172
-     * @param Certificate $cert Certificate
173
-     * @return boolean
174
-     */
175
-    public function isHeldBy(Certificate $cert): bool
176
-    {
177
-        if (!$this->_acinfo->holder()->identifiesPKC($cert)) {
178
-            return false;
179
-        }
180
-        return true;
181
-    }
182
-    
183
-    /**
184
-     * Check whether attribute certificate is issued by given public key
185
-     * certificate.
186
-     *
187
-     * @param Certificate $cert Certificate
188
-     * @return boolean
189
-     */
190
-    public function isIssuedBy(Certificate $cert): bool
191
-    {
192
-        if (!$this->_acinfo->issuer()->identifiesPKC($cert)) {
193
-            return false;
194
-        }
195
-        return true;
196
-    }
197
-    
198
-    /**
199
-     * Verify signature.
200
-     *
201
-     * @param PublicKeyInfo $pubkey_info Signer's public key
202
-     * @param Crypto|null $crypto Crypto engine, use default if not set
203
-     * @return bool
204
-     */
205
-    public function verify(PublicKeyInfo $pubkey_info, Crypto $crypto = null): bool
206
-    {
207
-        $crypto = $crypto ?: Crypto::getDefault();
208
-        $data = $this->_acinfo->toASN1()->toDER();
209
-        return $crypto->verify($data, $this->_signatureValue, $pubkey_info,
210
-            $this->_signatureAlgorithm);
211
-    }
212
-    
213
-    /**
214
-     * Get attribute certificate as a PEM formatted string.
215
-     *
216
-     * @return string
217
-     */
218
-    public function __toString()
219
-    {
220
-        return $this->toPEM()->string();
221
-    }
23
+	/**
24
+	 * Attribute certificate info.
25
+	 *
26
+	 * @var AttributeCertificateInfo $_acinfo
27
+	 */
28
+	protected $_acinfo;
29
+    
30
+	/**
31
+	 * Signature algorithm identifier.
32
+	 *
33
+	 * @var SignatureAlgorithmIdentifier $_signatureAlgorithm
34
+	 */
35
+	protected $_signatureAlgorithm;
36
+    
37
+	/**
38
+	 * Signature value.
39
+	 *
40
+	 * @var Signature $_signatureValue
41
+	 */
42
+	protected $_signatureValue;
43
+    
44
+	/**
45
+	 * Constructor.
46
+	 *
47
+	 * @param AttributeCertificateInfo $acinfo
48
+	 * @param SignatureAlgorithmIdentifier $algo
49
+	 * @param Signature $signature
50
+	 */
51
+	public function __construct(AttributeCertificateInfo $acinfo,
52
+		SignatureAlgorithmIdentifier $algo, Signature $signature)
53
+	{
54
+		$this->_acinfo = $acinfo;
55
+		$this->_signatureAlgorithm = $algo;
56
+		$this->_signatureValue = $signature;
57
+	}
58
+    
59
+	/**
60
+	 * Initialize from ASN.1.
61
+	 *
62
+	 * @param Sequence $seq
63
+	 * @return self
64
+	 */
65
+	public static function fromASN1(Sequence $seq)
66
+	{
67
+		$acinfo = AttributeCertificateInfo::fromASN1($seq->at(0)->asSequence());
68
+		$algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
69
+		if (!$algo instanceof SignatureAlgorithmIdentifier) {
70
+			throw new \UnexpectedValueException(
71
+				"Unsupported signature algorithm " . $algo->oid() . ".");
72
+		}
73
+		$signature = Signature::fromSignatureData(
74
+			$seq->at(2)
75
+				->asBitString()
76
+				->string(), $algo);
77
+		return new self($acinfo, $algo, $signature);
78
+	}
79
+    
80
+	/**
81
+	 * Initialize from DER data.
82
+	 *
83
+	 * @param string $data
84
+	 * @return self
85
+	 */
86
+	public static function fromDER(string $data)
87
+	{
88
+		return self::fromASN1(Sequence::fromDER($data));
89
+	}
90
+    
91
+	/**
92
+	 * Initialize from PEM.
93
+	 *
94
+	 * @param PEM $pem
95
+	 * @throws \UnexpectedValueException
96
+	 * @return self
97
+	 */
98
+	public static function fromPEM(PEM $pem)
99
+	{
100
+		if ($pem->type() !== PEM::TYPE_ATTRIBUTE_CERTIFICATE) {
101
+			throw new \UnexpectedValueException("Invalid PEM type.");
102
+		}
103
+		return self::fromDER($pem->data());
104
+	}
105
+    
106
+	/**
107
+	 * Get attribute certificate info.
108
+	 *
109
+	 * @return AttributeCertificateInfo
110
+	 */
111
+	public function acinfo(): AttributeCertificateInfo
112
+	{
113
+		return $this->_acinfo;
114
+	}
115
+    
116
+	/**
117
+	 * Get signature algorithm identifier.
118
+	 *
119
+	 * @return SignatureAlgorithmIdentifier
120
+	 */
121
+	public function signatureAlgorithm(): SignatureAlgorithmIdentifier
122
+	{
123
+		return $this->_signatureAlgorithm;
124
+	}
125
+    
126
+	/**
127
+	 * Get signature value.
128
+	 *
129
+	 * @return Signature
130
+	 */
131
+	public function signatureValue(): Signature
132
+	{
133
+		return $this->_signatureValue;
134
+	}
135
+    
136
+	/**
137
+	 * Get ASN.1 structure.
138
+	 *
139
+	 * @return Sequence
140
+	 */
141
+	public function toASN1(): Sequence
142
+	{
143
+		return new Sequence($this->_acinfo->toASN1(),
144
+			$this->_signatureAlgorithm->toASN1(),
145
+			$this->_signatureValue->bitString());
146
+	}
147
+    
148
+	/**
149
+	 * Get attribute certificate as a DER.
150
+	 *
151
+	 * @return string
152
+	 */
153
+	public function toDER(): string
154
+	{
155
+		return $this->toASN1()->toDER();
156
+	}
157
+    
158
+	/**
159
+	 * Get attribute certificate as a PEM.
160
+	 *
161
+	 * @return PEM
162
+	 */
163
+	public function toPEM(): PEM
164
+	{
165
+		return new PEM(PEM::TYPE_ATTRIBUTE_CERTIFICATE, $this->toDER());
166
+	}
167
+    
168
+	/**
169
+	 * Check whether attribute certificate is issued to the subject identified
170
+	 * by given public key certificate.
171
+	 *
172
+	 * @param Certificate $cert Certificate
173
+	 * @return boolean
174
+	 */
175
+	public function isHeldBy(Certificate $cert): bool
176
+	{
177
+		if (!$this->_acinfo->holder()->identifiesPKC($cert)) {
178
+			return false;
179
+		}
180
+		return true;
181
+	}
182
+    
183
+	/**
184
+	 * Check whether attribute certificate is issued by given public key
185
+	 * certificate.
186
+	 *
187
+	 * @param Certificate $cert Certificate
188
+	 * @return boolean
189
+	 */
190
+	public function isIssuedBy(Certificate $cert): bool
191
+	{
192
+		if (!$this->_acinfo->issuer()->identifiesPKC($cert)) {
193
+			return false;
194
+		}
195
+		return true;
196
+	}
197
+    
198
+	/**
199
+	 * Verify signature.
200
+	 *
201
+	 * @param PublicKeyInfo $pubkey_info Signer's public key
202
+	 * @param Crypto|null $crypto Crypto engine, use default if not set
203
+	 * @return bool
204
+	 */
205
+	public function verify(PublicKeyInfo $pubkey_info, Crypto $crypto = null): bool
206
+	{
207
+		$crypto = $crypto ?: Crypto::getDefault();
208
+		$data = $this->_acinfo->toASN1()->toDER();
209
+		return $crypto->verify($data, $this->_signatureValue, $pubkey_info,
210
+			$this->_signatureAlgorithm);
211
+	}
212
+    
213
+	/**
214
+	 * Get attribute certificate as a PEM formatted string.
215
+	 *
216
+	 * @return string
217
+	 */
218
+	public function __toString()
219
+	{
220
+		return $this->toPEM()->string();
221
+	}
222 222
 }
Please login to merge, or discard this patch.