author | darcy |
Thu, 23 Apr 2015 18:51:18 -0700 | |
changeset 30033 | b9c86c17164a |
parent 25859 | 3317bb8137f4 |
child 32649 | 2ee9017c7597 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
2 |
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.security.cert; |
|
27 |
||
28 |
import java.security.AccessController; |
|
29 |
import java.security.InvalidAlgorithmParameterException; |
|
30 |
import java.security.NoSuchAlgorithmException; |
|
31 |
import java.security.NoSuchProviderException; |
|
32 |
import java.security.PrivilegedAction; |
|
33 |
import java.security.Provider; |
|
34 |
import java.security.Security; |
|
35 |
import sun.security.util.Debug; |
|
36 |
||
37 |
import sun.security.jca.*; |
|
38 |
import sun.security.jca.GetInstance.Instance; |
|
39 |
||
40 |
/** |
|
41 |
* A class for validating certification paths (also known as certificate |
|
42 |
* chains). |
|
43 |
* <p> |
|
44 |
* This class uses a provider-based architecture. |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
45 |
* To create a {@code CertPathValidator}, |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
46 |
* call one of the static {@code getInstance} methods, passing in the |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
47 |
* algorithm name of the {@code CertPathValidator} desired and |
2 | 48 |
* optionally the name of the provider desired. |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
49 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
50 |
* <p>Once a {@code CertPathValidator} object has been created, it can |
2 | 51 |
* be used to validate certification paths by calling the {@link #validate |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
52 |
* validate} method and passing it the {@code CertPath} to be validated |
2 | 53 |
* and an algorithm-specific set of parameters. If successful, the result is |
54 |
* returned in an object that implements the |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
55 |
* {@code CertPathValidatorResult} interface. |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
56 |
* |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
57 |
* <p>The {@link #getRevocationChecker} method allows an application to specify |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
58 |
* additional algorithm-specific parameters and options used by the |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
59 |
* {@code CertPathValidator} when checking the revocation status of |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
60 |
* certificates. Here is an example demonstrating how it is used with the PKIX |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
61 |
* algorithm: |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
62 |
* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
63 |
* <pre> |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
64 |
* CertPathValidator cpv = CertPathValidator.getInstance("PKIX"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
65 |
* PKIXRevocationChecker rc = (PKIXRevocationChecker)cpv.getRevocationChecker(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
66 |
* rc.setOptions(EnumSet.of(Option.SOFT_FAIL)); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
67 |
* params.addCertPathChecker(rc); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
68 |
* CertPathValidatorResult cpvr = cpv.validate(path, params); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
69 |
* </pre> |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
70 |
* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
71 |
* <p>Every implementation of the Java platform is required to support the |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
72 |
* following standard {@code CertPathValidator} algorithm: |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
73 |
* <ul> |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
74 |
* <li>{@code PKIX}</li> |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
75 |
* </ul> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
76 |
* This algorithm is described in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
77 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
78 |
* CertPathValidator section</a> of the |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
79 |
* Java Cryptography Architecture Standard Algorithm Name Documentation. |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
80 |
* Consult the release documentation for your implementation to see if any |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
81 |
* other algorithms are supported. |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
82 |
* |
2 | 83 |
* <p> |
84 |
* <b>Concurrent Access</b> |
|
85 |
* <p> |
|
86 |
* The static methods of this class are guaranteed to be thread-safe. |
|
87 |
* Multiple threads may concurrently invoke the static methods defined in |
|
88 |
* this class with no ill effects. |
|
89 |
* <p> |
|
90 |
* However, this is not true for the non-static methods defined by this class. |
|
91 |
* Unless otherwise documented by a specific provider, threads that need to |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
92 |
* access a single {@code CertPathValidator} instance concurrently should |
2 | 93 |
* synchronize amongst themselves and provide the necessary locking. Multiple |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
94 |
* threads each manipulating a different {@code CertPathValidator} |
2 | 95 |
* instance need not synchronize. |
96 |
* |
|
97 |
* @see CertPath |
|
98 |
* |
|
99 |
* @since 1.4 |
|
100 |
* @author Yassir Elley |
|
101 |
*/ |
|
102 |
public class CertPathValidator { |
|
103 |
||
104 |
/* |
|
105 |
* Constant to lookup in the Security properties file to determine |
|
106 |
* the default certpathvalidator type. In the Security properties file, |
|
107 |
* the default certpathvalidator type is given as: |
|
108 |
* <pre> |
|
109 |
* certpathvalidator.type=PKIX |
|
110 |
* </pre> |
|
111 |
*/ |
|
112 |
private static final String CPV_TYPE = "certpathvalidator.type"; |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
113 |
private final CertPathValidatorSpi validatorSpi; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
114 |
private final Provider provider; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
115 |
private final String algorithm; |
2 | 116 |
|
117 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
118 |
* Creates a {@code CertPathValidator} object of the given algorithm, |
2 | 119 |
* and encapsulates the given provider implementation (SPI object) in it. |
120 |
* |
|
121 |
* @param validatorSpi the provider implementation |
|
122 |
* @param provider the provider |
|
123 |
* @param algorithm the algorithm name |
|
124 |
*/ |
|
125 |
protected CertPathValidator(CertPathValidatorSpi validatorSpi, |
|
126 |
Provider provider, String algorithm) |
|
127 |
{ |
|
128 |
this.validatorSpi = validatorSpi; |
|
129 |
this.provider = provider; |
|
130 |
this.algorithm = algorithm; |
|
131 |
} |
|
132 |
||
133 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
134 |
* Returns a {@code CertPathValidator} object that implements the |
2 | 135 |
* specified algorithm. |
136 |
* |
|
137 |
* <p> This method traverses the list of registered security Providers, |
|
138 |
* starting with the most preferred Provider. |
|
139 |
* A new CertPathValidator object encapsulating the |
|
140 |
* CertPathValidatorSpi implementation from the first |
|
141 |
* Provider that supports the specified algorithm is returned. |
|
142 |
* |
|
143 |
* <p> Note that the list of registered providers may be retrieved via |
|
144 |
* the {@link Security#getProviders() Security.getProviders()} method. |
|
145 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
146 |
* @param algorithm the name of the requested {@code CertPathValidator} |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
147 |
* algorithm. See the CertPathValidator section in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
148 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
149 |
* Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
150 |
* for information about standard algorithm names. |
2 | 151 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
152 |
* @return a {@code CertPathValidator} object that implements the |
2 | 153 |
* specified algorithm. |
154 |
* |
|
155 |
* @exception NoSuchAlgorithmException if no Provider supports a |
|
156 |
* CertPathValidatorSpi implementation for the |
|
157 |
* specified algorithm. |
|
158 |
* |
|
159 |
* @see java.security.Provider |
|
160 |
*/ |
|
161 |
public static CertPathValidator getInstance(String algorithm) |
|
162 |
throws NoSuchAlgorithmException { |
|
163 |
Instance instance = GetInstance.getInstance("CertPathValidator", |
|
164 |
CertPathValidatorSpi.class, algorithm); |
|
165 |
return new CertPathValidator((CertPathValidatorSpi)instance.impl, |
|
166 |
instance.provider, algorithm); |
|
167 |
} |
|
168 |
||
169 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
170 |
* Returns a {@code CertPathValidator} object that implements the |
2 | 171 |
* specified algorithm. |
172 |
* |
|
173 |
* <p> A new CertPathValidator object encapsulating the |
|
174 |
* CertPathValidatorSpi implementation from the specified provider |
|
175 |
* is returned. The specified provider must be registered |
|
176 |
* in the security provider list. |
|
177 |
* |
|
178 |
* <p> Note that the list of registered providers may be retrieved via |
|
179 |
* the {@link Security#getProviders() Security.getProviders()} method. |
|
180 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
181 |
* @param algorithm the name of the requested {@code CertPathValidator} |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
182 |
* algorithm. See the CertPathValidator section in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
183 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
184 |
* Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
185 |
* for information about standard algorithm names. |
2 | 186 |
* |
187 |
* @param provider the name of the provider. |
|
188 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
189 |
* @return a {@code CertPathValidator} object that implements the |
2 | 190 |
* specified algorithm. |
191 |
* |
|
192 |
* @exception NoSuchAlgorithmException if a CertPathValidatorSpi |
|
193 |
* implementation for the specified algorithm is not |
|
194 |
* available from the specified provider. |
|
195 |
* |
|
196 |
* @exception NoSuchProviderException if the specified provider is not |
|
197 |
* registered in the security provider list. |
|
198 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
199 |
* @exception IllegalArgumentException if the {@code provider} is |
2 | 200 |
* null or empty. |
201 |
* |
|
202 |
* @see java.security.Provider |
|
203 |
*/ |
|
204 |
public static CertPathValidator getInstance(String algorithm, |
|
205 |
String provider) throws NoSuchAlgorithmException, |
|
206 |
NoSuchProviderException { |
|
207 |
Instance instance = GetInstance.getInstance("CertPathValidator", |
|
208 |
CertPathValidatorSpi.class, algorithm, provider); |
|
209 |
return new CertPathValidator((CertPathValidatorSpi)instance.impl, |
|
210 |
instance.provider, algorithm); |
|
211 |
} |
|
212 |
||
213 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
214 |
* Returns a {@code CertPathValidator} object that implements the |
2 | 215 |
* specified algorithm. |
216 |
* |
|
217 |
* <p> A new CertPathValidator object encapsulating the |
|
218 |
* CertPathValidatorSpi implementation from the specified Provider |
|
219 |
* object is returned. Note that the specified Provider object |
|
220 |
* does not have to be registered in the provider list. |
|
221 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
222 |
* @param algorithm the name of the requested {@code CertPathValidator} |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
223 |
* algorithm. See the CertPathValidator section in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
224 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
225 |
* Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
226 |
* for information about standard algorithm names. |
2 | 227 |
* |
228 |
* @param provider the provider. |
|
229 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
230 |
* @return a {@code CertPathValidator} object that implements the |
2 | 231 |
* specified algorithm. |
232 |
* |
|
233 |
* @exception NoSuchAlgorithmException if a CertPathValidatorSpi |
|
234 |
* implementation for the specified algorithm is not available |
|
235 |
* from the specified Provider object. |
|
236 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
237 |
* @exception IllegalArgumentException if the {@code provider} is |
2 | 238 |
* null. |
239 |
* |
|
240 |
* @see java.security.Provider |
|
241 |
*/ |
|
242 |
public static CertPathValidator getInstance(String algorithm, |
|
243 |
Provider provider) throws NoSuchAlgorithmException { |
|
244 |
Instance instance = GetInstance.getInstance("CertPathValidator", |
|
245 |
CertPathValidatorSpi.class, algorithm, provider); |
|
246 |
return new CertPathValidator((CertPathValidatorSpi)instance.impl, |
|
247 |
instance.provider, algorithm); |
|
248 |
} |
|
249 |
||
250 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
251 |
* Returns the {@code Provider} of this |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
252 |
* {@code CertPathValidator}. |
2 | 253 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
254 |
* @return the {@code Provider} of this {@code CertPathValidator} |
2 | 255 |
*/ |
256 |
public final Provider getProvider() { |
|
257 |
return this.provider; |
|
258 |
} |
|
259 |
||
260 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
261 |
* Returns the algorithm name of this {@code CertPathValidator}. |
2 | 262 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
263 |
* @return the algorithm name of this {@code CertPathValidator} |
2 | 264 |
*/ |
265 |
public final String getAlgorithm() { |
|
266 |
return this.algorithm; |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
* Validates the specified certification path using the specified |
|
271 |
* algorithm parameter set. |
|
272 |
* <p> |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
273 |
* The {@code CertPath} specified must be of a type that is |
2 | 274 |
* supported by the validation algorithm, otherwise an |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
275 |
* {@code InvalidAlgorithmParameterException} will be thrown. For |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
276 |
* example, a {@code CertPathValidator} that implements the PKIX |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
277 |
* algorithm validates {@code CertPath} objects of type X.509. |
2 | 278 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
279 |
* @param certPath the {@code CertPath} to be validated |
2 | 280 |
* @param params the algorithm parameters |
281 |
* @return the result of the validation algorithm |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
282 |
* @exception CertPathValidatorException if the {@code CertPath} |
2 | 283 |
* does not validate |
284 |
* @exception InvalidAlgorithmParameterException if the specified |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
285 |
* parameters or the type of the specified {@code CertPath} are |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
286 |
* inappropriate for this {@code CertPathValidator} |
2 | 287 |
*/ |
288 |
public final CertPathValidatorResult validate(CertPath certPath, |
|
289 |
CertPathParameters params) |
|
290 |
throws CertPathValidatorException, InvalidAlgorithmParameterException |
|
291 |
{ |
|
292 |
return validatorSpi.engineValidate(certPath, params); |
|
293 |
} |
|
294 |
||
295 |
/** |
|
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
296 |
* Returns the default {@code CertPathValidator} type as specified by |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
297 |
* the {@code certpathvalidator.type} security property, or the string |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
298 |
* {@literal "PKIX"} if no such property exists. |
2 | 299 |
* |
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
300 |
* <p>The default {@code CertPathValidator} type can be used by |
2 | 301 |
* applications that do not want to use a hard-coded type when calling one |
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
302 |
* of the {@code getInstance} methods, and want to provide a default |
2 | 303 |
* type in case a user does not specify its own. |
304 |
* |
|
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
305 |
* <p>The default {@code CertPathValidator} type can be changed by |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
306 |
* setting the value of the {@code certpathvalidator.type} security |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
307 |
* property to the desired type. |
2 | 308 |
* |
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
309 |
* @see java.security.Security security properties |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
310 |
* @return the default {@code CertPathValidator} type as specified |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
311 |
* by the {@code certpathvalidator.type} security property, or the string |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
312 |
* {@literal "PKIX"} if no such property exists. |
2 | 313 |
*/ |
314 |
public final static String getDefaultType() { |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
315 |
String cpvtype = |
30033
b9c86c17164a
8078468: Update security libraries to use diamond with anonymous classes
darcy
parents:
25859
diff
changeset
|
316 |
AccessController.doPrivileged(new PrivilegedAction<>() { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
317 |
public String run() { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
318 |
return Security.getProperty(CPV_TYPE); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
319 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
320 |
}); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
321 |
return (cpvtype == null) ? "PKIX" : cpvtype; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
322 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
323 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
324 |
/** |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
325 |
* Returns a {@code CertPathChecker} that the encapsulated |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
326 |
* {@code CertPathValidatorSpi} implementation uses to check the revocation |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
327 |
* status of certificates. A PKIX implementation returns objects of |
14402 | 328 |
* type {@code PKIXRevocationChecker}. Each invocation of this method |
329 |
* returns a new instance of {@code CertPathChecker}. |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
330 |
* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
331 |
* <p>The primary purpose of this method is to allow callers to specify |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
332 |
* additional input parameters and options specific to revocation checking. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
333 |
* See the class description for an example. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
334 |
* |
14402 | 335 |
* @return a {@code CertPathChecker} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
336 |
* @throws UnsupportedOperationException if the service provider does not |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
337 |
* support this method |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
338 |
* @since 1.8 |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
339 |
*/ |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
340 |
public final CertPathChecker getRevocationChecker() { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
341 |
return validatorSpi.engineGetRevocationChecker(); |
2 | 342 |
} |
343 |
} |