author | xuelei |
Tue, 02 Jun 2015 04:01:04 +0000 | |
changeset 30904 | ec0224270f90 |
parent 29492 | a4bf9a570035 |
child 34380 | 2b2609379881 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
29492
a4bf9a570035
8028266: Tidy warnings cleanup for packages java.security/javax.security
avstepan
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2005, 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 javax.net.ssl; |
|
27 |
||
7043 | 28 |
import java.security.AlgorithmConstraints; |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
29 |
import java.util.Map; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
30 |
import java.util.List; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
31 |
import java.util.HashMap; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
32 |
import java.util.ArrayList; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
33 |
import java.util.Collection; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
34 |
import java.util.Collections; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
35 |
import java.util.LinkedHashMap; |
7043 | 36 |
|
2 | 37 |
/** |
30904 | 38 |
* Encapsulates parameters for an SSL/TLS/DTLS connection. The parameters |
39 |
* are the list of ciphersuites to be accepted in an SSL/TLS/DTLS handshake, |
|
7043 | 40 |
* the list of protocols to be allowed, the endpoint identification |
30904 | 41 |
* algorithm during SSL/TLS/DTLS handshaking, the Server Name Indication (SNI), |
42 |
* the maximum network packet size, the algorithm constraints and whether |
|
43 |
* SSL/TLS/DTLS servers should request or require client authentication, etc. |
|
7043 | 44 |
* <p> |
45 |
* SSLParameters can be created via the constructors in this class. |
|
30904 | 46 |
* Objects can also be obtained using the {@code getSSLParameters()} |
2 | 47 |
* methods in |
48 |
* {@link SSLSocket#getSSLParameters SSLSocket} and |
|
7043 | 49 |
* {@link SSLServerSocket#getSSLParameters SSLServerSocket} and |
2 | 50 |
* {@link SSLEngine#getSSLParameters SSLEngine} or the |
51 |
* {@link SSLContext#getDefaultSSLParameters getDefaultSSLParameters()} and |
|
52 |
* {@link SSLContext#getSupportedSSLParameters getSupportedSSLParameters()} |
|
30904 | 53 |
* methods in {@code SSLContext}. |
7043 | 54 |
* <p> |
55 |
* SSLParameters can be applied to a connection via the methods |
|
2 | 56 |
* {@link SSLSocket#setSSLParameters SSLSocket.setSSLParameters()} and |
7043 | 57 |
* {@link SSLServerSocket#setSSLParameters SSLServerSocket.setSSLParameters()} |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
58 |
* and {@link SSLEngine#setSSLParameters SSLEngine.setSSLParameters()}. |
2 | 59 |
* |
60 |
* @see SSLSocket |
|
61 |
* @see SSLEngine |
|
62 |
* @see SSLContext |
|
63 |
* |
|
64 |
* @since 1.6 |
|
65 |
*/ |
|
66 |
public class SSLParameters { |
|
67 |
||
68 |
private String[] cipherSuites; |
|
69 |
private String[] protocols; |
|
70 |
private boolean wantClientAuth; |
|
71 |
private boolean needClientAuth; |
|
7043 | 72 |
private String identificationAlgorithm; |
73 |
private AlgorithmConstraints algorithmConstraints; |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
74 |
private Map<Integer, SNIServerName> sniNames = null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
75 |
private Map<Integer, SNIMatcher> sniMatchers = null; |
19823
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
76 |
private boolean preferLocalCipherSuites; |
30904 | 77 |
private boolean enableRetransmissions = true; |
78 |
private int maximumPacketSize = 0; |
|
2 | 79 |
|
80 |
/** |
|
81 |
* Constructs SSLParameters. |
|
7043 | 82 |
* <p> |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
83 |
* The values of cipherSuites, protocols, cryptographic algorithm |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
84 |
* constraints, endpoint identification algorithm, server names and |
30904 | 85 |
* server name matchers are set to {@code null}; useCipherSuitesOrder, |
86 |
* wantClientAuth and needClientAuth are set to {@code false}; |
|
87 |
* enableRetransmissions is set to {@code true}; maximum network packet |
|
88 |
* size is set to {@code 0}. |
|
2 | 89 |
*/ |
90 |
public SSLParameters() { |
|
91 |
// empty |
|
92 |
} |
|
93 |
||
94 |
/** |
|
95 |
* Constructs SSLParameters from the specified array of ciphersuites. |
|
7043 | 96 |
* <p> |
2 | 97 |
* Calling this constructor is equivalent to calling the no-args |
98 |
* constructor followed by |
|
30904 | 99 |
* {@code setCipherSuites(cipherSuites);}. |
2 | 100 |
* |
101 |
* @param cipherSuites the array of ciphersuites (or null) |
|
102 |
*/ |
|
103 |
public SSLParameters(String[] cipherSuites) { |
|
104 |
setCipherSuites(cipherSuites); |
|
105 |
} |
|
106 |
||
107 |
/** |
|
108 |
* Constructs SSLParameters from the specified array of ciphersuites |
|
109 |
* and protocols. |
|
7043 | 110 |
* <p> |
2 | 111 |
* Calling this constructor is equivalent to calling the no-args |
112 |
* constructor followed by |
|
30904 | 113 |
* {@code setCipherSuites(cipherSuites); setProtocols(protocols);}. |
2 | 114 |
* |
115 |
* @param cipherSuites the array of ciphersuites (or null) |
|
116 |
* @param protocols the array of protocols (or null) |
|
117 |
*/ |
|
118 |
public SSLParameters(String[] cipherSuites, String[] protocols) { |
|
119 |
setCipherSuites(cipherSuites); |
|
120 |
setProtocols(protocols); |
|
121 |
} |
|
122 |
||
123 |
private static String[] clone(String[] s) { |
|
124 |
return (s == null) ? null : s.clone(); |
|
125 |
} |
|
126 |
||
127 |
/** |
|
128 |
* Returns a copy of the array of ciphersuites or null if none |
|
129 |
* have been set. |
|
130 |
* |
|
131 |
* @return a copy of the array of ciphersuites or null if none |
|
132 |
* have been set. |
|
133 |
*/ |
|
134 |
public String[] getCipherSuites() { |
|
135 |
return clone(cipherSuites); |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* Sets the array of ciphersuites. |
|
140 |
* |
|
141 |
* @param cipherSuites the array of ciphersuites (or null) |
|
142 |
*/ |
|
143 |
public void setCipherSuites(String[] cipherSuites) { |
|
144 |
this.cipherSuites = clone(cipherSuites); |
|
145 |
} |
|
146 |
||
147 |
/** |
|
148 |
* Returns a copy of the array of protocols or null if none |
|
149 |
* have been set. |
|
150 |
* |
|
151 |
* @return a copy of the array of protocols or null if none |
|
152 |
* have been set. |
|
153 |
*/ |
|
154 |
public String[] getProtocols() { |
|
155 |
return clone(protocols); |
|
156 |
} |
|
157 |
||
158 |
/** |
|
159 |
* Sets the array of protocols. |
|
160 |
* |
|
161 |
* @param protocols the array of protocols (or null) |
|
162 |
*/ |
|
163 |
public void setProtocols(String[] protocols) { |
|
164 |
this.protocols = clone(protocols); |
|
165 |
} |
|
166 |
||
167 |
/** |
|
168 |
* Returns whether client authentication should be requested. |
|
169 |
* |
|
170 |
* @return whether client authentication should be requested. |
|
171 |
*/ |
|
172 |
public boolean getWantClientAuth() { |
|
173 |
return wantClientAuth; |
|
174 |
} |
|
175 |
||
176 |
/** |
|
177 |
* Sets whether client authentication should be requested. Calling |
|
30904 | 178 |
* this method clears the {@code needClientAuth} flag. |
2 | 179 |
* |
180 |
* @param wantClientAuth whether client authentication should be requested |
|
181 |
*/ |
|
182 |
public void setWantClientAuth(boolean wantClientAuth) { |
|
183 |
this.wantClientAuth = wantClientAuth; |
|
184 |
this.needClientAuth = false; |
|
185 |
} |
|
186 |
||
187 |
/** |
|
188 |
* Returns whether client authentication should be required. |
|
189 |
* |
|
190 |
* @return whether client authentication should be required. |
|
191 |
*/ |
|
192 |
public boolean getNeedClientAuth() { |
|
193 |
return needClientAuth; |
|
194 |
} |
|
195 |
||
196 |
/** |
|
197 |
* Sets whether client authentication should be required. Calling |
|
30904 | 198 |
* this method clears the {@code wantClientAuth} flag. |
2 | 199 |
* |
200 |
* @param needClientAuth whether client authentication should be required |
|
201 |
*/ |
|
202 |
public void setNeedClientAuth(boolean needClientAuth) { |
|
203 |
this.wantClientAuth = false; |
|
204 |
this.needClientAuth = needClientAuth; |
|
205 |
} |
|
206 |
||
7043 | 207 |
/** |
208 |
* Returns the cryptographic algorithm constraints. |
|
209 |
* |
|
210 |
* @return the cryptographic algorithm constraints, or null if the |
|
211 |
* constraints have not been set |
|
212 |
* |
|
213 |
* @see #setAlgorithmConstraints(AlgorithmConstraints) |
|
214 |
* |
|
215 |
* @since 1.7 |
|
216 |
*/ |
|
217 |
public AlgorithmConstraints getAlgorithmConstraints() { |
|
218 |
return algorithmConstraints; |
|
219 |
} |
|
220 |
||
221 |
/** |
|
222 |
* Sets the cryptographic algorithm constraints, which will be used |
|
223 |
* in addition to any configured by the runtime environment. |
|
224 |
* <p> |
|
30904 | 225 |
* If the {@code constraints} parameter is non-null, every |
7043 | 226 |
* cryptographic algorithm, key and algorithm parameters used in the |
30904 | 227 |
* SSL/TLS/DTLS handshake must be permitted by the constraints. |
7043 | 228 |
* |
229 |
* @param constraints the algorithm constraints (or null) |
|
230 |
* |
|
231 |
* @since 1.7 |
|
232 |
*/ |
|
233 |
public void setAlgorithmConstraints(AlgorithmConstraints constraints) { |
|
234 |
// the constraints object is immutable |
|
235 |
this.algorithmConstraints = constraints; |
|
236 |
} |
|
237 |
||
238 |
/** |
|
239 |
* Gets the endpoint identification algorithm. |
|
240 |
* |
|
241 |
* @return the endpoint identification algorithm, or null if none |
|
242 |
* has been set. |
|
243 |
* |
|
244 |
* @see X509ExtendedTrustManager |
|
245 |
* @see #setEndpointIdentificationAlgorithm(String) |
|
246 |
* |
|
247 |
* @since 1.7 |
|
248 |
*/ |
|
249 |
public String getEndpointIdentificationAlgorithm() { |
|
250 |
return identificationAlgorithm; |
|
251 |
} |
|
252 |
||
253 |
/** |
|
254 |
* Sets the endpoint identification algorithm. |
|
255 |
* <p> |
|
30904 | 256 |
* If the {@code algorithm} parameter is non-null or non-empty, the |
7043 | 257 |
* endpoint identification/verification procedures must be handled during |
30904 | 258 |
* SSL/TLS/DTLS handshaking. This is to prevent man-in-the-middle attacks. |
7043 | 259 |
* |
260 |
* @param algorithm The standard string name of the endpoint |
|
261 |
* identification algorithm (or null). See Appendix A in the <a href= |
|
11838 | 262 |
* "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA"> |
7043 | 263 |
* Java Cryptography Architecture API Specification & Reference </a> |
264 |
* for information about standard algorithm names. |
|
265 |
* |
|
266 |
* @see X509ExtendedTrustManager |
|
267 |
* |
|
268 |
* @since 1.7 |
|
269 |
*/ |
|
270 |
public void setEndpointIdentificationAlgorithm(String algorithm) { |
|
271 |
this.identificationAlgorithm = algorithm; |
|
272 |
} |
|
273 |
||
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
274 |
/** |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
275 |
* Sets the desired {@link SNIServerName}s of the Server Name |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
276 |
* Indication (SNI) parameter. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
277 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
278 |
* This method is only useful to {@link SSLSocket}s or {@link SSLEngine}s |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
279 |
* operating in client mode. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
280 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
281 |
* Note that the {@code serverNames} list is cloned |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
282 |
* to protect against subsequent modification. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
283 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
284 |
* @param serverNames |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
285 |
* the list of desired {@link SNIServerName}s (or null) |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
286 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
287 |
* @throws NullPointerException if the {@code serverNames} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
288 |
* contains {@code null} element |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
289 |
* @throws IllegalArgumentException if the {@code serverNames} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
290 |
* contains more than one name of the same name type |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
291 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
292 |
* @see SNIServerName |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
293 |
* @see #getServerNames() |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
294 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
295 |
* @since 1.8 |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
296 |
*/ |
14196
1ebcd181a423
8000954: Add final keyword to new method in SSLParameters
xuelei
parents:
14194
diff
changeset
|
297 |
public final void setServerNames(List<SNIServerName> serverNames) { |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
298 |
if (serverNames != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
299 |
if (!serverNames.isEmpty()) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
300 |
sniNames = new LinkedHashMap<>(serverNames.size()); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
301 |
for (SNIServerName serverName : serverNames) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
302 |
if (sniNames.put(serverName.getType(), |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
303 |
serverName) != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
304 |
throw new IllegalArgumentException( |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
305 |
"Duplicated server name of type " + |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
306 |
serverName.getType()); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
307 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
308 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
309 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
310 |
sniNames = Collections.<Integer, SNIServerName>emptyMap(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
311 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
312 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
313 |
sniNames = null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
314 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
315 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
316 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
317 |
/** |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
318 |
* Returns a {@link List} containing all {@link SNIServerName}s of the |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
319 |
* Server Name Indication (SNI) parameter, or null if none has been set. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
320 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
321 |
* This method is only useful to {@link SSLSocket}s or {@link SSLEngine}s |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
322 |
* operating in client mode. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
323 |
* <P> |
30904 | 324 |
* For SSL/TLS/DTLS connections, the underlying SSL/TLS/DTLS provider |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
325 |
* may specify a default value for a certain server name type. In |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
326 |
* client mode, it is recommended that, by default, providers should |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
327 |
* include the server name indication whenever the server can be located |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
328 |
* by a supported server name type. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
329 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
330 |
* It is recommended that providers initialize default Server Name |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
331 |
* Indications when creating {@code SSLSocket}/{@code SSLEngine}s. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
332 |
* In the following examples, the server name could be represented by an |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
333 |
* instance of {@link SNIHostName} which has been initialized with the |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
334 |
* hostname "www.example.com" and type |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
335 |
* {@link StandardConstants#SNI_HOST_NAME}. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
336 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
337 |
* <pre> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
338 |
* Socket socket = |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
339 |
* sslSocketFactory.createSocket("www.example.com", 443); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
340 |
* </pre> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
341 |
* or |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
342 |
* <pre> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
343 |
* SSLEngine engine = |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
344 |
* sslContext.createSSLEngine("www.example.com", 443); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
345 |
* </pre> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
346 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
347 |
* @return null or an immutable list of non-null {@link SNIServerName}s |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
348 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
349 |
* @see List |
14663 | 350 |
* @see #setServerNames(List) |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
351 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
352 |
* @since 1.8 |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
353 |
*/ |
14196
1ebcd181a423
8000954: Add final keyword to new method in SSLParameters
xuelei
parents:
14194
diff
changeset
|
354 |
public final List<SNIServerName> getServerNames() { |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
355 |
if (sniNames != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
356 |
if (!sniNames.isEmpty()) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
357 |
return Collections.<SNIServerName>unmodifiableList( |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
358 |
new ArrayList<>(sniNames.values())); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
359 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
360 |
return Collections.<SNIServerName>emptyList(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
361 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
362 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
363 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
364 |
return null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
365 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
366 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
367 |
/** |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
368 |
* Sets the {@link SNIMatcher}s of the Server Name Indication (SNI) |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
369 |
* parameter. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
370 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
371 |
* This method is only useful to {@link SSLSocket}s or {@link SSLEngine}s |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
372 |
* operating in server mode. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
373 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
374 |
* Note that the {@code matchers} collection is cloned to protect |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
375 |
* against subsequent modification. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
376 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
377 |
* @param matchers |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
378 |
* the collection of {@link SNIMatcher}s (or null) |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
379 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
380 |
* @throws NullPointerException if the {@code matchers} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
381 |
* contains {@code null} element |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
382 |
* @throws IllegalArgumentException if the {@code matchers} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
383 |
* contains more than one name of the same name type |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
384 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
385 |
* @see Collection |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
386 |
* @see SNIMatcher |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
387 |
* @see #getSNIMatchers() |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
388 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
389 |
* @since 1.8 |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
390 |
*/ |
14196
1ebcd181a423
8000954: Add final keyword to new method in SSLParameters
xuelei
parents:
14194
diff
changeset
|
391 |
public final void setSNIMatchers(Collection<SNIMatcher> matchers) { |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
392 |
if (matchers != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
393 |
if (!matchers.isEmpty()) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
394 |
sniMatchers = new HashMap<>(matchers.size()); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
395 |
for (SNIMatcher matcher : matchers) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
396 |
if (sniMatchers.put(matcher.getType(), |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
397 |
matcher) != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
398 |
throw new IllegalArgumentException( |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
399 |
"Duplicated server name of type " + |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
400 |
matcher.getType()); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
401 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
402 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
403 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
404 |
sniMatchers = Collections.<Integer, SNIMatcher>emptyMap(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
405 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
406 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
407 |
sniMatchers = null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
408 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
409 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
410 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
411 |
/** |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
412 |
* Returns a {@link Collection} containing all {@link SNIMatcher}s of the |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
413 |
* Server Name Indication (SNI) parameter, or null if none has been set. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
414 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
415 |
* This method is only useful to {@link SSLSocket}s or {@link SSLEngine}s |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
416 |
* operating in server mode. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
417 |
* <P> |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
418 |
* For better interoperability, providers generally will not define |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
419 |
* default matchers so that by default servers will ignore the SNI |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
420 |
* extension and continue the handshake. |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
421 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
422 |
* @return null or an immutable collection of non-null {@link SNIMatcher}s |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
423 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
424 |
* @see SNIMatcher |
14663 | 425 |
* @see #setSNIMatchers(Collection) |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
426 |
* |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
427 |
* @since 1.8 |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
428 |
*/ |
14196
1ebcd181a423
8000954: Add final keyword to new method in SSLParameters
xuelei
parents:
14194
diff
changeset
|
429 |
public final Collection<SNIMatcher> getSNIMatchers() { |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
430 |
if (sniMatchers != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
431 |
if (!sniMatchers.isEmpty()) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
432 |
return Collections.<SNIMatcher>unmodifiableList( |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
433 |
new ArrayList<>(sniMatchers.values())); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
434 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
435 |
return Collections.<SNIMatcher>emptyList(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
436 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
437 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
438 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
439 |
return null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
440 |
} |
19823
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
441 |
|
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
442 |
/** |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
443 |
* Sets whether the local cipher suites preference should be honored. |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
444 |
* |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
445 |
* @param honorOrder whether local cipher suites order in |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
446 |
* {@code #getCipherSuites} should be honored during |
30904 | 447 |
* SSL/TLS/DTLS handshaking. |
19823
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
448 |
* |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
449 |
* @see #getUseCipherSuitesOrder() |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
450 |
* |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
451 |
* @since 1.8 |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
452 |
*/ |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
453 |
public final void setUseCipherSuitesOrder(boolean honorOrder) { |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
454 |
this.preferLocalCipherSuites = honorOrder; |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
455 |
} |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
456 |
|
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
457 |
/** |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
458 |
* Returns whether the local cipher suites preference should be honored. |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
459 |
* |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
460 |
* @return whether local cipher suites order in {@code #getCipherSuites} |
30904 | 461 |
* should be honored during SSL/TLS/DTLS handshaking. |
19823
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
462 |
* |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
463 |
* @see #setUseCipherSuitesOrder(boolean) |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
464 |
* |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
465 |
* @since 1.8 |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
466 |
*/ |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
467 |
public final boolean getUseCipherSuitesOrder() { |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
468 |
return preferLocalCipherSuites; |
f0fd09e20528
7188657: There should be a way to reorder the JSSE ciphers
xuelei
parents:
14663
diff
changeset
|
469 |
} |
30904 | 470 |
|
471 |
/** |
|
472 |
* Sets whether DTLS handshake retransmissions should be enabled. |
|
473 |
* |
|
474 |
* This method only applies to DTLS. |
|
475 |
* |
|
476 |
* @param enableRetransmissions |
|
477 |
* {@code true} indicates that DTLS handshake retransmissions |
|
478 |
* should be enabled; {@code false} indicates that DTLS handshake |
|
479 |
* retransmissions should be disabled |
|
480 |
* |
|
481 |
* @see #getEnableRetransmissions() |
|
482 |
* |
|
483 |
* @since 1.9 |
|
484 |
*/ |
|
485 |
public void setEnableRetransmissions(boolean enableRetransmissions) { |
|
486 |
this.enableRetransmissions = enableRetransmissions; |
|
487 |
} |
|
488 |
||
489 |
/** |
|
490 |
* Returns whether DTLS handshake retransmissions should be enabled. |
|
491 |
* |
|
492 |
* This method only applies to DTLS. |
|
493 |
* |
|
494 |
* @return true, if DTLS handshake retransmissions should be enabled |
|
495 |
* |
|
496 |
* @see #setEnableRetransmissions(boolean) |
|
497 |
* |
|
498 |
* @since 1.9 |
|
499 |
*/ |
|
500 |
public boolean getEnableRetransmissions() { |
|
501 |
return enableRetransmissions; |
|
502 |
} |
|
503 |
||
504 |
/** |
|
505 |
* Sets the maximum expected network packet size in bytes for |
|
506 |
* SSL/TLS/DTLS records. |
|
507 |
* |
|
508 |
* @apiNote It is recommended that if possible, the maximum packet size |
|
509 |
* should not be less than 256 bytes so that small handshake |
|
510 |
* messages, such as HelloVerifyRequests, are not fragmented. |
|
511 |
* |
|
512 |
* @implNote If the maximum packet size is too small to hold a minimal |
|
513 |
* record, an implementation may attempt to generate as minimal |
|
514 |
* records as possible. However, this may cause a generated |
|
515 |
* packet to be larger than the maximum packet size. |
|
516 |
* |
|
517 |
* @param maximumPacketSize |
|
518 |
* the maximum expected network packet size in bytes, or |
|
519 |
* {@code 0} to use the implicit size that is automatically |
|
520 |
* specified by the underlying implementation. |
|
521 |
* @throws IllegalArgumentException |
|
522 |
* if {@code maximumPacketSize} is negative. |
|
523 |
* |
|
524 |
* @see #getMaximumPacketSize() |
|
525 |
* |
|
526 |
* @since 1.9 |
|
527 |
*/ |
|
528 |
public void setMaximumPacketSize(int maximumPacketSize) { |
|
529 |
if (maximumPacketSize < 0) { |
|
530 |
throw new IllegalArgumentException( |
|
531 |
"The maximum packet size cannot be negative"); |
|
532 |
} |
|
533 |
||
534 |
this.maximumPacketSize = maximumPacketSize; |
|
535 |
} |
|
536 |
||
537 |
/** |
|
538 |
* Returns the maximum expected network packet size in bytes for |
|
539 |
* SSL/TLS/DTLS records. |
|
540 |
* |
|
541 |
* @apiNote The implicit size may not be a fixed value, especially |
|
542 |
* for a DTLS protocols implementation. |
|
543 |
* |
|
544 |
* @implNote For SSL/TLS/DTLS connections, the underlying provider |
|
545 |
* should calculate and specify the implicit value of the |
|
546 |
* maximum expected network packet size if it is not |
|
547 |
* configured explicitly. For any connection populated |
|
548 |
* object, this method should never return {@code 0} so |
|
549 |
* that applications can retrieve the actual implicit size |
|
550 |
* of the underlying implementation. |
|
551 |
* <P> |
|
552 |
* An implementation should attempt to comply with the maximum |
|
553 |
* packet size configuration. However, if the maximum packet |
|
554 |
* size is too small to hold a minimal record, an implementation |
|
555 |
* may try to generate as minimal records as possible. This |
|
556 |
* may cause a generated packet to be larger than the maximum |
|
557 |
* packet size. |
|
558 |
* |
|
559 |
* @return the maximum expected network packet size, or {@code 0} if |
|
560 |
* use the implicit size that is automatically specified by |
|
561 |
* the underlying implementation and this object has not been |
|
562 |
* populated by any connection. |
|
563 |
* |
|
564 |
* @see #setMaximumPacketSize(int) |
|
565 |
* |
|
566 |
* @since 1.9 |
|
567 |
*/ |
|
568 |
public int getMaximumPacketSize() { |
|
569 |
return maximumPacketSize; |
|
570 |
} |
|
571 |
||
2 | 572 |
} |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
11838
diff
changeset
|
573 |