author | mchung |
Wed, 31 Jan 2018 15:15:09 -0800 | |
changeset 48692 | 60c19c384333 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
1 |
/* |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
35302
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
4 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
10 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
15 |
* accompanied this code). |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
16 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
20 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
23 |
* questions. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
24 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
25 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
26 |
package sun.security.provider.certpath.ldap; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
27 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
28 |
import java.util.HashMap; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
29 |
import java.util.List; |
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
30 |
import java.security.*; |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
31 |
import java.security.cert.CertStoreParameters; |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
35302
diff
changeset
|
32 |
import static sun.security.util.SecurityConstants.PROVIDER_VER; |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
33 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
34 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
35 |
* Provider class for the JdkLDAP provider. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
36 |
* Supports LDAP cert store. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
37 |
* |
35302
e4d2275861c3
8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents:
33991
diff
changeset
|
38 |
* @since 9 |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
39 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
40 |
public final class JdkLDAP extends Provider { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
41 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
42 |
private static final long serialVersionUID = -2279741232933606418L; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
43 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
44 |
private static final class ProviderService extends Provider.Service { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
45 |
ProviderService(Provider p, String type, String algo, String cn, |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
46 |
List<String> aliases, HashMap<String, String> attrs) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
47 |
super(p, type, algo, cn, aliases, attrs); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
48 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
49 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
50 |
@Override |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
51 |
public Object newInstance(Object ctrParamObj) |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
52 |
throws NoSuchAlgorithmException { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
53 |
String type = getType(); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
54 |
String algo = getAlgorithm(); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
55 |
if (type.equals("CertStore") && algo.equals("LDAP")) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
56 |
if (ctrParamObj != null && |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
57 |
!(ctrParamObj instanceof CertStoreParameters)) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
58 |
throw new InvalidParameterException |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
59 |
("constructorParameter must be instanceof CertStoreParameters"); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
60 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
61 |
try { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
62 |
return new LDAPCertStore((CertStoreParameters) ctrParamObj); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
63 |
} catch (Exception ex) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
64 |
throw new NoSuchAlgorithmException("Error constructing " + |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
65 |
type + " for " + algo + " using JdkLDAP", ex); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
66 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
67 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
68 |
throw new ProviderException("No impl for " + algo + " " + type); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
69 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
70 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
71 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
72 |
public JdkLDAP() { |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
35302
diff
changeset
|
73 |
super("JdkLDAP", PROVIDER_VER, "JdkLDAP Provider (implements LDAP CertStore)"); |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
74 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
75 |
final Provider p = this; |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
76 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
77 |
public Void run() { |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
78 |
HashMap<String, String> attrs = new HashMap<>(2); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
79 |
attrs.put("LDAPSchema", "RFC2587"); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
80 |
attrs.put("ImplementedIn", "Software"); |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
81 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
82 |
/* |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
83 |
* CertStore |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
84 |
* attrs: LDAPSchema, ImplementedIn |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
85 |
*/ |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
86 |
putService(new ProviderService(p, "CertStore", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
87 |
"LDAP", "sun.security.provider.certpath.ldap.LDAPCertStore", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
88 |
null, attrs)); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
89 |
return null; |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
90 |
} |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
91 |
}); |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
92 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
93 |
} |