author | mullan |
Thu, 11 Sep 2008 14:05:16 -0400 | |
changeset 1238 | 6d1f4b722acd |
parent 715 | f16baef3a20e |
child 3214 | 3ee25b27ed91 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
715 | 2 |
* Copyright 2003-2008 Sun Microsystems, Inc. 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 |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
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 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.security.provider.certpath; |
|
27 |
||
28 |
import java.io.*; |
|
29 |
import java.math.BigInteger; |
|
30 |
import java.util.*; |
|
31 |
import java.security.AccessController; |
|
32 |
import java.security.Principal; |
|
33 |
import java.security.PrivilegedAction; |
|
34 |
import java.security.Security; |
|
35 |
import java.security.cert.*; |
|
1238
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
715
diff
changeset
|
36 |
import java.security.cert.CertPathValidatorException.BasicReason; |
2 | 37 |
import java.net.*; |
38 |
import javax.security.auth.x500.X500Principal; |
|
39 |
||
40 |
import sun.security.util.*; |
|
41 |
import sun.security.x509.*; |
|
42 |
||
43 |
/** |
|
44 |
* OCSPChecker is a <code>PKIXCertPathChecker</code> that uses the |
|
45 |
* Online Certificate Status Protocol (OCSP) as specified in RFC 2560 |
|
46 |
* <a href="http://www.ietf.org/rfc/rfc2560.txt"> |
|
47 |
* http://www.ietf.org/rfc/rfc2560.txt</a>. |
|
48 |
* |
|
49 |
* @author Ram Marti |
|
50 |
*/ |
|
51 |
class OCSPChecker extends PKIXCertPathChecker { |
|
52 |
||
53 |
public static final String OCSP_ENABLE_PROP = "ocsp.enable"; |
|
54 |
public static final String OCSP_URL_PROP = "ocsp.responderURL"; |
|
55 |
public static final String OCSP_CERT_SUBJECT_PROP = |
|
56 |
"ocsp.responderCertSubjectName"; |
|
57 |
public static final String OCSP_CERT_ISSUER_PROP = |
|
58 |
"ocsp.responderCertIssuerName"; |
|
59 |
public static final String OCSP_CERT_NUMBER_PROP = |
|
60 |
"ocsp.responderCertSerialNumber"; |
|
61 |
||
62 |
private static final String HEX_DIGITS = "0123456789ABCDEFabcdef"; |
|
63 |
private static final Debug DEBUG = Debug.getInstance("certpath"); |
|
64 |
private static final boolean dump = false; |
|
65 |
||
66 |
// Supported extensions |
|
67 |
private static final int OCSP_NONCE_DATA[] = |
|
68 |
{ 1, 3, 6, 1, 5, 5, 7, 48, 1, 2 }; |
|
69 |
private static final ObjectIdentifier OCSP_NONCE_OID; |
|
70 |
static { |
|
71 |
OCSP_NONCE_OID = ObjectIdentifier.newInternal(OCSP_NONCE_DATA); |
|
72 |
} |
|
73 |
||
74 |
private int remainingCerts; |
|
75 |
||
76 |
private X509Certificate[] certs; |
|
77 |
||
78 |
private CertPath cp; |
|
79 |
||
80 |
private PKIXParameters pkixParams; |
|
81 |
||
82 |
/** |
|
83 |
* Default Constructor |
|
84 |
* |
|
85 |
* @param certPath the X509 certification path |
|
86 |
* @param pkixParams the input PKIX parameter set |
|
87 |
* @exception CertPathValidatorException Exception thrown if cert path |
|
88 |
* does not validate. |
|
89 |
*/ |
|
90 |
OCSPChecker(CertPath certPath, PKIXParameters pkixParams) |
|
91 |
throws CertPathValidatorException { |
|
92 |
||
93 |
this.cp = certPath; |
|
94 |
this.pkixParams = pkixParams; |
|
95 |
List<? extends Certificate> tmp = cp.getCertificates(); |
|
96 |
certs = tmp.toArray(new X509Certificate[tmp.size()]); |
|
97 |
init(false); |
|
98 |
} |
|
99 |
||
100 |
/** |
|
101 |
* Initializes the internal state of the checker from parameters |
|
102 |
* specified in the constructor |
|
103 |
*/ |
|
104 |
public void init(boolean forward) throws CertPathValidatorException { |
|
105 |
if (!forward) { |
|
625
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
106 |
remainingCerts = certs.length + 1; |
2 | 107 |
} else { |
108 |
throw new CertPathValidatorException( |
|
109 |
"Forward checking not supported"); |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
public boolean isForwardCheckingSupported() { |
|
114 |
return false; |
|
115 |
} |
|
116 |
||
117 |
public Set<String> getSupportedExtensions() { |
|
118 |
return Collections.<String>emptySet(); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Sends an OCSPRequest for the certificate to the OCSP Server and |
|
123 |
* processes the response back from the OCSP Server. |
|
124 |
* |
|
125 |
* @param cert the Certificate |
|
126 |
* @param unresolvedCritExts the unresolved critical extensions |
|
127 |
* @exception CertPathValidatorException Exception is thrown if the |
|
128 |
* certificate has been revoked. |
|
129 |
*/ |
|
130 |
public void check(Certificate cert, Collection<String> unresolvedCritExts) |
|
131 |
throws CertPathValidatorException { |
|
132 |
||
133 |
InputStream in = null; |
|
134 |
OutputStream out = null; |
|
625
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
135 |
|
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
136 |
// Decrement the certificate counter |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
137 |
remainingCerts--; |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
138 |
|
2 | 139 |
try { |
140 |
X509Certificate responderCert = null; |
|
141 |
boolean seekResponderCert = false; |
|
142 |
X500Principal responderSubjectName = null; |
|
143 |
X500Principal responderIssuerName = null; |
|
144 |
BigInteger responderSerialNumber = null; |
|
145 |
||
625
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
146 |
boolean seekIssuerCert = true; |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
147 |
X509CertImpl issuerCertImpl = null; |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
148 |
X509CertImpl currCertImpl = |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
149 |
X509CertImpl.toImpl((X509Certificate)cert); |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
150 |
|
2 | 151 |
/* |
152 |
* OCSP security property values, in the following order: |
|
153 |
* 1. ocsp.responderURL |
|
154 |
* 2. ocsp.responderCertSubjectName |
|
155 |
* 3. ocsp.responderCertIssuerName |
|
156 |
* 4. ocsp.responderCertSerialNumber |
|
157 |
*/ |
|
158 |
String[] properties = getOCSPProperties(); |
|
159 |
||
625
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
160 |
// Check whether OCSP is feasible before seeking cert information |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
161 |
URL url = getOCSPServerURL(currCertImpl, properties); |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
162 |
|
2 | 163 |
// When responder's subject name is set then the issuer/serial |
164 |
// properties are ignored |
|
165 |
if (properties[1] != null) { |
|
166 |
responderSubjectName = new X500Principal(properties[1]); |
|
167 |
||
168 |
} else if (properties[2] != null && properties[3] != null) { |
|
169 |
responderIssuerName = new X500Principal(properties[2]); |
|
170 |
// remove colon or space separators |
|
171 |
String value = stripOutSeparators(properties[3]); |
|
172 |
responderSerialNumber = new BigInteger(value, 16); |
|
173 |
||
174 |
} else if (properties[2] != null || properties[3] != null) { |
|
175 |
throw new CertPathValidatorException( |
|
176 |
"Must specify both ocsp.responderCertIssuerName and " + |
|
177 |
"ocsp.responderCertSerialNumber properties"); |
|
178 |
} |
|
179 |
||
180 |
// If the OCSP responder cert properties are set then the |
|
181 |
// identified cert must be located in the trust anchors or |
|
182 |
// in the cert stores. |
|
183 |
if (responderSubjectName != null || responderIssuerName != null) { |
|
184 |
seekResponderCert = true; |
|
185 |
} |
|
186 |
||
625
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
187 |
// Set the issuer certificate to the next cert in the chain |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
188 |
// (unless we're processing the final cert). |
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
189 |
if (remainingCerts < certs.length) { |
2 | 190 |
issuerCertImpl = X509CertImpl.toImpl(certs[remainingCerts]); |
191 |
seekIssuerCert = false; // done |
|
192 |
||
193 |
// By default, the OCSP responder's cert is the same as the |
|
194 |
// issuer of the cert being validated. |
|
195 |
if (! seekResponderCert) { |
|
196 |
responderCert = certs[remainingCerts]; |
|
197 |
if (DEBUG != null) { |
|
198 |
DEBUG.println("Responder's certificate is the same " + |
|
199 |
"as the issuer of the certificate being validated"); |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
// Check anchor certs for: |
|
205 |
// - the issuer cert (of the cert being validated) |
|
206 |
// - the OCSP responder's cert |
|
207 |
if (seekIssuerCert || seekResponderCert) { |
|
208 |
||
209 |
if (DEBUG != null && seekResponderCert) { |
|
210 |
DEBUG.println("Searching trust anchors for responder's " + |
|
211 |
"certificate"); |
|
212 |
} |
|
213 |
||
214 |
// Extract the anchor certs |
|
215 |
Iterator anchors = pkixParams.getTrustAnchors().iterator(); |
|
216 |
if (! anchors.hasNext()) { |
|
217 |
throw new CertPathValidatorException( |
|
218 |
"Must specify at least one trust anchor"); |
|
219 |
} |
|
220 |
||
221 |
X500Principal certIssuerName = |
|
222 |
currCertImpl.getIssuerX500Principal(); |
|
223 |
while (anchors.hasNext() && |
|
224 |
(seekIssuerCert || seekResponderCert)) { |
|
225 |
||
226 |
TrustAnchor anchor = (TrustAnchor)anchors.next(); |
|
227 |
X509Certificate anchorCert = anchor.getTrustedCert(); |
|
228 |
X500Principal anchorSubjectName = |
|
229 |
anchorCert.getSubjectX500Principal(); |
|
230 |
||
231 |
if (dump) { |
|
232 |
System.out.println("Issuer DN is " + certIssuerName); |
|
233 |
System.out.println("Subject DN is " + |
|
234 |
anchorSubjectName); |
|
235 |
} |
|
236 |
||
237 |
// Check if anchor cert is the issuer cert |
|
238 |
if (seekIssuerCert && |
|
239 |
certIssuerName.equals(anchorSubjectName)) { |
|
240 |
||
241 |
issuerCertImpl = X509CertImpl.toImpl(anchorCert); |
|
242 |
seekIssuerCert = false; // done |
|
243 |
||
244 |
// By default, the OCSP responder's cert is the same as |
|
245 |
// the issuer of the cert being validated. |
|
246 |
if (! seekResponderCert && responderCert == null) { |
|
247 |
responderCert = anchorCert; |
|
248 |
if (DEBUG != null) { |
|
249 |
DEBUG.println("Responder's certificate is the" + |
|
250 |
" same as the issuer of the certificate " + |
|
251 |
"being validated"); |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
// Check if anchor cert is the responder cert |
|
257 |
if (seekResponderCert) { |
|
258 |
// Satisfy the responder subject name property only, or |
|
259 |
// satisfy the responder issuer name and serial number |
|
260 |
// properties only |
|
261 |
if ((responderSubjectName != null && |
|
262 |
responderSubjectName.equals(anchorSubjectName)) || |
|
263 |
(responderIssuerName != null && |
|
264 |
responderSerialNumber != null && |
|
265 |
responderIssuerName.equals( |
|
266 |
anchorCert.getIssuerX500Principal()) && |
|
267 |
responderSerialNumber.equals( |
|
268 |
anchorCert.getSerialNumber()))) { |
|
269 |
||
270 |
responderCert = anchorCert; |
|
271 |
seekResponderCert = false; // done |
|
272 |
} |
|
273 |
} |
|
274 |
} |
|
275 |
if (issuerCertImpl == null) { |
|
276 |
throw new CertPathValidatorException( |
|
277 |
"No trusted certificate for " + |
|
278 |
currCertImpl.getIssuerDN()); |
|
279 |
} |
|
280 |
||
281 |
// Check cert stores if responder cert has not yet been found |
|
282 |
if (seekResponderCert) { |
|
283 |
if (DEBUG != null) { |
|
284 |
DEBUG.println("Searching cert stores for responder's " + |
|
285 |
"certificate"); |
|
286 |
} |
|
287 |
X509CertSelector filter = null; |
|
288 |
if (responderSubjectName != null) { |
|
289 |
filter = new X509CertSelector(); |
|
290 |
filter.setSubject(responderSubjectName.getName()); |
|
291 |
} else if (responderIssuerName != null && |
|
292 |
responderSerialNumber != null) { |
|
293 |
filter = new X509CertSelector(); |
|
294 |
filter.setIssuer(responderIssuerName.getName()); |
|
295 |
filter.setSerialNumber(responderSerialNumber); |
|
296 |
} |
|
297 |
if (filter != null) { |
|
298 |
List<CertStore> certStores = pkixParams.getCertStores(); |
|
299 |
for (CertStore certStore : certStores) { |
|
300 |
Iterator i = |
|
301 |
certStore.getCertificates(filter).iterator(); |
|
302 |
if (i.hasNext()) { |
|
303 |
responderCert = (X509Certificate) i.next(); |
|
304 |
seekResponderCert = false; // done |
|
305 |
break; |
|
306 |
} |
|
307 |
} |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
// Could not find the certificate identified in the OCSP properties |
|
313 |
if (seekResponderCert) { |
|
314 |
throw new CertPathValidatorException( |
|
315 |
"Cannot find the responder's certificate " + |
|
316 |
"(set using the OCSP security properties)."); |
|
317 |
} |
|
318 |
||
319 |
// Construct an OCSP Request |
|
320 |
OCSPRequest ocspRequest = |
|
321 |
new OCSPRequest(currCertImpl, issuerCertImpl); |
|
625
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
322 |
|
ba0b63c29671
6383078: OCSP checking does not work on end-entity certificate
vinnie
parents:
2
diff
changeset
|
323 |
// Use the URL to the OCSP service that was created earlier |
2 | 324 |
HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
325 |
if (DEBUG != null) { |
|
326 |
DEBUG.println("connecting to OCSP service at: " + url); |
|
327 |
} |
|
328 |
||
329 |
// Indicate that both input and output will be performed, |
|
330 |
// that the method is POST, and that the content length is |
|
331 |
// the length of the byte array |
|
332 |
||
333 |
con.setDoOutput(true); |
|
334 |
con.setDoInput(true); |
|
335 |
con.setRequestMethod("POST"); |
|
336 |
con.setRequestProperty("Content-type", "application/ocsp-request"); |
|
337 |
byte[] bytes = ocspRequest.encodeBytes(); |
|
338 |
CertId certId = ocspRequest.getCertId(); |
|
339 |
||
340 |
con.setRequestProperty("Content-length", |
|
341 |
String.valueOf(bytes.length)); |
|
342 |
out = con.getOutputStream(); |
|
343 |
out.write(bytes); |
|
344 |
out.flush(); |
|
345 |
||
346 |
// Check the response |
|
347 |
if (DEBUG != null && |
|
348 |
con.getResponseCode() != HttpURLConnection.HTTP_OK) { |
|
349 |
DEBUG.println("Received HTTP error: " + con.getResponseCode() + |
|
350 |
" - " + con.getResponseMessage()); |
|
351 |
} |
|
352 |
in = con.getInputStream(); |
|
353 |
||
354 |
int contentLength = con.getContentLength(); |
|
355 |
if (contentLength == -1) { |
|
356 |
contentLength = Integer.MAX_VALUE; |
|
357 |
} |
|
358 |
||
359 |
byte[] response = new byte[contentLength]; |
|
360 |
int total = 0; |
|
361 |
int count = 0; |
|
362 |
while (count != -1 && total < contentLength) { |
|
363 |
count = in.read(response, total, response.length - total); |
|
364 |
total += count; |
|
365 |
} |
|
366 |
||
367 |
OCSPResponse ocspResponse = new OCSPResponse(response, pkixParams, |
|
368 |
responderCert); |
|
369 |
// Check that response applies to the cert that was supplied |
|
370 |
if (! certId.equals(ocspResponse.getCertId())) { |
|
371 |
throw new CertPathValidatorException( |
|
372 |
"Certificate in the OCSP response does not match the " + |
|
373 |
"certificate supplied in the OCSP request."); |
|
374 |
} |
|
375 |
SerialNumber serialNumber = currCertImpl.getSerialNumberObject(); |
|
376 |
int certOCSPStatus = ocspResponse.getCertStatus(serialNumber); |
|
377 |
||
378 |
if (DEBUG != null) { |
|
379 |
DEBUG.println("Status of certificate (with serial number " + |
|
380 |
serialNumber.getNumber() + ") is: " + |
|
381 |
OCSPResponse.certStatusToText(certOCSPStatus)); |
|
382 |
} |
|
383 |
||
384 |
if (certOCSPStatus == OCSPResponse.CERT_STATUS_REVOKED) { |
|
1238
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
715
diff
changeset
|
385 |
Throwable t = new CertificateRevokedException( |
2 | 386 |
ocspResponse.getRevocationTime(), |
387 |
ocspResponse.getRevocationReason(), |
|
388 |
responderCert.getSubjectX500Principal(), |
|
1238
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
715
diff
changeset
|
389 |
ocspResponse.getSingleExtensions()); |
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
715
diff
changeset
|
390 |
throw new CertPathValidatorException(t.getMessage(), t, |
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
715
diff
changeset
|
391 |
null, -1, BasicReason.REVOKED); |
2 | 392 |
|
393 |
} else if (certOCSPStatus == OCSPResponse.CERT_STATUS_UNKNOWN) { |
|
394 |
throw new CertPathValidatorException( |
|
395 |
"Certificate's revocation status is unknown", null, cp, |
|
1238
6d1f4b722acd
6465942: Add problem identification facility to the CertPathValidator framework
mullan
parents:
715
diff
changeset
|
396 |
remainingCerts, BasicReason.UNDETERMINED_REVOCATION_STATUS); |
2 | 397 |
} |
398 |
} catch (Exception e) { |
|
399 |
throw new CertPathValidatorException(e); |
|
400 |
} finally { |
|
401 |
if (in != null) { |
|
402 |
try { |
|
403 |
in.close(); |
|
404 |
} catch (IOException ioe) { |
|
405 |
throw new CertPathValidatorException(ioe); |
|
406 |
} |
|
407 |
} |
|
408 |
if (out != null) { |
|
409 |
try { |
|
410 |
out.close(); |
|
411 |
} catch (IOException ioe) { |
|
412 |
throw new CertPathValidatorException(ioe); |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
} |
|
417 |
||
418 |
/* |
|
419 |
* The OCSP security property values are in the following order: |
|
420 |
* 1. ocsp.responderURL |
|
421 |
* 2. ocsp.responderCertSubjectName |
|
422 |
* 3. ocsp.responderCertIssuerName |
|
423 |
* 4. ocsp.responderCertSerialNumber |
|
424 |
*/ |
|
425 |
private static URL getOCSPServerURL(X509CertImpl currCertImpl, |
|
426 |
String[] properties) |
|
427 |
throws CertificateParsingException, CertPathValidatorException { |
|
428 |
||
429 |
if (properties[0] != null) { |
|
430 |
try { |
|
431 |
return new URL(properties[0]); |
|
432 |
} catch (java.net.MalformedURLException e) { |
|
433 |
throw new CertPathValidatorException(e); |
|
434 |
} |
|
435 |
} |
|
436 |
||
437 |
// Examine the certificate's AuthorityInfoAccess extension |
|
438 |
||
439 |
AuthorityInfoAccessExtension aia = |
|
440 |
currCertImpl.getAuthorityInfoAccessExtension(); |
|
441 |
if (aia == null) { |
|
442 |
throw new CertPathValidatorException( |
|
443 |
"Must specify the location of an OCSP Responder"); |
|
444 |
} |
|
445 |
||
446 |
List<AccessDescription> descriptions = aia.getAccessDescriptions(); |
|
447 |
for (AccessDescription description : descriptions) { |
|
448 |
if (description.getAccessMethod().equals( |
|
449 |
AccessDescription.Ad_OCSP_Id)) { |
|
450 |
||
451 |
GeneralName generalName = description.getAccessLocation(); |
|
452 |
if (generalName.getType() == GeneralNameInterface.NAME_URI) { |
|
453 |
try { |
|
454 |
URIName uri = (URIName) generalName.getName(); |
|
455 |
return (new URL(uri.getName())); |
|
456 |
||
457 |
} catch (java.net.MalformedURLException e) { |
|
458 |
throw new CertPathValidatorException(e); |
|
459 |
} |
|
460 |
} |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
throw new CertPathValidatorException( |
|
465 |
"Cannot find the location of the OCSP Responder"); |
|
466 |
} |
|
467 |
||
468 |
/* |
|
469 |
* Retrieves the values of the OCSP security properties. |
|
470 |
*/ |
|
471 |
private static String[] getOCSPProperties() { |
|
472 |
final String[] properties = new String[4]; |
|
473 |
||
474 |
AccessController.doPrivileged( |
|
475 |
new PrivilegedAction<Void>() { |
|
476 |
public Void run() { |
|
477 |
properties[0] = Security.getProperty(OCSP_URL_PROP); |
|
478 |
properties[1] = |
|
479 |
Security.getProperty(OCSP_CERT_SUBJECT_PROP); |
|
480 |
properties[2] = |
|
481 |
Security.getProperty(OCSP_CERT_ISSUER_PROP); |
|
482 |
properties[3] = |
|
483 |
Security.getProperty(OCSP_CERT_NUMBER_PROP); |
|
484 |
return null; |
|
485 |
} |
|
486 |
}); |
|
487 |
||
488 |
return properties; |
|
489 |
} |
|
490 |
||
491 |
/* |
|
492 |
* Removes any non-hexadecimal characters from a string. |
|
493 |
*/ |
|
494 |
private static String stripOutSeparators(String value) { |
|
495 |
char[] chars = value.toCharArray(); |
|
496 |
StringBuilder hexNumber = new StringBuilder(); |
|
497 |
for (int i = 0; i < chars.length; i++) { |
|
498 |
if (HEX_DIGITS.indexOf(chars[i]) != -1) { |
|
499 |
hexNumber.append(chars[i]); |
|
500 |
} |
|
501 |
} |
|
502 |
return hexNumber.toString(); |
|
503 |
} |
|
504 |
} |