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.
Completed
Push — master ( ff3a63...584877 )
by Joni
04:52
created
examples/issue-cert.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@
 block discarded – undo
25 25
 $csr = CertificationRequest::fromPEM(PEM::fromFile($argv[2]));
26 26
 // verify CSR
27 27
 if (!$csr->verify()) {
28
-    echo "Failed to verify certification request signature.\n";
29
-    exit(1);
28
+	echo "Failed to verify certification request signature.\n";
29
+	exit(1);
30 30
 }
31 31
 // load CA's private key from PEM
32 32
 $private_key_info = PrivateKeyInfo::fromPEM(
33
-    PEM::fromFile(dirname(__DIR__) . "/test/assets/rsa/private_key.pem"));
33
+	PEM::fromFile(dirname(__DIR__) . "/test/assets/rsa/private_key.pem"));
34 34
 // initialize certificate from CSR and issuer's certificate
35 35
 $tbs_cert = TBSCertificate::fromCSR($csr)->withIssuerCertificate($issuer_cert);
36 36
 // set random serial number
37 37
 $tbs_cert = $tbs_cert->withRandomSerialNumber();
38 38
 // set validity period
39 39
 $tbs_cert = $tbs_cert->withValidity(
40
-    Validity::fromStrings("now", "now + 3 months"));
40
+	Validity::fromStrings("now", "now + 3 months"));
41 41
 // add extensions
42 42
 $tbs_cert = $tbs_cert->withAdditionalExtensions(
43
-    new KeyUsageExtension(true,
44
-        KeyUsageExtension::DIGITAL_SIGNATURE |
45
-             KeyUsageExtension::KEY_ENCIPHERMENT),
46
-    new BasicConstraintsExtension(true, false));
43
+	new KeyUsageExtension(true,
44
+		KeyUsageExtension::DIGITAL_SIGNATURE |
45
+			 KeyUsageExtension::KEY_ENCIPHERMENT),
46
+	new BasicConstraintsExtension(true, false));
47 47
 // sign certificate with issuer's private key
48 48
 $algo = SignatureAlgorithmIdentifierFactory::algoForAsymmetricCrypto(
49
-    $private_key_info->algorithmIdentifier(), new SHA512AlgorithmIdentifier());
49
+	$private_key_info->algorithmIdentifier(), new SHA512AlgorithmIdentifier());
50 50
 $cert = $tbs_cert->sign($algo, $private_key_info);
51 51
 echo $cert;
Please login to merge, or discard this patch.
examples/create-csr.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 // load EC private key from PEM
18 18
 $private_key_info = PrivateKeyInfo::fromPEM(
19
-    PEM::fromFile(dirname(__DIR__) . "/test/assets/ec/private_key.pem"));
19
+	PEM::fromFile(dirname(__DIR__) . "/test/assets/ec/private_key.pem"));
20 20
 // extract public key from private key
21 21
 $public_key_info = $private_key_info->publicKeyInfo();
22 22
 // DN of the subject
@@ -25,6 +25,6 @@  discard block
 block discarded – undo
25 25
 $cri = new CertificationRequestInfo($subject, $public_key_info);
26 26
 // sign certificate request with private key
27 27
 $algo = SignatureAlgorithmIdentifierFactory::algoForAsymmetricCrypto(
28
-    $private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier());
28
+	$private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier());
29 29
 $csr = $cri->sign($algo, $private_key_info);
30 30
 echo $csr;
Please login to merge, or discard this patch.
examples/path-validate.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,19 +28,19 @@
 block discarded – undo
28 28
 // build certification path from CA to end-entity certificate
29 29
 $path = CertificationPath::fromTrustAnchorToTarget($ca, $cert);
30 30
 foreach ($path->certificates() as $idx => $cert) {
31
-    printf("#%d: %s\n", $idx,
32
-        $cert->tbsCertificate()
33
-            ->subject()
34
-            ->toString());
31
+	printf("#%d: %s\n", $idx,
32
+		$cert->tbsCertificate()
33
+			->subject()
34
+			->toString());
35 35
 }
36 36
 // validate certification path with default configuration
37 37
 $config = PathValidationConfig::defaultConfig();
38 38
 $result = $path->validate($config);
39 39
 printf("Certificate '%s' is valid.\n",
40
-    $result->certificate()
41
-        ->tbsCertificate()
42
-        ->subject()
43
-        ->toString());
40
+	$result->certificate()
41
+		->tbsCertificate()
42
+		->subject()
43
+		->toString());
44 44
 // remove temporary files
45 45
 unlink($ca_file);
46 46
 unlink($csr_file);
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/PolicyQualifierInfo.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -14,85 +14,85 @@
 block discarded – undo
14 14
  */
15 15
 abstract class PolicyQualifierInfo
16 16
 {
17
-    /**
18
-     * OID for the CPS Pointer qualifier.
19
-     *
20
-     * @var string
21
-     */
22
-    const OID_CPS = "1.3.6.1.5.5.7.2.1";
17
+	/**
18
+	 * OID for the CPS Pointer qualifier.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	const OID_CPS = "1.3.6.1.5.5.7.2.1";
23 23
     
24
-    /**
25
-     * OID for the user notice qualifier.
26
-     *
27
-     * @var string
28
-     */
29
-    const OID_UNOTICE = "1.3.6.1.5.5.7.2.2";
24
+	/**
25
+	 * OID for the user notice qualifier.
26
+	 *
27
+	 * @var string
28
+	 */
29
+	const OID_UNOTICE = "1.3.6.1.5.5.7.2.2";
30 30
     
31
-    /**
32
-     * Qualifier identifier.
33
-     *
34
-     * @var string $_oid
35
-     */
36
-    protected $_oid;
31
+	/**
32
+	 * Qualifier identifier.
33
+	 *
34
+	 * @var string $_oid
35
+	 */
36
+	protected $_oid;
37 37
     
38
-    /**
39
-     * Generate ASN.1 for the 'qualifier' field.
40
-     *
41
-     * @return \ASN1\Element
42
-     */
43
-    abstract protected function _qualifierASN1();
38
+	/**
39
+	 * Generate ASN.1 for the 'qualifier' field.
40
+	 *
41
+	 * @return \ASN1\Element
42
+	 */
43
+	abstract protected function _qualifierASN1();
44 44
     
45
-    /**
46
-     * Initialize from qualifier ASN.1 element.
47
-     *
48
-     * @param UnspecifiedType $el
49
-     * @return self
50
-     */
51
-    public static function fromQualifierASN1(UnspecifiedType $el)
52
-    {
53
-        throw new \BadMethodCallException(
54
-            __FUNCTION__ . " must be implemented in the derived class.");
55
-    }
45
+	/**
46
+	 * Initialize from qualifier ASN.1 element.
47
+	 *
48
+	 * @param UnspecifiedType $el
49
+	 * @return self
50
+	 */
51
+	public static function fromQualifierASN1(UnspecifiedType $el)
52
+	{
53
+		throw new \BadMethodCallException(
54
+			__FUNCTION__ . " must be implemented in the derived class.");
55
+	}
56 56
     
57
-    /**
58
-     * Initialize from ASN.1.
59
-     *
60
-     * @param Sequence $seq
61
-     * @throws \UnexpectedValueException
62
-     * @return self
63
-     */
64
-    public static function fromASN1(Sequence $seq)
65
-    {
66
-        $oid = $seq->at(0)
67
-            ->asObjectIdentifier()
68
-            ->oid();
69
-        switch ($oid) {
70
-            case self::OID_CPS:
71
-                return CPSQualifier::fromQualifierASN1($seq->at(1));
72
-            case self::OID_UNOTICE:
73
-                return UserNoticeQualifier::fromQualifierASN1($seq->at(1));
74
-        }
75
-        throw new \UnexpectedValueException("Qualifier $oid not supported.");
76
-    }
57
+	/**
58
+	 * Initialize from ASN.1.
59
+	 *
60
+	 * @param Sequence $seq
61
+	 * @throws \UnexpectedValueException
62
+	 * @return self
63
+	 */
64
+	public static function fromASN1(Sequence $seq)
65
+	{
66
+		$oid = $seq->at(0)
67
+			->asObjectIdentifier()
68
+			->oid();
69
+		switch ($oid) {
70
+			case self::OID_CPS:
71
+				return CPSQualifier::fromQualifierASN1($seq->at(1));
72
+			case self::OID_UNOTICE:
73
+				return UserNoticeQualifier::fromQualifierASN1($seq->at(1));
74
+		}
75
+		throw new \UnexpectedValueException("Qualifier $oid not supported.");
76
+	}
77 77
     
78
-    /**
79
-     * Get qualifier identifier.
80
-     *
81
-     * @return string
82
-     */
83
-    public function oid()
84
-    {
85
-        return $this->_oid;
86
-    }
78
+	/**
79
+	 * Get qualifier identifier.
80
+	 *
81
+	 * @return string
82
+	 */
83
+	public function oid()
84
+	{
85
+		return $this->_oid;
86
+	}
87 87
     
88
-    /**
89
-     * Generate ASN.1 structure.
90
-     *
91
-     * @return Sequence
92
-     */
93
-    public function toASN1()
94
-    {
95
-        return new Sequence(new ObjectIdentifier($this->_oid),
96
-            $this->_qualifierASN1());
97
-    }
88
+	/**
89
+	 * Generate ASN.1 structure.
90
+	 *
91
+	 * @return Sequence
92
+	 */
93
+	public function toASN1()
94
+	{
95
+		return new Sequence(new ObjectIdentifier($this->_oid),
96
+			$this->_qualifierASN1());
97
+	}
98 98
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathValidation/PathValidationConfig.php 1 patch
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -12,274 +12,274 @@
 block discarded – undo
12 12
  */
13 13
 class PathValidationConfig
14 14
 {
15
-    /**
16
-     * Maximum allowed certification path length.
17
-     *
18
-     * @var int $_maxLength
19
-     */
20
-    protected $_maxLength;
15
+	/**
16
+	 * Maximum allowed certification path length.
17
+	 *
18
+	 * @var int $_maxLength
19
+	 */
20
+	protected $_maxLength;
21 21
     
22
-    /**
23
-     * Reference time.
24
-     *
25
-     * @var \DateTimeImmutable $_dateTime
26
-     */
27
-    protected $_dateTime;
22
+	/**
23
+	 * Reference time.
24
+	 *
25
+	 * @var \DateTimeImmutable $_dateTime
26
+	 */
27
+	protected $_dateTime;
28 28
     
29
-    /**
30
-     * List of acceptable policy identifiers.
31
-     *
32
-     * @var string[] $_policySet
33
-     */
34
-    protected $_policySet;
29
+	/**
30
+	 * List of acceptable policy identifiers.
31
+	 *
32
+	 * @var string[] $_policySet
33
+	 */
34
+	protected $_policySet;
35 35
     
36
-    /**
37
-     * Trust anchor certificate.
38
-     *
39
-     * If not set, path validation uses the first certificate of the path.
40
-     *
41
-     * @var Certificate|null $_trustAnchor
42
-     */
43
-    protected $_trustAnchor;
36
+	/**
37
+	 * Trust anchor certificate.
38
+	 *
39
+	 * If not set, path validation uses the first certificate of the path.
40
+	 *
41
+	 * @var Certificate|null $_trustAnchor
42
+	 */
43
+	protected $_trustAnchor;
44 44
     
45
-    /**
46
-     * Whether policy mapping in inhibited.
47
-     *
48
-     * Setting this to true disallows policy mapping.
49
-     *
50
-     * @var bool $_policyMappingInhibit
51
-     */
52
-    protected $_policyMappingInhibit;
45
+	/**
46
+	 * Whether policy mapping in inhibited.
47
+	 *
48
+	 * Setting this to true disallows policy mapping.
49
+	 *
50
+	 * @var bool $_policyMappingInhibit
51
+	 */
52
+	protected $_policyMappingInhibit;
53 53
     
54
-    /**
55
-     * Whether the path must be valid for at least one policy in the
56
-     * initial policy set.
57
-     *
58
-     * @var bool $_explicitPolicy
59
-     */
60
-    protected $_explicitPolicy;
54
+	/**
55
+	 * Whether the path must be valid for at least one policy in the
56
+	 * initial policy set.
57
+	 *
58
+	 * @var bool $_explicitPolicy
59
+	 */
60
+	protected $_explicitPolicy;
61 61
     
62
-    /**
63
-     * Whether anyPolicy OID processing should be inhibited.
64
-     *
65
-     * Setting this to true disallows the usage of anyPolicy.
66
-     *
67
-     * @var bool $_anyPolicyInhibit
68
-     */
69
-    protected $_anyPolicyInhibit;
62
+	/**
63
+	 * Whether anyPolicy OID processing should be inhibited.
64
+	 *
65
+	 * Setting this to true disallows the usage of anyPolicy.
66
+	 *
67
+	 * @var bool $_anyPolicyInhibit
68
+	 */
69
+	protected $_anyPolicyInhibit;
70 70
     
71
-    /**
72
-     *
73
-     * @todo Implement
74
-     * @var mixed $_permittedSubtrees
75
-     */
76
-    protected $_permittedSubtrees;
71
+	/**
72
+	 *
73
+	 * @todo Implement
74
+	 * @var mixed $_permittedSubtrees
75
+	 */
76
+	protected $_permittedSubtrees;
77 77
     
78
-    /**
79
-     *
80
-     * @todo Implement
81
-     * @var mixed $_excludedSubtrees
82
-     */
83
-    protected $_excludedSubtrees;
78
+	/**
79
+	 *
80
+	 * @todo Implement
81
+	 * @var mixed $_excludedSubtrees
82
+	 */
83
+	protected $_excludedSubtrees;
84 84
     
85
-    /**
86
-     * Constructor.
87
-     *
88
-     * @param \DateTimeImmutable $dt Reference date and time
89
-     * @param int $max_length Maximum certification path length
90
-     */
91
-    public function __construct(\DateTimeImmutable $dt, $max_length)
92
-    {
93
-        $this->_dateTime = $dt;
94
-        $this->_maxLength = (int) $max_length;
95
-        $this->_policySet = array((string) PolicyInformation::OID_ANY_POLICY);
96
-        $this->_policyMappingInhibit = false;
97
-        $this->_explicitPolicy = false;
98
-        $this->_anyPolicyInhibit = false;
99
-    }
85
+	/**
86
+	 * Constructor.
87
+	 *
88
+	 * @param \DateTimeImmutable $dt Reference date and time
89
+	 * @param int $max_length Maximum certification path length
90
+	 */
91
+	public function __construct(\DateTimeImmutable $dt, $max_length)
92
+	{
93
+		$this->_dateTime = $dt;
94
+		$this->_maxLength = (int) $max_length;
95
+		$this->_policySet = array((string) PolicyInformation::OID_ANY_POLICY);
96
+		$this->_policyMappingInhibit = false;
97
+		$this->_explicitPolicy = false;
98
+		$this->_anyPolicyInhibit = false;
99
+	}
100 100
     
101
-    /**
102
-     * Get default configuration.
103
-     *
104
-     * @return self
105
-     */
106
-    public static function defaultConfig()
107
-    {
108
-        return new self(new \DateTimeImmutable(), 3);
109
-    }
101
+	/**
102
+	 * Get default configuration.
103
+	 *
104
+	 * @return self
105
+	 */
106
+	public static function defaultConfig()
107
+	{
108
+		return new self(new \DateTimeImmutable(), 3);
109
+	}
110 110
     
111
-    /**
112
-     * Get self with maximum path length.
113
-     *
114
-     * @param int $length
115
-     * @return self
116
-     */
117
-    public function withMaxLength($length)
118
-    {
119
-        $obj = clone $this;
120
-        $obj->_maxLength = $length;
121
-        return $obj;
122
-    }
111
+	/**
112
+	 * Get self with maximum path length.
113
+	 *
114
+	 * @param int $length
115
+	 * @return self
116
+	 */
117
+	public function withMaxLength($length)
118
+	{
119
+		$obj = clone $this;
120
+		$obj->_maxLength = $length;
121
+		return $obj;
122
+	}
123 123
     
124
-    /**
125
-     * Get self with reference date and time.
126
-     *
127
-     * @param \DateTimeImmutable $dt
128
-     * @return self
129
-     */
130
-    public function withDateTime(\DateTimeImmutable $dt)
131
-    {
132
-        $obj = clone $this;
133
-        $obj->_dateTime = $dt;
134
-        return $obj;
135
-    }
124
+	/**
125
+	 * Get self with reference date and time.
126
+	 *
127
+	 * @param \DateTimeImmutable $dt
128
+	 * @return self
129
+	 */
130
+	public function withDateTime(\DateTimeImmutable $dt)
131
+	{
132
+		$obj = clone $this;
133
+		$obj->_dateTime = $dt;
134
+		return $obj;
135
+	}
136 136
     
137
-    /**
138
-     * Get self with trust anchor certificate.
139
-     *
140
-     * @param Certificate $ca
141
-     * @return self
142
-     */
143
-    public function withTrustAnchor(Certificate $ca)
144
-    {
145
-        $obj = clone $this;
146
-        $obj->_trustAnchor = $ca;
147
-        return $obj;
148
-    }
137
+	/**
138
+	 * Get self with trust anchor certificate.
139
+	 *
140
+	 * @param Certificate $ca
141
+	 * @return self
142
+	 */
143
+	public function withTrustAnchor(Certificate $ca)
144
+	{
145
+		$obj = clone $this;
146
+		$obj->_trustAnchor = $ca;
147
+		return $obj;
148
+	}
149 149
     
150
-    /**
151
-     * Get self with initial-policy-mapping-inhibit set.
152
-     *
153
-     * @param bool $flag
154
-     * @return self
155
-     */
156
-    public function withPolicyMappingInhibit($flag)
157
-    {
158
-        $obj = clone $this;
159
-        $obj->_policyMappingInhibit = (bool) $flag;
160
-        return $obj;
161
-    }
150
+	/**
151
+	 * Get self with initial-policy-mapping-inhibit set.
152
+	 *
153
+	 * @param bool $flag
154
+	 * @return self
155
+	 */
156
+	public function withPolicyMappingInhibit($flag)
157
+	{
158
+		$obj = clone $this;
159
+		$obj->_policyMappingInhibit = (bool) $flag;
160
+		return $obj;
161
+	}
162 162
     
163
-    /**
164
-     * Get self with initial-explicit-policy set.
165
-     *
166
-     * @param bool $flag
167
-     * @return self
168
-     */
169
-    public function withExplicitPolicy($flag)
170
-    {
171
-        $obj = clone $this;
172
-        $obj->_explicitPolicy = (bool) $flag;
173
-        return $obj;
174
-    }
163
+	/**
164
+	 * Get self with initial-explicit-policy set.
165
+	 *
166
+	 * @param bool $flag
167
+	 * @return self
168
+	 */
169
+	public function withExplicitPolicy($flag)
170
+	{
171
+		$obj = clone $this;
172
+		$obj->_explicitPolicy = (bool) $flag;
173
+		return $obj;
174
+	}
175 175
     
176
-    /**
177
-     * Get self with initial-any-policy-inhibit set.
178
-     *
179
-     * @param bool $flag
180
-     * @return self
181
-     */
182
-    public function withAnyPolicyInhibit($flag)
183
-    {
184
-        $obj = clone $this;
185
-        $obj->_anyPolicyInhibit = (bool) $flag;
186
-        return $obj;
187
-    }
176
+	/**
177
+	 * Get self with initial-any-policy-inhibit set.
178
+	 *
179
+	 * @param bool $flag
180
+	 * @return self
181
+	 */
182
+	public function withAnyPolicyInhibit($flag)
183
+	{
184
+		$obj = clone $this;
185
+		$obj->_anyPolicyInhibit = (bool) $flag;
186
+		return $obj;
187
+	}
188 188
     
189
-    /**
190
-     * Get self with user-initial-policy-set set to policy OIDs.
191
-     *
192
-     * @param string ...$policies List of policy OIDs
193
-     * @return self
194
-     */
195
-    public function withPolicySet(...$policies)
196
-    {
197
-        $obj = clone $this;
198
-        $obj->_policySet = $policies;
199
-        return $obj;
200
-    }
189
+	/**
190
+	 * Get self with user-initial-policy-set set to policy OIDs.
191
+	 *
192
+	 * @param string ...$policies List of policy OIDs
193
+	 * @return self
194
+	 */
195
+	public function withPolicySet(...$policies)
196
+	{
197
+		$obj = clone $this;
198
+		$obj->_policySet = $policies;
199
+		return $obj;
200
+	}
201 201
     
202
-    /**
203
-     * Get maximum certification path length.
204
-     *
205
-     * @return int
206
-     */
207
-    public function maxLength()
208
-    {
209
-        return $this->_maxLength;
210
-    }
202
+	/**
203
+	 * Get maximum certification path length.
204
+	 *
205
+	 * @return int
206
+	 */
207
+	public function maxLength()
208
+	{
209
+		return $this->_maxLength;
210
+	}
211 211
     
212
-    /**
213
-     * Get reference date and time.
214
-     *
215
-     * @return \DateTimeImmutable
216
-     */
217
-    public function dateTime()
218
-    {
219
-        return $this->_dateTime;
220
-    }
212
+	/**
213
+	 * Get reference date and time.
214
+	 *
215
+	 * @return \DateTimeImmutable
216
+	 */
217
+	public function dateTime()
218
+	{
219
+		return $this->_dateTime;
220
+	}
221 221
     
222
-    /**
223
-     * Get user-initial-policy-set.
224
-     *
225
-     * @return string[] Array of OID's
226
-     */
227
-    public function policySet()
228
-    {
229
-        return $this->_policySet;
230
-    }
222
+	/**
223
+	 * Get user-initial-policy-set.
224
+	 *
225
+	 * @return string[] Array of OID's
226
+	 */
227
+	public function policySet()
228
+	{
229
+		return $this->_policySet;
230
+	}
231 231
     
232
-    /**
233
-     * Check whether trust anchor certificate is set.
234
-     *
235
-     * @return bool
236
-     */
237
-    public function hasTrustAnchor()
238
-    {
239
-        return isset($this->_trustAnchor);
240
-    }
232
+	/**
233
+	 * Check whether trust anchor certificate is set.
234
+	 *
235
+	 * @return bool
236
+	 */
237
+	public function hasTrustAnchor()
238
+	{
239
+		return isset($this->_trustAnchor);
240
+	}
241 241
     
242
-    /**
243
-     * Get trust anchor certificate.
244
-     *
245
-     * @throws \LogicException
246
-     * @return Certificate
247
-     */
248
-    public function trustAnchor()
249
-    {
250
-        if (!$this->hasTrustAnchor()) {
251
-            throw new \LogicException("No trust anchor.");
252
-        }
253
-        return $this->_trustAnchor;
254
-    }
242
+	/**
243
+	 * Get trust anchor certificate.
244
+	 *
245
+	 * @throws \LogicException
246
+	 * @return Certificate
247
+	 */
248
+	public function trustAnchor()
249
+	{
250
+		if (!$this->hasTrustAnchor()) {
251
+			throw new \LogicException("No trust anchor.");
252
+		}
253
+		return $this->_trustAnchor;
254
+	}
255 255
     
256
-    /**
257
-     * Get initial-policy-mapping-inhibit.
258
-     *
259
-     * @return bool
260
-     */
261
-    public function policyMappingInhibit()
262
-    {
263
-        return $this->_policyMappingInhibit;
264
-    }
256
+	/**
257
+	 * Get initial-policy-mapping-inhibit.
258
+	 *
259
+	 * @return bool
260
+	 */
261
+	public function policyMappingInhibit()
262
+	{
263
+		return $this->_policyMappingInhibit;
264
+	}
265 265
     
266
-    /**
267
-     * Get initial-explicit-policy.
268
-     *
269
-     * @return bool
270
-     */
271
-    public function explicitPolicy()
272
-    {
273
-        return $this->_explicitPolicy;
274
-    }
266
+	/**
267
+	 * Get initial-explicit-policy.
268
+	 *
269
+	 * @return bool
270
+	 */
271
+	public function explicitPolicy()
272
+	{
273
+		return $this->_explicitPolicy;
274
+	}
275 275
     
276
-    /**
277
-     * Get initial-any-policy-inhibit.
278
-     *
279
-     * @return bool
280
-     */
281
-    public function anyPolicyInhibit()
282
-    {
283
-        return $this->_anyPolicyInhibit;
284
-    }
276
+	/**
277
+	 * Get initial-any-policy-inhibit.
278
+	 *
279
+	 * @return bool
280
+	 */
281
+	public function anyPolicyInhibit()
282
+	{
283
+		return $this->_anyPolicyInhibit;
284
+	}
285 285
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/Policy/PolicyTree.php 1 patch
Indentation   +393 added lines, -393 removed lines patch added patch discarded remove patch
@@ -8,411 +8,411 @@
 block discarded – undo
8 8
 
9 9
 class PolicyTree
10 10
 {
11
-    /**
12
-     * Root node at depth zero.
13
-     *
14
-     * @var PolicyNode|null
15
-     */
16
-    protected $_root;
11
+	/**
12
+	 * Root node at depth zero.
13
+	 *
14
+	 * @var PolicyNode|null
15
+	 */
16
+	protected $_root;
17 17
     
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param PolicyNode $root Initial root node
22
-     */
23
-    public function __construct(PolicyNode $root)
24
-    {
25
-        $this->_root = $root;
26
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param PolicyNode $root Initial root node
22
+	 */
23
+	public function __construct(PolicyNode $root)
24
+	{
25
+		$this->_root = $root;
26
+	}
27 27
     
28
-    /**
29
-     * Process policy information from the certificate.
30
-     *
31
-     * Certificate policies extension must be present.
32
-     *
33
-     * @param ValidatorState $state
34
-     * @param Certificate $cert
35
-     * @return ValidatorState
36
-     */
37
-    public function processPolicies(ValidatorState $state, Certificate $cert)
38
-    {
39
-        $policies = $cert->tbsCertificate()
40
-            ->extensions()
41
-            ->certificatePolicies();
42
-        $tree = clone $this;
43
-        // (d.1) for each policy P not equal to anyPolicy
44
-        foreach ($policies as $policy) {
45
-            if ($policy->isAnyPolicy()) {
46
-                $tree->_processAnyPolicy($policy, $cert, $state);
47
-            } else {
48
-                $tree->_processPolicy($policy, $state);
49
-            }
50
-        }
51
-        // if whole tree is pruned
52
-        if (!$tree->_pruneTree($state->index() - 1)) {
53
-            return $state->withoutValidPolicyTree();
54
-        }
55
-        return $state->withValidPolicyTree($tree);
56
-    }
28
+	/**
29
+	 * Process policy information from the certificate.
30
+	 *
31
+	 * Certificate policies extension must be present.
32
+	 *
33
+	 * @param ValidatorState $state
34
+	 * @param Certificate $cert
35
+	 * @return ValidatorState
36
+	 */
37
+	public function processPolicies(ValidatorState $state, Certificate $cert)
38
+	{
39
+		$policies = $cert->tbsCertificate()
40
+			->extensions()
41
+			->certificatePolicies();
42
+		$tree = clone $this;
43
+		// (d.1) for each policy P not equal to anyPolicy
44
+		foreach ($policies as $policy) {
45
+			if ($policy->isAnyPolicy()) {
46
+				$tree->_processAnyPolicy($policy, $cert, $state);
47
+			} else {
48
+				$tree->_processPolicy($policy, $state);
49
+			}
50
+		}
51
+		// if whole tree is pruned
52
+		if (!$tree->_pruneTree($state->index() - 1)) {
53
+			return $state->withoutValidPolicyTree();
54
+		}
55
+		return $state->withValidPolicyTree($tree);
56
+	}
57 57
     
58
-    /**
59
-     * Process policy mappings from the certificate.
60
-     *
61
-     * @param ValidatorState $state
62
-     * @param Certificate $cert
63
-     * @return ValidatorState
64
-     */
65
-    public function processMappings(ValidatorState $state, Certificate $cert)
66
-    {
67
-        $tree = clone $this;
68
-        if ($state->policyMapping() > 0) {
69
-            $tree->_applyMappings($cert, $state);
70
-        } else if ($state->policyMapping() == 0) {
71
-            $tree->_deleteMappings($cert, $state);
72
-        }
73
-        // if whole tree is pruned
74
-        if (!$tree->_root) {
75
-            return $state->withoutValidPolicyTree();
76
-        }
77
-        return $state->withValidPolicyTree($tree);
78
-    }
58
+	/**
59
+	 * Process policy mappings from the certificate.
60
+	 *
61
+	 * @param ValidatorState $state
62
+	 * @param Certificate $cert
63
+	 * @return ValidatorState
64
+	 */
65
+	public function processMappings(ValidatorState $state, Certificate $cert)
66
+	{
67
+		$tree = clone $this;
68
+		if ($state->policyMapping() > 0) {
69
+			$tree->_applyMappings($cert, $state);
70
+		} else if ($state->policyMapping() == 0) {
71
+			$tree->_deleteMappings($cert, $state);
72
+		}
73
+		// if whole tree is pruned
74
+		if (!$tree->_root) {
75
+			return $state->withoutValidPolicyTree();
76
+		}
77
+		return $state->withValidPolicyTree($tree);
78
+	}
79 79
     
80
-    /**
81
-     * Calculate policy intersection as specified in Wrap-Up Procedure 6.1.5.g.
82
-     *
83
-     * @param ValidatorState $state
84
-     * @param array $policies
85
-     * @return ValidatorState
86
-     */
87
-    public function calculateIntersection(ValidatorState $state, array $policies)
88
-    {
89
-        $tree = clone $this;
90
-        $valid_policy_node_set = $tree->_validPolicyNodeSet();
91
-        // 2. If the valid_policy of any node in the valid_policy_node_set
92
-        // is not in the user-initial-policy-set and is not anyPolicy,
93
-        // delete this node and all its children.
94
-        $valid_policy_node_set = array_filter($valid_policy_node_set,
95
-            function (PolicyNode $node) use ($policies) {
96
-                if ($node->isAnyPolicy()) {
97
-                    return true;
98
-                }
99
-                if (in_array($node->validPolicy(), $policies)) {
100
-                    return true;
101
-                }
102
-                $node->remove();
103
-                return false;
104
-            });
105
-        // array of valid policy OIDs
106
-        $valid_policy_set = array_map(
107
-            function (PolicyNode $node) {
108
-                return $node->validPolicy();
109
-            }, $valid_policy_node_set);
110
-        // 3. If the valid_policy_tree includes a node of depth n with
111
-        // the valid_policy anyPolicy and the user-initial-policy-set 
112
-        // is not any-policy
113
-        foreach ($tree->_nodesAtDepth($state->index()) as $node) {
114
-            if ($node->hasParent() && $node->isAnyPolicy()) {
115
-                // a. Set P-Q to the qualifier_set in the node of depth n
116
-                // with valid_policy anyPolicy.
117
-                $pq = $node->qualifiers();
118
-                // b. For each P-OID in the user-initial-policy-set that is not
119
-                // the valid_policy of a node in the valid_policy_node_set,
120
-                // create a child node whose parent is the node of depth n-1
121
-                // with the valid_policy anyPolicy.
122
-                $poids = array_diff($policies, $valid_policy_set);
123
-                foreach ($tree->_nodesAtDepth($state->index() - 1) as $parent) {
124
-                    if ($parent->isAnyPolicy()) {
125
-                        // Set the values in the child node as follows: 
126
-                        // set the valid_policy to P-OID, set the qualifier_set
127
-                        // to P-Q, and set the expected_policy_set to {P-OID}.
128
-                        foreach ($poids as $poid) {
129
-                            $parent->addChild(
130
-                                new PolicyNode($poid, $pq, array($poid)));
131
-                        }
132
-                        break;
133
-                    }
134
-                }
135
-                // c. Delete the node of depth n with the
136
-                // valid_policy anyPolicy.
137
-                $node->remove();
138
-            }
139
-        }
140
-        // 4. If there is a node in the valid_policy_tree of depth n-1 or less
141
-        // without any child nodes, delete that node. Repeat this step until
142
-        // there are no nodes of depth n-1 or less without children.
143
-        if (!$tree->_pruneTree($state->index() - 1)) {
144
-            return $state->withoutValidPolicyTree();
145
-        }
146
-        return $state->withValidPolicyTree($tree);
147
-    }
80
+	/**
81
+	 * Calculate policy intersection as specified in Wrap-Up Procedure 6.1.5.g.
82
+	 *
83
+	 * @param ValidatorState $state
84
+	 * @param array $policies
85
+	 * @return ValidatorState
86
+	 */
87
+	public function calculateIntersection(ValidatorState $state, array $policies)
88
+	{
89
+		$tree = clone $this;
90
+		$valid_policy_node_set = $tree->_validPolicyNodeSet();
91
+		// 2. If the valid_policy of any node in the valid_policy_node_set
92
+		// is not in the user-initial-policy-set and is not anyPolicy,
93
+		// delete this node and all its children.
94
+		$valid_policy_node_set = array_filter($valid_policy_node_set,
95
+			function (PolicyNode $node) use ($policies) {
96
+				if ($node->isAnyPolicy()) {
97
+					return true;
98
+				}
99
+				if (in_array($node->validPolicy(), $policies)) {
100
+					return true;
101
+				}
102
+				$node->remove();
103
+				return false;
104
+			});
105
+		// array of valid policy OIDs
106
+		$valid_policy_set = array_map(
107
+			function (PolicyNode $node) {
108
+				return $node->validPolicy();
109
+			}, $valid_policy_node_set);
110
+		// 3. If the valid_policy_tree includes a node of depth n with
111
+		// the valid_policy anyPolicy and the user-initial-policy-set 
112
+		// is not any-policy
113
+		foreach ($tree->_nodesAtDepth($state->index()) as $node) {
114
+			if ($node->hasParent() && $node->isAnyPolicy()) {
115
+				// a. Set P-Q to the qualifier_set in the node of depth n
116
+				// with valid_policy anyPolicy.
117
+				$pq = $node->qualifiers();
118
+				// b. For each P-OID in the user-initial-policy-set that is not
119
+				// the valid_policy of a node in the valid_policy_node_set,
120
+				// create a child node whose parent is the node of depth n-1
121
+				// with the valid_policy anyPolicy.
122
+				$poids = array_diff($policies, $valid_policy_set);
123
+				foreach ($tree->_nodesAtDepth($state->index() - 1) as $parent) {
124
+					if ($parent->isAnyPolicy()) {
125
+						// Set the values in the child node as follows: 
126
+						// set the valid_policy to P-OID, set the qualifier_set
127
+						// to P-Q, and set the expected_policy_set to {P-OID}.
128
+						foreach ($poids as $poid) {
129
+							$parent->addChild(
130
+								new PolicyNode($poid, $pq, array($poid)));
131
+						}
132
+						break;
133
+					}
134
+				}
135
+				// c. Delete the node of depth n with the
136
+				// valid_policy anyPolicy.
137
+				$node->remove();
138
+			}
139
+		}
140
+		// 4. If there is a node in the valid_policy_tree of depth n-1 or less
141
+		// without any child nodes, delete that node. Repeat this step until
142
+		// there are no nodes of depth n-1 or less without children.
143
+		if (!$tree->_pruneTree($state->index() - 1)) {
144
+			return $state->withoutValidPolicyTree();
145
+		}
146
+		return $state->withValidPolicyTree($tree);
147
+	}
148 148
     
149
-    /**
150
-     * Get policies at given policy tree depth.
151
-     *
152
-     * @param int $i Depth in range 1..n
153
-     * @return PolicyInformation[]
154
-     */
155
-    public function policiesAtDepth($i)
156
-    {
157
-        $policies = array();
158
-        foreach ($this->_nodesAtDepth($i) as $node) {
159
-            $policies[] = new PolicyInformation($node->validPolicy(),
160
-                ...$node->qualifiers());
161
-        }
162
-        return $policies;
163
-    }
149
+	/**
150
+	 * Get policies at given policy tree depth.
151
+	 *
152
+	 * @param int $i Depth in range 1..n
153
+	 * @return PolicyInformation[]
154
+	 */
155
+	public function policiesAtDepth($i)
156
+	{
157
+		$policies = array();
158
+		foreach ($this->_nodesAtDepth($i) as $node) {
159
+			$policies[] = new PolicyInformation($node->validPolicy(),
160
+				...$node->qualifiers());
161
+		}
162
+		return $policies;
163
+	}
164 164
     
165
-    /**
166
-     * Process single policy information.
167
-     *
168
-     * @param PolicyInformation $policy
169
-     * @param ValidatorState $state
170
-     */
171
-    protected function _processPolicy(PolicyInformation $policy,
172
-        ValidatorState $state)
173
-    {
174
-        $p_oid = $policy->oid();
175
-        $i = $state->index();
176
-        $match_count = 0;
177
-        // (d.1.i) for each node of depth i-1 in the valid_policy_tree...
178
-        foreach ($this->_nodesAtDepth($i - 1) as $node) {
179
-            // ...where P-OID is in the expected_policy_set
180
-            if ($node->hasExpectedPolicy($p_oid)) {
181
-                $node->addChild(
182
-                    new PolicyNode($p_oid, $policy->qualifiers(), array($p_oid)));
183
-                ++$match_count;
184
-            }
185
-        }
186
-        // (d.1.ii) if there was no match in step (i)...
187
-        if (!$match_count) {
188
-            // ...and the valid_policy_tree includes a node of depth i-1 with
189
-            // the valid_policy anyPolicy
190
-            foreach ($this->_nodesAtDepth($i - 1) as $node) {
191
-                if ($node->isAnyPolicy()) {
192
-                    $node->addChild(
193
-                        new PolicyNode($p_oid, $policy->qualifiers(),
194
-                            array($p_oid)));
195
-                }
196
-            }
197
-        }
198
-    }
165
+	/**
166
+	 * Process single policy information.
167
+	 *
168
+	 * @param PolicyInformation $policy
169
+	 * @param ValidatorState $state
170
+	 */
171
+	protected function _processPolicy(PolicyInformation $policy,
172
+		ValidatorState $state)
173
+	{
174
+		$p_oid = $policy->oid();
175
+		$i = $state->index();
176
+		$match_count = 0;
177
+		// (d.1.i) for each node of depth i-1 in the valid_policy_tree...
178
+		foreach ($this->_nodesAtDepth($i - 1) as $node) {
179
+			// ...where P-OID is in the expected_policy_set
180
+			if ($node->hasExpectedPolicy($p_oid)) {
181
+				$node->addChild(
182
+					new PolicyNode($p_oid, $policy->qualifiers(), array($p_oid)));
183
+				++$match_count;
184
+			}
185
+		}
186
+		// (d.1.ii) if there was no match in step (i)...
187
+		if (!$match_count) {
188
+			// ...and the valid_policy_tree includes a node of depth i-1 with
189
+			// the valid_policy anyPolicy
190
+			foreach ($this->_nodesAtDepth($i - 1) as $node) {
191
+				if ($node->isAnyPolicy()) {
192
+					$node->addChild(
193
+						new PolicyNode($p_oid, $policy->qualifiers(),
194
+							array($p_oid)));
195
+				}
196
+			}
197
+		}
198
+	}
199 199
     
200
-    /**
201
-     * Process anyPolicy policy information.
202
-     *
203
-     * @param PolicyInformation $policy
204
-     * @param Certificate $cert
205
-     * @param ValidatorState $state
206
-     */
207
-    protected function _processAnyPolicy(PolicyInformation $policy,
208
-        Certificate $cert, ValidatorState $state)
209
-    {
210
-        $i = $state->index();
211
-        // if (a) inhibit_anyPolicy is greater than 0 or
212
-        // (b) i<n and the certificate is self-issued
213
-        if (!($state->inhibitAnyPolicy() > 0 ||
214
-             ($i < $state->pathLength() && $cert->isSelfIssued()))) {
215
-            return;
216
-        }
217
-        // for each node in the valid_policy_tree of depth i-1
218
-        foreach ($this->_nodesAtDepth($i - 1) as $node) {
219
-            // for each value in the expected_policy_set
220
-            foreach ($node->expectedPolicies() as $p_oid) {
221
-                // that does not appear in a child node
222
-                if (!$node->hasChildWithValidPolicy($p_oid)) {
223
-                    $node->addChild(
224
-                        new PolicyNode($p_oid, $policy->qualifiers(),
225
-                            array($p_oid)));
226
-                }
227
-            }
228
-        }
229
-    }
200
+	/**
201
+	 * Process anyPolicy policy information.
202
+	 *
203
+	 * @param PolicyInformation $policy
204
+	 * @param Certificate $cert
205
+	 * @param ValidatorState $state
206
+	 */
207
+	protected function _processAnyPolicy(PolicyInformation $policy,
208
+		Certificate $cert, ValidatorState $state)
209
+	{
210
+		$i = $state->index();
211
+		// if (a) inhibit_anyPolicy is greater than 0 or
212
+		// (b) i<n and the certificate is self-issued
213
+		if (!($state->inhibitAnyPolicy() > 0 ||
214
+			 ($i < $state->pathLength() && $cert->isSelfIssued()))) {
215
+			return;
216
+		}
217
+		// for each node in the valid_policy_tree of depth i-1
218
+		foreach ($this->_nodesAtDepth($i - 1) as $node) {
219
+			// for each value in the expected_policy_set
220
+			foreach ($node->expectedPolicies() as $p_oid) {
221
+				// that does not appear in a child node
222
+				if (!$node->hasChildWithValidPolicy($p_oid)) {
223
+					$node->addChild(
224
+						new PolicyNode($p_oid, $policy->qualifiers(),
225
+							array($p_oid)));
226
+				}
227
+			}
228
+		}
229
+	}
230 230
     
231
-    /**
232
-     * Apply policy mappings to the policy tree.
233
-     *
234
-     * @param Certificate $cert
235
-     * @param ValidatorState $state
236
-     */
237
-    protected function _applyMappings(Certificate $cert, ValidatorState $state)
238
-    {
239
-        $policy_mappings = $cert->tbsCertificate()
240
-            ->extensions()
241
-            ->policyMappings();
242
-        // (6.1.4. b.1.) for each node in the valid_policy_tree of depth i...
243
-        foreach ($policy_mappings->flattenedMappings() as $idp => $sdps) {
244
-            $match_count = 0;
245
-            foreach ($this->_nodesAtDepth($state->index()) as $node) {
246
-                // ...where ID-P is the valid_policy
247
-                if ($node->validPolicy() == $idp) {
248
-                    // set expected_policy_set to the set of subjectDomainPolicy
249
-                    // values that are specified as equivalent to ID-P by
250
-                    // the policy mappings extension
251
-                    $node->setExpectedPolicies(...$sdps);
252
-                    ++$match_count;
253
-                }
254
-            }
255
-            // if no node of depth i in the valid_policy_tree has
256
-            // a valid_policy of ID-P...
257
-            if (!$match_count) {
258
-                $this->_applyAnyPolicyMapping($cert, $state, $idp, $sdps);
259
-            }
260
-        }
261
-    }
231
+	/**
232
+	 * Apply policy mappings to the policy tree.
233
+	 *
234
+	 * @param Certificate $cert
235
+	 * @param ValidatorState $state
236
+	 */
237
+	protected function _applyMappings(Certificate $cert, ValidatorState $state)
238
+	{
239
+		$policy_mappings = $cert->tbsCertificate()
240
+			->extensions()
241
+			->policyMappings();
242
+		// (6.1.4. b.1.) for each node in the valid_policy_tree of depth i...
243
+		foreach ($policy_mappings->flattenedMappings() as $idp => $sdps) {
244
+			$match_count = 0;
245
+			foreach ($this->_nodesAtDepth($state->index()) as $node) {
246
+				// ...where ID-P is the valid_policy
247
+				if ($node->validPolicy() == $idp) {
248
+					// set expected_policy_set to the set of subjectDomainPolicy
249
+					// values that are specified as equivalent to ID-P by
250
+					// the policy mappings extension
251
+					$node->setExpectedPolicies(...$sdps);
252
+					++$match_count;
253
+				}
254
+			}
255
+			// if no node of depth i in the valid_policy_tree has
256
+			// a valid_policy of ID-P...
257
+			if (!$match_count) {
258
+				$this->_applyAnyPolicyMapping($cert, $state, $idp, $sdps);
259
+			}
260
+		}
261
+	}
262 262
     
263
-    /**
264
-     * Apply anyPolicy mapping to the policy tree as specified in 6.1.4 (b)(1).
265
-     *
266
-     * @param Certificate $cert
267
-     * @param ValidatorState $state
268
-     * @param string $idp OID of the issuer domain policy
269
-     * @param array $sdps Array of subject domain policy OIDs
270
-     */
271
-    protected function _applyAnyPolicyMapping(Certificate $cert,
272
-        ValidatorState $state, $idp, array $sdps)
273
-    {
274
-        // (6.1.4. b.1.) ...but there is a node of depth i with
275
-        // a valid_policy of anyPolicy
276
-        foreach ($this->_nodesAtDepth($state->index()) as $node) {
277
-            if ($node->isAnyPolicy()) {
278
-                // then generate a child node of the node of depth i-1
279
-                // that has a valid_policy of anyPolicy as follows...
280
-                foreach ($this->_nodesAtDepth($state->index() - 1) as $node) {
281
-                    if ($node->isAnyPolicy()) {
282
-                        // try to fetch qualifiers of anyPolicy certificate policy
283
-                        $qualifiers = array();
284
-                        try {
285
-                            $qualifiers = $cert->tbsCertificate()
286
-                                ->extensions()
287
-                                ->certificatePolicies()
288
-                                ->anyPolicy()
289
-                                ->qualifiers();
290
-                        } catch (\LogicException $e) {
291
-                            // if there's no policies or no qualifiers
292
-                        }
293
-                        $node->addChild(
294
-                            new PolicyNode($idp, $qualifiers, $sdps));
295
-                        // bail after first anyPolicy has been processed
296
-                        break;
297
-                    }
298
-                }
299
-                // bail after first anyPolicy has been processed
300
-                break;
301
-            }
302
-        }
303
-    }
263
+	/**
264
+	 * Apply anyPolicy mapping to the policy tree as specified in 6.1.4 (b)(1).
265
+	 *
266
+	 * @param Certificate $cert
267
+	 * @param ValidatorState $state
268
+	 * @param string $idp OID of the issuer domain policy
269
+	 * @param array $sdps Array of subject domain policy OIDs
270
+	 */
271
+	protected function _applyAnyPolicyMapping(Certificate $cert,
272
+		ValidatorState $state, $idp, array $sdps)
273
+	{
274
+		// (6.1.4. b.1.) ...but there is a node of depth i with
275
+		// a valid_policy of anyPolicy
276
+		foreach ($this->_nodesAtDepth($state->index()) as $node) {
277
+			if ($node->isAnyPolicy()) {
278
+				// then generate a child node of the node of depth i-1
279
+				// that has a valid_policy of anyPolicy as follows...
280
+				foreach ($this->_nodesAtDepth($state->index() - 1) as $node) {
281
+					if ($node->isAnyPolicy()) {
282
+						// try to fetch qualifiers of anyPolicy certificate policy
283
+						$qualifiers = array();
284
+						try {
285
+							$qualifiers = $cert->tbsCertificate()
286
+								->extensions()
287
+								->certificatePolicies()
288
+								->anyPolicy()
289
+								->qualifiers();
290
+						} catch (\LogicException $e) {
291
+							// if there's no policies or no qualifiers
292
+						}
293
+						$node->addChild(
294
+							new PolicyNode($idp, $qualifiers, $sdps));
295
+						// bail after first anyPolicy has been processed
296
+						break;
297
+					}
298
+				}
299
+				// bail after first anyPolicy has been processed
300
+				break;
301
+			}
302
+		}
303
+	}
304 304
     
305
-    /**
306
-     * Delete nodes as specified in 6.1.4 (b)(2).
307
-     *
308
-     * @param Certificate $cert
309
-     * @param ValidatorState $state
310
-     */
311
-    protected function _deleteMappings(Certificate $cert, ValidatorState $state)
312
-    {
313
-        $idps = $cert->tbsCertificate()
314
-            ->extensions()
315
-            ->policyMappings()
316
-            ->issuerDomainPolicies();
317
-        // delete each node of depth i in the valid_policy_tree
318
-        // where ID-P is the valid_policy
319
-        foreach ($this->_nodesAtDepth($state->index()) as $node) {
320
-            if (in_array($node->validPolicy(), $idps)) {
321
-                $node->remove();
322
-            }
323
-        }
324
-        $this->_pruneTree($state->index() - 1);
325
-    }
305
+	/**
306
+	 * Delete nodes as specified in 6.1.4 (b)(2).
307
+	 *
308
+	 * @param Certificate $cert
309
+	 * @param ValidatorState $state
310
+	 */
311
+	protected function _deleteMappings(Certificate $cert, ValidatorState $state)
312
+	{
313
+		$idps = $cert->tbsCertificate()
314
+			->extensions()
315
+			->policyMappings()
316
+			->issuerDomainPolicies();
317
+		// delete each node of depth i in the valid_policy_tree
318
+		// where ID-P is the valid_policy
319
+		foreach ($this->_nodesAtDepth($state->index()) as $node) {
320
+			if (in_array($node->validPolicy(), $idps)) {
321
+				$node->remove();
322
+			}
323
+		}
324
+		$this->_pruneTree($state->index() - 1);
325
+	}
326 326
     
327
-    /**
328
-     * Prune tree starting from given depth.
329
-     *
330
-     * @param int $depth
331
-     * @return int The number of nodes left in a tree
332
-     */
333
-    protected function _pruneTree($depth)
334
-    {
335
-        for ($i = $depth; $i > 0; --$i) {
336
-            foreach ($this->_nodesAtDepth($i) as $node) {
337
-                if (!count($node)) {
338
-                    $node->remove();
339
-                }
340
-            }
341
-        }
342
-        // if root has no children left
343
-        if (!count($this->_root)) {
344
-            $this->_root = null;
345
-            return 0;
346
-        }
347
-        return $this->_root->nodeCount();
348
-    }
327
+	/**
328
+	 * Prune tree starting from given depth.
329
+	 *
330
+	 * @param int $depth
331
+	 * @return int The number of nodes left in a tree
332
+	 */
333
+	protected function _pruneTree($depth)
334
+	{
335
+		for ($i = $depth; $i > 0; --$i) {
336
+			foreach ($this->_nodesAtDepth($i) as $node) {
337
+				if (!count($node)) {
338
+					$node->remove();
339
+				}
340
+			}
341
+		}
342
+		// if root has no children left
343
+		if (!count($this->_root)) {
344
+			$this->_root = null;
345
+			return 0;
346
+		}
347
+		return $this->_root->nodeCount();
348
+	}
349 349
     
350
-    /**
351
-     * Get all nodes at given depth.
352
-     *
353
-     * @param int $i
354
-     * @return PolicyNode[]
355
-     */
356
-    protected function _nodesAtDepth($i)
357
-    {
358
-        if (!$this->_root) {
359
-            return array();
360
-        }
361
-        $depth = 0;
362
-        $nodes = array($this->_root);
363
-        while ($depth < $i) {
364
-            $nodes = self::_gatherChildren(...$nodes);
365
-            if (!count($nodes)) {
366
-                break;
367
-            }
368
-            ++$depth;
369
-        }
370
-        return $nodes;
371
-    }
350
+	/**
351
+	 * Get all nodes at given depth.
352
+	 *
353
+	 * @param int $i
354
+	 * @return PolicyNode[]
355
+	 */
356
+	protected function _nodesAtDepth($i)
357
+	{
358
+		if (!$this->_root) {
359
+			return array();
360
+		}
361
+		$depth = 0;
362
+		$nodes = array($this->_root);
363
+		while ($depth < $i) {
364
+			$nodes = self::_gatherChildren(...$nodes);
365
+			if (!count($nodes)) {
366
+				break;
367
+			}
368
+			++$depth;
369
+		}
370
+		return $nodes;
371
+	}
372 372
     
373
-    /**
374
-     * Get the valid policy node set as specified in spec 6.1.5.(g)(iii)1.
375
-     *
376
-     * @return PolicyNode[]
377
-     */
378
-    protected function _validPolicyNodeSet()
379
-    {
380
-        // 1. Determine the set of policy nodes whose parent nodes have
381
-        // a valid_policy of anyPolicy. This is the valid_policy_node_set.
382
-        $set = array();
383
-        if (!$this->_root) {
384
-            return $set;
385
-        }
386
-        // for each node in a tree
387
-        $this->_root->walkNodes(
388
-            function (PolicyNode $node) use (&$set) {
389
-                $parents = $node->parents();
390
-                // node has parents
391
-                if (count($parents)) {
392
-                    // check that each ancestor is an anyPolicy node
393
-                    foreach ($parents as $ancestor) {
394
-                        if (!$ancestor->isAnyPolicy()) {
395
-                            return;
396
-                        }
397
-                    }
398
-                    $set[] = $node;
399
-                }
400
-            });
401
-        return $set;
402
-    }
373
+	/**
374
+	 * Get the valid policy node set as specified in spec 6.1.5.(g)(iii)1.
375
+	 *
376
+	 * @return PolicyNode[]
377
+	 */
378
+	protected function _validPolicyNodeSet()
379
+	{
380
+		// 1. Determine the set of policy nodes whose parent nodes have
381
+		// a valid_policy of anyPolicy. This is the valid_policy_node_set.
382
+		$set = array();
383
+		if (!$this->_root) {
384
+			return $set;
385
+		}
386
+		// for each node in a tree
387
+		$this->_root->walkNodes(
388
+			function (PolicyNode $node) use (&$set) {
389
+				$parents = $node->parents();
390
+				// node has parents
391
+				if (count($parents)) {
392
+					// check that each ancestor is an anyPolicy node
393
+					foreach ($parents as $ancestor) {
394
+						if (!$ancestor->isAnyPolicy()) {
395
+							return;
396
+						}
397
+					}
398
+					$set[] = $node;
399
+				}
400
+			});
401
+		return $set;
402
+	}
403 403
     
404
-    /**
405
-     * Gather all children of given nodes to a flattened array.
406
-     *
407
-     * @param PolicyNode ...$nodes
408
-     * @return PolicyNode[]
409
-     */
410
-    private static function _gatherChildren(PolicyNode ...$nodes)
411
-    {
412
-        $children = array();
413
-        foreach ($nodes as $node) {
414
-            $children = array_merge($children, $node->children());
415
-        }
416
-        return $children;
417
-    }
404
+	/**
405
+	 * Gather all children of given nodes to a flattened array.
406
+	 *
407
+	 * @param PolicyNode ...$nodes
408
+	 * @return PolicyNode[]
409
+	 */
410
+	private static function _gatherChildren(PolicyNode ...$nodes)
411
+	{
412
+		$children = array();
413
+		foreach ($nodes as $node) {
414
+			$children = array_merge($children, $node->children());
415
+		}
416
+		return $children;
417
+	}
418 418
 }
Please login to merge, or discard this patch.