author | martin |
Tue, 15 Sep 2015 21:56:04 -0700 | |
changeset 32649 | 2ee9017c7597 |
parent 30033 | b9c86c17164a |
child 33241 | 27eb2d6abda9 |
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 building certification paths (also known as certificate chains). |
|
42 |
* <p> |
|
43 |
* 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
|
44 |
* To create a {@code CertPathBuilder}, call |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
45 |
* 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
|
46 |
* algorithm name of the {@code CertPathBuilder} desired and optionally |
2 | 47 |
* the name of the provider desired. |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
48 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
49 |
* <p>Once a {@code CertPathBuilder} object has been created, certification |
2 | 50 |
* paths can be constructed by calling the {@link #build build} method and |
51 |
* passing it an algorithm-specific set of parameters. If successful, the |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
52 |
* result (including the {@code CertPath} that was built) is returned |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
53 |
* in an object that implements the {@code CertPathBuilderResult} |
2 | 54 |
* interface. |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
55 |
* |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
56 |
* <p>The {@link #getRevocationChecker} method allows an application to specify |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
57 |
* additional algorithm-specific parameters and options used by the |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
58 |
* {@code CertPathBuilder} when checking the revocation status of certificates. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
59 |
* Here is an example demonstrating how it is used with the PKIX algorithm: |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
60 |
* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
61 |
* <pre> |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
62 |
* CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX"); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
63 |
* PKIXRevocationChecker rc = (PKIXRevocationChecker)cpb.getRevocationChecker(); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
64 |
* rc.setOptions(EnumSet.of(Option.PREFER_CRLS)); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
65 |
* params.addCertPathChecker(rc); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
66 |
* CertPathBuilderResult cpbr = cpb.build(params); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
67 |
* </pre> |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
68 |
* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
69 |
* <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
|
70 |
* following standard {@code CertPathBuilder} algorithm: |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
71 |
* <ul> |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
72 |
* <li>{@code PKIX}</li> |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
73 |
* </ul> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
74 |
* This algorithm is described in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
75 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
76 |
* CertPathBuilder section</a> of the |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
77 |
* Java Cryptography Architecture Standard Algorithm Name Documentation. |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
78 |
* 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
|
79 |
* other algorithms are supported. |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
80 |
* |
2 | 81 |
* <p> |
82 |
* <b>Concurrent Access</b> |
|
83 |
* <p> |
|
84 |
* The static methods of this class are guaranteed to be thread-safe. |
|
85 |
* Multiple threads may concurrently invoke the static methods defined in |
|
86 |
* this class with no ill effects. |
|
87 |
* <p> |
|
88 |
* However, this is not true for the non-static methods defined by this class. |
|
89 |
* 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
|
90 |
* access a single {@code CertPathBuilder} instance concurrently should |
2 | 91 |
* 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
|
92 |
* threads each manipulating a different {@code CertPathBuilder} instance |
2 | 93 |
* need not synchronize. |
94 |
* |
|
95 |
* @see CertPath |
|
96 |
* |
|
97 |
* @since 1.4 |
|
98 |
* @author Sean Mullan |
|
99 |
* @author Yassir Elley |
|
100 |
*/ |
|
101 |
public class CertPathBuilder { |
|
102 |
||
103 |
/* |
|
104 |
* Constant to lookup in the Security properties file to determine |
|
105 |
* the default certpathbuilder type. In the Security properties file, |
|
106 |
* the default certpathbuilder type is given as: |
|
107 |
* <pre> |
|
108 |
* certpathbuilder.type=PKIX |
|
109 |
* </pre> |
|
110 |
*/ |
|
111 |
private static final String CPB_TYPE = "certpathbuilder.type"; |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
112 |
private final CertPathBuilderSpi builderSpi; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
113 |
private final Provider provider; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
114 |
private final String algorithm; |
2 | 115 |
|
116 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
117 |
* Creates a {@code CertPathBuilder} object of the given algorithm, |
2 | 118 |
* and encapsulates the given provider implementation (SPI object) in it. |
119 |
* |
|
120 |
* @param builderSpi the provider implementation |
|
121 |
* @param provider the provider |
|
122 |
* @param algorithm the algorithm name |
|
123 |
*/ |
|
124 |
protected CertPathBuilder(CertPathBuilderSpi builderSpi, Provider provider, |
|
125 |
String algorithm) |
|
126 |
{ |
|
127 |
this.builderSpi = builderSpi; |
|
128 |
this.provider = provider; |
|
129 |
this.algorithm = algorithm; |
|
130 |
} |
|
131 |
||
132 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
133 |
* Returns a {@code CertPathBuilder} object that implements the |
2 | 134 |
* specified algorithm. |
135 |
* |
|
136 |
* <p> This method traverses the list of registered security Providers, |
|
137 |
* starting with the most preferred Provider. |
|
138 |
* A new CertPathBuilder object encapsulating the |
|
139 |
* CertPathBuilderSpi implementation from the first |
|
140 |
* Provider that supports the specified algorithm is returned. |
|
141 |
* |
|
142 |
* <p> Note that the list of registered providers may be retrieved via |
|
143 |
* the {@link Security#getProviders() Security.getProviders()} method. |
|
144 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
145 |
* @param algorithm the name of the requested {@code CertPathBuilder} |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
146 |
* algorithm. See the CertPathBuilder section in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
147 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
148 |
* Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
149 |
* for information about standard algorithm names. |
2 | 150 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
151 |
* @return a {@code CertPathBuilder} object that implements the |
2 | 152 |
* specified algorithm. |
153 |
* |
|
154 |
* @throws NoSuchAlgorithmException if no Provider supports a |
|
155 |
* CertPathBuilderSpi implementation for the |
|
156 |
* specified algorithm. |
|
157 |
* |
|
158 |
* @see java.security.Provider |
|
159 |
*/ |
|
160 |
public static CertPathBuilder getInstance(String algorithm) |
|
161 |
throws NoSuchAlgorithmException { |
|
162 |
Instance instance = GetInstance.getInstance("CertPathBuilder", |
|
163 |
CertPathBuilderSpi.class, algorithm); |
|
164 |
return new CertPathBuilder((CertPathBuilderSpi)instance.impl, |
|
165 |
instance.provider, algorithm); |
|
166 |
} |
|
167 |
||
168 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
169 |
* Returns a {@code CertPathBuilder} object that implements the |
2 | 170 |
* specified algorithm. |
171 |
* |
|
172 |
* <p> A new CertPathBuilder object encapsulating the |
|
173 |
* CertPathBuilderSpi implementation from the specified provider |
|
174 |
* is returned. The specified provider must be registered |
|
175 |
* in the security provider list. |
|
176 |
* |
|
177 |
* <p> Note that the list of registered providers may be retrieved via |
|
178 |
* the {@link Security#getProviders() Security.getProviders()} method. |
|
179 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
180 |
* @param algorithm the name of the requested {@code CertPathBuilder} |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
181 |
* algorithm. See the CertPathBuilder section in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
182 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
183 |
* Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
184 |
* for information about standard algorithm names. |
2 | 185 |
* |
186 |
* @param provider the name of the provider. |
|
187 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
188 |
* @return a {@code CertPathBuilder} object that implements the |
2 | 189 |
* specified algorithm. |
190 |
* |
|
191 |
* @throws NoSuchAlgorithmException if a CertPathBuilderSpi |
|
192 |
* implementation for the specified algorithm is not |
|
193 |
* available from the specified provider. |
|
194 |
* |
|
195 |
* @throws NoSuchProviderException if the specified provider is not |
|
196 |
* registered in the security provider list. |
|
197 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
198 |
* @exception IllegalArgumentException if the {@code provider} is |
2 | 199 |
* null or empty. |
200 |
* |
|
201 |
* @see java.security.Provider |
|
202 |
*/ |
|
203 |
public static CertPathBuilder getInstance(String algorithm, String provider) |
|
204 |
throws NoSuchAlgorithmException, NoSuchProviderException { |
|
205 |
Instance instance = GetInstance.getInstance("CertPathBuilder", |
|
206 |
CertPathBuilderSpi.class, algorithm, provider); |
|
207 |
return new CertPathBuilder((CertPathBuilderSpi)instance.impl, |
|
208 |
instance.provider, algorithm); |
|
209 |
} |
|
210 |
||
211 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
212 |
* Returns a {@code CertPathBuilder} object that implements the |
2 | 213 |
* specified algorithm. |
214 |
* |
|
215 |
* <p> A new CertPathBuilder object encapsulating the |
|
216 |
* CertPathBuilderSpi implementation from the specified Provider |
|
217 |
* object is returned. Note that the specified Provider object |
|
218 |
* does not have to be registered in the provider list. |
|
219 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
220 |
* @param algorithm the name of the requested {@code CertPathBuilder} |
8152
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
221 |
* algorithm. See the CertPathBuilder section in the <a href= |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
222 |
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder"> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
223 |
* Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
94e5966bdf22
5001004: Required Security Algorithms need to be defined
mullan
parents:
5506
diff
changeset
|
224 |
* for information about standard algorithm names. |
2 | 225 |
* |
226 |
* @param provider the provider. |
|
227 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
228 |
* @return a {@code CertPathBuilder} object that implements the |
2 | 229 |
* specified algorithm. |
230 |
* |
|
231 |
* @exception NoSuchAlgorithmException if a CertPathBuilderSpi |
|
232 |
* implementation for the specified algorithm is not available |
|
233 |
* from the specified Provider object. |
|
234 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
235 |
* @exception IllegalArgumentException if the {@code provider} is |
2 | 236 |
* null. |
237 |
* |
|
238 |
* @see java.security.Provider |
|
239 |
*/ |
|
240 |
public static CertPathBuilder getInstance(String algorithm, |
|
241 |
Provider provider) throws NoSuchAlgorithmException { |
|
242 |
Instance instance = GetInstance.getInstance("CertPathBuilder", |
|
243 |
CertPathBuilderSpi.class, algorithm, provider); |
|
244 |
return new CertPathBuilder((CertPathBuilderSpi)instance.impl, |
|
245 |
instance.provider, algorithm); |
|
246 |
} |
|
247 |
||
248 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
249 |
* Returns the provider of this {@code CertPathBuilder}. |
2 | 250 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
251 |
* @return the provider of this {@code CertPathBuilder} |
2 | 252 |
*/ |
253 |
public final Provider getProvider() { |
|
254 |
return this.provider; |
|
255 |
} |
|
256 |
||
257 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
258 |
* Returns the name of the algorithm of this {@code CertPathBuilder}. |
2 | 259 |
* |
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
260 |
* @return the name of the algorithm of this {@code CertPathBuilder} |
2 | 261 |
*/ |
262 |
public final String getAlgorithm() { |
|
263 |
return this.algorithm; |
|
264 |
} |
|
265 |
||
266 |
/** |
|
267 |
* Attempts to build a certification path using the specified algorithm |
|
268 |
* parameter set. |
|
269 |
* |
|
270 |
* @param params the algorithm parameters |
|
271 |
* @return the result of the build algorithm |
|
272 |
* @throws CertPathBuilderException if the builder is unable to construct |
|
273 |
* a certification path that satisfies the specified parameters |
|
274 |
* @throws InvalidAlgorithmParameterException if the specified parameters |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14775
diff
changeset
|
275 |
* are inappropriate for this {@code CertPathBuilder} |
2 | 276 |
*/ |
277 |
public final CertPathBuilderResult build(CertPathParameters params) |
|
278 |
throws CertPathBuilderException, InvalidAlgorithmParameterException |
|
279 |
{ |
|
280 |
return builderSpi.engineBuild(params); |
|
281 |
} |
|
282 |
||
283 |
/** |
|
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
284 |
* Returns the default {@code CertPathBuilder} type as specified by |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
285 |
* the {@code certpathbuilder.type} security property, or the string |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
286 |
* {@literal "PKIX"} if no such property exists. |
2 | 287 |
* |
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
288 |
* <p>The default {@code CertPathBuilder} type can be used by |
2 | 289 |
* 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
|
290 |
* of the {@code getInstance} methods, and want to provide a default |
2 | 291 |
* type in case a user does not specify its own. |
292 |
* |
|
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
293 |
* <p>The default {@code CertPathBuilder} type can be changed by |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
294 |
* setting the value of the {@code certpathbuilder.type} security property |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
295 |
* to the desired type. |
2 | 296 |
* |
14775
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
297 |
* @see java.security.Security security properties |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
298 |
* @return the default {@code CertPathBuilder} type as specified |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
299 |
* by the {@code certpathbuilder.type} security property, or the string |
2ed01c760aea
8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents:
14402
diff
changeset
|
300 |
* {@literal "PKIX"} if no such property exists. |
2 | 301 |
*/ |
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30033
diff
changeset
|
302 |
public static final String getDefaultType() { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
303 |
String cpbtype = |
30033
b9c86c17164a
8078468: Update security libraries to use diamond with anonymous classes
darcy
parents:
25859
diff
changeset
|
304 |
AccessController.doPrivileged(new PrivilegedAction<>() { |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
305 |
public String run() { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
306 |
return Security.getProperty(CPB_TYPE); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
307 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
308 |
}); |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
309 |
return (cpbtype == null) ? "PKIX" : cpbtype; |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
310 |
} |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
311 |
|
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
312 |
/** |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
313 |
* Returns a {@code CertPathChecker} that the encapsulated |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
314 |
* {@code CertPathBuilderSpi} implementation uses to check the revocation |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
315 |
* status of certificates. A PKIX implementation returns objects of |
14402 | 316 |
* type {@code PKIXRevocationChecker}. Each invocation of this method |
317 |
* returns a new instance of {@code CertPathChecker}. |
|
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
318 |
* |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
319 |
* <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
|
320 |
* additional input parameters and options specific to revocation checking. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
321 |
* See the class description for an example. |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
322 |
* |
14402 | 323 |
* @return a {@code CertPathChecker} |
12860
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
324 |
* @throws UnsupportedOperationException if the service provider does not |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
325 |
* support this method |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
326 |
* @since 1.8 |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
327 |
*/ |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
328 |
public final CertPathChecker getRevocationChecker() { |
9ffbd4e43413
6854712: Revocation checking enhancements (JEP-124)
mullan
parents:
9035
diff
changeset
|
329 |
return builderSpi.engineGetRevocationChecker(); |
2 | 330 |
} |
331 |
} |