author | coleenp |
Wed, 30 Aug 2017 19:18:22 -0400 | |
changeset 47098 | e704f55561c3 |
parent 30506 | 1998a5644f50 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2000, 2015, 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 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
29 |
* Parameters used as input for the LDAP {@code CertStore} algorithm. |
2 | 30 |
* <p> |
31 |
* This class is used to provide necessary configuration parameters (server |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
32 |
* name and port number) to implementations of the LDAP {@code CertStore} |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
33 |
* algorithm. However, if you are retrieving certificates or CRLs from |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
34 |
* an ldap URI as specified by RFC 5280, use the |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
35 |
* {@link java.security.cert.URICertStoreParameters URICertStoreParameters} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
36 |
* instead as the URI may contain additional information such as the |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
37 |
* distinguished name that will help the LDAP CertStore find the specific |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
25859
diff
changeset
|
38 |
* certificates and CRLs. |
2 | 39 |
* <p> |
40 |
* <b>Concurrent Access</b> |
|
41 |
* <p> |
|
42 |
* Unless otherwise specified, the methods defined in this class are not |
|
43 |
* thread-safe. Multiple threads that need to access a single |
|
44 |
* object concurrently should synchronize amongst themselves and |
|
45 |
* provide the necessary locking. Multiple threads each manipulating |
|
46 |
* separate objects need not synchronize. |
|
47 |
* |
|
48 |
* @since 1.4 |
|
49 |
* @author Steve Hanna |
|
50 |
* @see CertStore |
|
51 |
*/ |
|
52 |
public class LDAPCertStoreParameters implements CertStoreParameters { |
|
53 |
||
54 |
private static final int LDAP_DEFAULT_PORT = 389; |
|
55 |
||
56 |
/** |
|
57 |
* the port number of the LDAP server |
|
58 |
*/ |
|
59 |
private int port; |
|
60 |
||
61 |
/** |
|
62 |
* the DNS name of the LDAP server |
|
63 |
*/ |
|
64 |
private String serverName; |
|
65 |
||
66 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
67 |
* Creates an instance of {@code LDAPCertStoreParameters} with the |
2 | 68 |
* specified parameter values. |
69 |
* |
|
70 |
* @param serverName the DNS name of the LDAP server |
|
71 |
* @param port the port number of the LDAP server |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
72 |
* @exception NullPointerException if {@code serverName} is |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
73 |
* {@code null} |
2 | 74 |
*/ |
75 |
public LDAPCertStoreParameters(String serverName, int port) { |
|
76 |
if (serverName == null) |
|
77 |
throw new NullPointerException(); |
|
78 |
this.serverName = serverName; |
|
79 |
this.port = port; |
|
80 |
} |
|
81 |
||
82 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
83 |
* Creates an instance of {@code LDAPCertStoreParameters} with the |
2 | 84 |
* specified server name and a default port of 389. |
85 |
* |
|
86 |
* @param serverName the DNS name of the LDAP server |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
87 |
* @exception NullPointerException if {@code serverName} is |
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
88 |
* {@code null} |
2 | 89 |
*/ |
90 |
public LDAPCertStoreParameters(String serverName) { |
|
91 |
this(serverName, LDAP_DEFAULT_PORT); |
|
92 |
} |
|
93 |
||
94 |
/** |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
95 |
* Creates an instance of {@code LDAPCertStoreParameters} with the |
2 | 96 |
* default parameter values (server name "localhost", port 389). |
97 |
*/ |
|
98 |
public LDAPCertStoreParameters() { |
|
99 |
this("localhost", LDAP_DEFAULT_PORT); |
|
100 |
} |
|
101 |
||
102 |
/** |
|
103 |
* Returns the DNS name of the LDAP server. |
|
104 |
* |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
105 |
* @return the name (not {@code null}) |
2 | 106 |
*/ |
107 |
public String getServerName() { |
|
108 |
return serverName; |
|
109 |
} |
|
110 |
||
111 |
/** |
|
112 |
* Returns the port number of the LDAP server. |
|
113 |
* |
|
114 |
* @return the port number |
|
115 |
*/ |
|
116 |
public int getPort() { |
|
117 |
return port; |
|
118 |
} |
|
119 |
||
120 |
/** |
|
121 |
* Returns a copy of this object. Changes to the copy will not affect |
|
122 |
* the original and vice versa. |
|
123 |
* <p> |
|
124 |
* Note: this method currently performs a shallow copy of the object |
|
18551
882a3948c6e6
8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents:
14342
diff
changeset
|
125 |
* (simply calls {@code Object.clone()}). This may be changed in a |
2 | 126 |
* future revision to perform a deep copy if new parameters are added |
127 |
* that should not be shared. |
|
128 |
* |
|
129 |
* @return the copy |
|
130 |
*/ |
|
131 |
public Object clone() { |
|
132 |
try { |
|
133 |
return super.clone(); |
|
134 |
} catch (CloneNotSupportedException e) { |
|
135 |
/* Cannot happen */ |
|
10419
12c063b39232
7084245: Update usages of InternalError to use exception chaining
sherman
parents:
5506
diff
changeset
|
136 |
throw new InternalError(e.toString(), e); |
2 | 137 |
} |
138 |
} |
|
139 |
||
140 |
/** |
|
141 |
* Returns a formatted string describing the parameters. |
|
142 |
* |
|
143 |
* @return a formatted string describing the parameters |
|
144 |
*/ |
|
145 |
public String toString() { |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
18551
diff
changeset
|
146 |
StringBuilder sb = new StringBuilder(); |
2 | 147 |
sb.append("LDAPCertStoreParameters: [\n"); |
148 |
||
149 |
sb.append(" serverName: " + serverName + "\n"); |
|
150 |
sb.append(" port: " + port + "\n"); |
|
151 |
sb.append("]"); |
|
152 |
return sb.toString(); |
|
153 |
} |
|
154 |
} |