1 /* |
|
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
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. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle 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 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. |
|
24 */ |
|
25 |
|
26 package sun.security.provider.certpath.ldap; |
|
27 |
|
28 import java.io.IOException; |
|
29 import java.net.URI; |
|
30 import java.util.Collection; |
|
31 import java.security.NoSuchAlgorithmException; |
|
32 import java.security.InvalidAlgorithmParameterException; |
|
33 import java.security.cert.CertStore; |
|
34 import java.security.cert.CertStoreException; |
|
35 import java.security.cert.X509CertSelector; |
|
36 import java.security.cert.X509CRLSelector; |
|
37 import javax.naming.CommunicationException; |
|
38 import javax.naming.ServiceUnavailableException; |
|
39 import javax.security.auth.x500.X500Principal; |
|
40 |
|
41 import sun.security.provider.certpath.CertStoreHelper; |
|
42 |
|
43 /** |
|
44 * LDAP implementation of CertStoreHelper. |
|
45 */ |
|
46 |
|
47 public final class LDAPCertStoreHelper |
|
48 extends CertStoreHelper |
|
49 { |
|
50 @Override |
|
51 public CertStore getCertStore(URI uri) |
|
52 throws NoSuchAlgorithmException, InvalidAlgorithmParameterException |
|
53 { |
|
54 return LDAPCertStore.getInstance(LDAPCertStore.getParameters(uri)); |
|
55 } |
|
56 |
|
57 @Override |
|
58 public X509CertSelector wrap(X509CertSelector selector, |
|
59 X500Principal certSubject, |
|
60 String ldapDN) |
|
61 throws IOException |
|
62 { |
|
63 return new LDAPCertStore.LDAPCertSelector(selector, certSubject, ldapDN); |
|
64 } |
|
65 |
|
66 @Override |
|
67 public X509CRLSelector wrap(X509CRLSelector selector, |
|
68 Collection<X500Principal> certIssuers, |
|
69 String ldapDN) |
|
70 throws IOException |
|
71 { |
|
72 return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN); |
|
73 } |
|
74 |
|
75 @Override |
|
76 public boolean isCausedByNetworkIssue(CertStoreException e) { |
|
77 Throwable t = e.getCause(); |
|
78 return (t != null && (t instanceof ServiceUnavailableException || |
|
79 t instanceof CommunicationException)); |
|
80 } |
|
81 } |
|