author | iris |
Wed, 20 Jan 2016 11:02:36 -0800 | |
changeset 35302 | e4d2275861c3 |
parent 33991 | 619bfc4d582d |
child 40416 | 5d91b2fd668c |
permissions | -rw-r--r-- |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
1 |
/* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
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; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
32 |
|
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 |
* Provider class for the JdkLDAP provider. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
35 |
* Supports LDAP cert store. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
36 |
* |
35302
e4d2275861c3
8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents:
33991
diff
changeset
|
37 |
* @since 9 |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
38 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
39 |
public final class JdkLDAP extends Provider { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
40 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
41 |
private static final long serialVersionUID = -2279741232933606418L; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
42 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
43 |
private static final class ProviderService extends Provider.Service { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
44 |
ProviderService(Provider p, String type, String algo, String cn, |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
45 |
List<String> aliases, HashMap<String, String> attrs) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
46 |
super(p, type, algo, cn, aliases, attrs); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
47 |
} |
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 |
@Override |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
50 |
public Object newInstance(Object ctrParamObj) |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
51 |
throws NoSuchAlgorithmException { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
52 |
String type = getType(); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
53 |
String algo = getAlgorithm(); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
54 |
if (type.equals("CertStore") && algo.equals("LDAP")) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
55 |
if (ctrParamObj != null && |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
56 |
!(ctrParamObj instanceof CertStoreParameters)) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
57 |
throw new InvalidParameterException |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
58 |
("constructorParameter must be instanceof CertStoreParameters"); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
59 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
60 |
try { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
61 |
return new LDAPCertStore((CertStoreParameters) ctrParamObj); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
62 |
} catch (Exception ex) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
63 |
throw new NoSuchAlgorithmException("Error constructing " + |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
64 |
type + " for " + algo + " using JdkLDAP", ex); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
65 |
} |
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 |
throw new ProviderException("No impl for " + algo + " " + type); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
68 |
} |
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 |
public JdkLDAP() { |
33991
619bfc4d582d
8130696: Security Providers need to have their version numbers updated for JDK 9
iris
parents:
31270
diff
changeset
|
72 |
super("JdkLDAP", 9.0d, "JdkLDAP Provider (implements LDAP CertStore)"); |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
73 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
74 |
final Provider p = this; |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
75 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
76 |
public Void run() { |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
77 |
HashMap<String, String> attrs = new HashMap<>(2); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
78 |
attrs.put("LDAPSchema", "RFC2587"); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
79 |
attrs.put("ImplementedIn", "Software"); |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
80 |
|
31270
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
81 |
/* |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
82 |
* CertStore |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
83 |
* attrs: LDAPSchema, ImplementedIn |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
84 |
*/ |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
85 |
putService(new ProviderService(p, "CertStore", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
86 |
"LDAP", "sun.security.provider.certpath.ldap.LDAPCertStore", |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
87 |
null, attrs)); |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
88 |
return null; |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
89 |
} |
e6470b24700d
7191662: JCE providers should be located via ServiceLoader
valeriep
parents:
30506
diff
changeset
|
90 |
}); |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
91 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
92 |
} |