author | lana |
Tue, 23 Oct 2012 11:29:53 -0700 | |
changeset 14229 | 40fbffe104bd |
parent 14194 | 971f46db533d |
child 14664 | e71aa0962e70 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2002, 2012, 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 sun.security.ssl; |
|
27 |
||
28 |
import java.io.*; |
|
29 |
import java.nio.channels.SocketChannel; |
|
30 |
import java.net.*; |
|
31 |
||
32 |
import javax.net.ssl.*; |
|
33 |
||
34 |
/** |
|
35 |
* Abstract base class for SSLSocketImpl. Its purpose is to house code with |
|
36 |
* no SSL related logic (or no logic at all). This makes SSLSocketImpl shorter |
|
37 |
* and easier to read. It contains a few constants and static methods plus |
|
38 |
* overridden java.net.Socket methods. |
|
39 |
* |
|
40 |
* Methods are defined final to ensure that they are not accidentally |
|
41 |
* overridden in SSLSocketImpl. |
|
42 |
* |
|
43 |
* @see javax.net.ssl.SSLSocket |
|
44 |
* @see SSLSocketImpl |
|
45 |
* |
|
46 |
*/ |
|
47 |
abstract class BaseSSLSocketImpl extends SSLSocket { |
|
48 |
||
49 |
/* |
|
50 |
* Normally "self" is "this" ... but not when this connection is |
|
51 |
* layered over a preexisting socket. If we're using an existing |
|
52 |
* socket, we delegate some actions to it. Else, we delegate |
|
53 |
* instead to "super". This is important to ensure that we don't |
|
54 |
* recurse infinitely ... e.g. close() calling itself, or doing |
|
55 |
* I/O in terms of our own streams. |
|
56 |
*/ |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
57 |
final private Socket self; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
58 |
final private InputStream consumedInput; |
2 | 59 |
|
60 |
BaseSSLSocketImpl() { |
|
61 |
super(); |
|
62 |
this.self = this; |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
63 |
this.consumedInput = null; |
2 | 64 |
} |
65 |
||
66 |
BaseSSLSocketImpl(Socket socket) { |
|
67 |
super(); |
|
68 |
this.self = socket; |
|
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
69 |
this.consumedInput = null; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
70 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
71 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
72 |
BaseSSLSocketImpl(Socket socket, InputStream consumed) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
73 |
super(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
74 |
this.self = socket; |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
75 |
this.consumedInput = consumed; |
2 | 76 |
} |
77 |
||
78 |
// |
|
79 |
// CONSTANTS AND STATIC METHODS |
|
80 |
// |
|
81 |
||
82 |
/** |
|
83 |
* TLS requires that a close_notify warning alert is sent before the |
|
84 |
* connection is closed in order to avoid truncation attacks. Some |
|
85 |
* implementations (MS IIS and others) don't do that. The property |
|
86 |
* below controls whether we accept that or treat it as an error. |
|
87 |
* |
|
88 |
* The default is "false", i.e. tolerate the broken behavior. |
|
89 |
*/ |
|
90 |
private final static String PROP_NAME = |
|
91 |
"com.sun.net.ssl.requireCloseNotify"; |
|
92 |
||
93 |
final static boolean requireCloseNotify = |
|
94 |
Debug.getBooleanProperty(PROP_NAME, false); |
|
95 |
||
96 |
// |
|
97 |
// MISC SOCKET METHODS |
|
98 |
// |
|
99 |
||
100 |
/** |
|
101 |
* Returns the unique {@link java.nio.SocketChannel SocketChannel} object |
|
102 |
* associated with this socket, if any. |
|
103 |
* @see java.net.Socket#getChannel |
|
104 |
*/ |
|
105 |
public final SocketChannel getChannel() { |
|
106 |
if (self == this) { |
|
107 |
return super.getChannel(); |
|
108 |
} else { |
|
109 |
return self.getChannel(); |
|
110 |
} |
|
111 |
} |
|
112 |
||
113 |
/** |
|
114 |
* Binds the address to the socket. |
|
115 |
* @see java.net.Socket#bind |
|
116 |
*/ |
|
117 |
public void bind(SocketAddress bindpoint) throws IOException { |
|
118 |
/* |
|
119 |
* Bind to this socket |
|
120 |
*/ |
|
121 |
if (self == this) { |
|
122 |
super.bind(bindpoint); |
|
123 |
} else { |
|
124 |
// If we're binding on a layered socket... |
|
125 |
throw new IOException( |
|
126 |
"Underlying socket should already be connected"); |
|
127 |
} |
|
128 |
} |
|
129 |
||
130 |
/** |
|
131 |
* Returns the address of the endpoint this socket is connected to |
|
132 |
* @see java.net.Socket#getLocalSocketAddress |
|
133 |
*/ |
|
134 |
public SocketAddress getLocalSocketAddress() { |
|
135 |
if (self == this) { |
|
136 |
return super.getLocalSocketAddress(); |
|
137 |
} else { |
|
138 |
return self.getLocalSocketAddress(); |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* Returns the address of the endpoint this socket is connected to |
|
144 |
* @see java.net.Socket#getRemoteSocketAddress |
|
145 |
*/ |
|
146 |
public SocketAddress getRemoteSocketAddress() { |
|
147 |
if (self == this) { |
|
148 |
return super.getRemoteSocketAddress(); |
|
149 |
} else { |
|
150 |
return self.getRemoteSocketAddress(); |
|
151 |
} |
|
152 |
} |
|
153 |
||
154 |
/** |
|
155 |
* Connects this socket to the server. |
|
156 |
* |
|
157 |
* This method is either called on an unconnected SSLSocketImpl by the |
|
158 |
* application, or it is called in the constructor of a regular |
|
159 |
* SSLSocketImpl. If we are layering on top on another socket, then |
|
160 |
* this method should not be called, because we assume that the |
|
161 |
* underlying socket is already connected by the time it is passed to |
|
162 |
* us. |
|
163 |
* |
|
164 |
* @param endpoint the <code>SocketAddress</code> |
|
165 |
* @throws IOException if an error occurs during the connection |
|
166 |
*/ |
|
167 |
public final void connect(SocketAddress endpoint) throws IOException { |
|
168 |
connect(endpoint, 0); |
|
169 |
} |
|
170 |
||
171 |
/** |
|
172 |
* Returns the connection state of the socket. |
|
173 |
* @see java.net.Socket#isConnected |
|
174 |
*/ |
|
175 |
public final boolean isConnected() { |
|
176 |
if (self == this) { |
|
177 |
return super.isConnected(); |
|
178 |
} else { |
|
179 |
return self.isConnected(); |
|
180 |
} |
|
181 |
} |
|
182 |
||
183 |
/** |
|
184 |
* Returns the binding state of the socket. |
|
185 |
* @see java.net.Socket#isBound |
|
186 |
*/ |
|
187 |
public final boolean isBound() { |
|
188 |
if (self == this) { |
|
189 |
return super.isBound(); |
|
190 |
} else { |
|
191 |
return self.isBound(); |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
// |
|
196 |
// CLOSE RELATED METHODS |
|
197 |
// |
|
198 |
||
199 |
/** |
|
200 |
* The semantics of shutdownInput is not supported in TLS 1.0 |
|
201 |
* spec. Thus when the method is called on an SSL socket, an |
|
202 |
* UnsupportedOperationException will be thrown. |
|
203 |
* |
|
204 |
* @throws UnsupportedOperationException |
|
205 |
*/ |
|
206 |
public final void shutdownInput() throws IOException { |
|
207 |
throw new UnsupportedOperationException("The method shutdownInput()" + |
|
208 |
" is not supported in SSLSocket"); |
|
209 |
} |
|
210 |
||
211 |
/** |
|
212 |
* The semantics of shutdownOutput is not supported in TLS 1.0 |
|
213 |
* spec. Thus when the method is called on an SSL socket, an |
|
214 |
* UnsupportedOperationException will be thrown. |
|
215 |
* |
|
216 |
* @throws UnsupportedOperationException |
|
217 |
*/ |
|
218 |
public final void shutdownOutput() throws IOException { |
|
219 |
throw new UnsupportedOperationException("The method shutdownOutput()" + |
|
220 |
" is not supported in SSLSocket"); |
|
221 |
||
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Returns the input state of the socket |
|
226 |
* @see java.net.Socket#isInputShutdown |
|
227 |
*/ |
|
228 |
public final boolean isInputShutdown() { |
|
229 |
if (self == this) { |
|
230 |
return super.isInputShutdown(); |
|
231 |
} else { |
|
232 |
return self.isInputShutdown(); |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
/** |
|
237 |
* Returns the output state of the socket |
|
238 |
* @see java.net.Socket#isOutputShutdown |
|
239 |
*/ |
|
240 |
public final boolean isOutputShutdown() { |
|
241 |
if (self == this) { |
|
242 |
return super.isOutputShutdown(); |
|
243 |
} else { |
|
244 |
return self.isOutputShutdown(); |
|
245 |
} |
|
246 |
} |
|
247 |
||
248 |
/** |
|
249 |
* Ensures that the SSL connection is closed down as cleanly |
|
250 |
* as possible, in case the application forgets to do so. |
|
251 |
* This allows SSL connections to be implicitly reclaimed, |
|
252 |
* rather than forcing them to be explicitly reclaimed at |
|
253 |
* the penalty of prematurly killing SSL sessions. |
|
254 |
*/ |
|
255 |
protected final void finalize() throws Throwable { |
|
256 |
try { |
|
257 |
close(); |
|
258 |
} catch (IOException e1) { |
|
259 |
try { |
|
260 |
if (self == this) { |
|
261 |
super.close(); |
|
262 |
} |
|
263 |
} catch (IOException e2) { |
|
264 |
// ignore |
|
265 |
} |
|
266 |
} finally { |
|
1580 | 267 |
// We called close on the underlying socket above to |
268 |
// make doubly sure all resources got released. We |
|
269 |
// don't finalize self in the case of overlain sockets, |
|
270 |
// that's a different object which the GC will finalize |
|
271 |
// separately. |
|
272 |
||
2 | 273 |
super.finalize(); |
274 |
} |
|
275 |
} |
|
276 |
||
277 |
// |
|
278 |
// GET ADDRESS METHODS |
|
279 |
// |
|
280 |
||
281 |
/** |
|
282 |
* Returns the address of the remote peer for this connection. |
|
283 |
*/ |
|
284 |
public final InetAddress getInetAddress() { |
|
285 |
if (self == this) { |
|
286 |
return super.getInetAddress(); |
|
287 |
} else { |
|
288 |
return self.getInetAddress(); |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
/** |
|
293 |
* Gets the local address to which the socket is bound. |
|
294 |
* |
|
295 |
* @return the local address to which the socket is bound. |
|
296 |
* @since JDK1.1 |
|
297 |
*/ |
|
298 |
public final InetAddress getLocalAddress() { |
|
299 |
if (self == this) { |
|
300 |
return super.getLocalAddress(); |
|
301 |
} else { |
|
302 |
return self.getLocalAddress(); |
|
303 |
} |
|
304 |
} |
|
305 |
||
306 |
/** |
|
307 |
* Returns the number of the remote port that this connection uses. |
|
308 |
*/ |
|
309 |
public final int getPort() { |
|
310 |
if (self == this) { |
|
311 |
return super.getPort(); |
|
312 |
} else { |
|
313 |
return self.getPort(); |
|
314 |
} |
|
315 |
} |
|
316 |
||
317 |
/** |
|
318 |
* Returns the number of the local port that this connection uses. |
|
319 |
*/ |
|
320 |
public final int getLocalPort() { |
|
321 |
if (self == this) { |
|
322 |
return super.getLocalPort(); |
|
323 |
} else { |
|
324 |
return self.getLocalPort(); |
|
325 |
} |
|
326 |
} |
|
327 |
||
328 |
// |
|
329 |
// SOCKET OPTION METHODS |
|
330 |
// |
|
331 |
||
332 |
/** |
|
333 |
* Enables or disables the Nagle optimization. |
|
334 |
* @see java.net.Socket#setTcpNoDelay |
|
335 |
*/ |
|
336 |
public final void setTcpNoDelay(boolean value) throws SocketException { |
|
337 |
if (self == this) { |
|
338 |
super.setTcpNoDelay(value); |
|
339 |
} else { |
|
340 |
self.setTcpNoDelay(value); |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
/** |
|
345 |
* Returns true if the Nagle optimization is disabled. This |
|
346 |
* relates to low-level buffering of TCP traffic, delaying the |
|
347 |
* traffic to promote better throughput. |
|
348 |
* |
|
349 |
* @see java.net.Socket#getTcpNoDelay |
|
350 |
*/ |
|
351 |
public final boolean getTcpNoDelay() throws SocketException { |
|
352 |
if (self == this) { |
|
353 |
return super.getTcpNoDelay(); |
|
354 |
} else { |
|
355 |
return self.getTcpNoDelay(); |
|
356 |
} |
|
357 |
} |
|
358 |
||
359 |
/** |
|
360 |
* Assigns the socket's linger timeout. |
|
361 |
* @see java.net.Socket#setSoLinger |
|
362 |
*/ |
|
363 |
public final void setSoLinger(boolean flag, int linger) |
|
364 |
throws SocketException { |
|
365 |
if (self == this) { |
|
366 |
super.setSoLinger(flag, linger); |
|
367 |
} else { |
|
368 |
self.setSoLinger(flag, linger); |
|
369 |
} |
|
370 |
} |
|
371 |
||
372 |
/** |
|
373 |
* Returns the socket's linger timeout. |
|
374 |
* @see java.net.Socket#getSoLinger |
|
375 |
*/ |
|
376 |
public final int getSoLinger() throws SocketException { |
|
377 |
if (self == this) { |
|
378 |
return super.getSoLinger(); |
|
379 |
} else { |
|
380 |
return self.getSoLinger(); |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
/** |
|
385 |
* Send one byte of urgent data on the socket. |
|
386 |
* @see java.net.Socket#sendUrgentData |
|
387 |
* At this point, there seems to be no specific requirement to support |
|
388 |
* this for an SSLSocket. An implementation can be provided if a need |
|
389 |
* arises in future. |
|
390 |
*/ |
|
391 |
public final void sendUrgentData(int data) throws SocketException { |
|
392 |
throw new SocketException("This method is not supported " |
|
393 |
+ "by SSLSockets"); |
|
394 |
} |
|
395 |
||
396 |
/** |
|
397 |
* Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this |
|
398 |
* option is disabled and TCP urgent data received on a socket is silently |
|
399 |
* discarded. |
|
400 |
* @see java.net.Socket#setOOBInline |
|
401 |
* Setting OOBInline does not have any effect on SSLSocket, |
|
402 |
* since currently we don't support sending urgent data. |
|
403 |
*/ |
|
404 |
public final void setOOBInline(boolean on) throws SocketException { |
|
405 |
throw new SocketException("This method is ineffective, since" |
|
406 |
+ " sending urgent data is not supported by SSLSockets"); |
|
407 |
} |
|
408 |
||
409 |
/** |
|
410 |
* Tests if OOBINLINE is enabled. |
|
411 |
* @see java.net.Socket#getOOBInline |
|
412 |
*/ |
|
413 |
public final boolean getOOBInline() throws SocketException { |
|
414 |
throw new SocketException("This method is ineffective, since" |
|
415 |
+ " sending urgent data is not supported by SSLSockets"); |
|
416 |
} |
|
417 |
||
418 |
/** |
|
419 |
* Returns the socket timeout. |
|
420 |
* @see java.net.Socket#getSoTimeout |
|
421 |
*/ |
|
422 |
public final int getSoTimeout() throws SocketException { |
|
423 |
if (self == this) { |
|
424 |
return super.getSoTimeout(); |
|
425 |
} else { |
|
426 |
return self.getSoTimeout(); |
|
427 |
} |
|
428 |
} |
|
429 |
||
430 |
public final void setSendBufferSize(int size) throws SocketException { |
|
431 |
if (self == this) { |
|
432 |
super.setSendBufferSize(size); |
|
433 |
} else { |
|
434 |
self.setSendBufferSize(size); |
|
435 |
} |
|
436 |
} |
|
437 |
||
438 |
public final int getSendBufferSize() throws SocketException { |
|
439 |
if (self == this) { |
|
440 |
return super.getSendBufferSize(); |
|
441 |
} else { |
|
442 |
return self.getSendBufferSize(); |
|
443 |
} |
|
444 |
} |
|
445 |
||
446 |
public final void setReceiveBufferSize(int size) throws SocketException { |
|
447 |
if (self == this) { |
|
448 |
super.setReceiveBufferSize(size); |
|
449 |
} else { |
|
450 |
self.setReceiveBufferSize(size); |
|
451 |
} |
|
452 |
} |
|
453 |
||
454 |
public final int getReceiveBufferSize() throws SocketException { |
|
455 |
if (self == this) { |
|
456 |
return super.getReceiveBufferSize(); |
|
457 |
} else { |
|
458 |
return self.getReceiveBufferSize(); |
|
459 |
} |
|
460 |
} |
|
461 |
||
462 |
/** |
|
463 |
* Enable/disable SO_KEEPALIVE. |
|
464 |
* @see java.net.Socket#setKeepAlive |
|
465 |
*/ |
|
466 |
public final void setKeepAlive(boolean on) throws SocketException { |
|
467 |
if (self == this) { |
|
468 |
super.setKeepAlive(on); |
|
469 |
} else { |
|
470 |
self.setKeepAlive(on); |
|
471 |
} |
|
472 |
} |
|
473 |
||
474 |
/** |
|
475 |
* Tests if SO_KEEPALIVE is enabled. |
|
476 |
* @see java.net.Socket#getKeepAlive |
|
477 |
*/ |
|
478 |
public final boolean getKeepAlive() throws SocketException { |
|
479 |
if (self == this) { |
|
480 |
return super.getKeepAlive(); |
|
481 |
} else { |
|
482 |
return self.getKeepAlive(); |
|
483 |
} |
|
484 |
} |
|
485 |
||
486 |
/** |
|
487 |
* Sets traffic class or type-of-service octet in the IP header for |
|
488 |
* packets sent from this Socket. |
|
489 |
* @see java.net.Socket#setTrafficClass |
|
490 |
*/ |
|
491 |
public final void setTrafficClass(int tc) throws SocketException { |
|
492 |
if (self == this) { |
|
493 |
super.setTrafficClass(tc); |
|
494 |
} else { |
|
495 |
self.setTrafficClass(tc); |
|
496 |
} |
|
497 |
} |
|
498 |
||
499 |
/** |
|
500 |
* Gets traffic class or type-of-service in the IP header for packets |
|
501 |
* sent from this Socket. |
|
502 |
* @see java.net.Socket#getTrafficClass |
|
503 |
*/ |
|
504 |
public final int getTrafficClass() throws SocketException { |
|
505 |
if (self == this) { |
|
506 |
return super.getTrafficClass(); |
|
507 |
} else { |
|
508 |
return self.getTrafficClass(); |
|
509 |
} |
|
510 |
} |
|
511 |
||
512 |
/** |
|
513 |
* Enable/disable SO_REUSEADDR. |
|
514 |
* @see java.net.Socket#setReuseAddress |
|
515 |
*/ |
|
516 |
public final void setReuseAddress(boolean on) throws SocketException { |
|
517 |
if (self == this) { |
|
518 |
super.setReuseAddress(on); |
|
519 |
} else { |
|
520 |
self.setReuseAddress(on); |
|
521 |
} |
|
522 |
} |
|
523 |
||
524 |
/** |
|
525 |
* Tests if SO_REUSEADDR is enabled. |
|
526 |
* @see java.net.Socket#getReuseAddress |
|
527 |
*/ |
|
528 |
public final boolean getReuseAddress() throws SocketException { |
|
529 |
if (self == this) { |
|
530 |
return super.getReuseAddress(); |
|
531 |
} else { |
|
532 |
return self.getReuseAddress(); |
|
533 |
} |
|
534 |
} |
|
535 |
||
536 |
/** |
|
537 |
* Sets performance preferences for this socket. |
|
538 |
* |
|
539 |
* @see java.net.Socket#setPerformancePreferences(int, int, int) |
|
540 |
*/ |
|
541 |
public void setPerformancePreferences(int connectionTime, |
|
542 |
int latency, int bandwidth) { |
|
543 |
if (self == this) { |
|
544 |
super.setPerformancePreferences( |
|
545 |
connectionTime, latency, bandwidth); |
|
546 |
} else { |
|
547 |
self.setPerformancePreferences( |
|
548 |
connectionTime, latency, bandwidth); |
|
549 |
} |
|
550 |
} |
|
551 |
||
14194
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
552 |
@Override |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
553 |
public String toString() { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
554 |
if (self == this) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
555 |
return super.toString(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
556 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
557 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
558 |
return self.toString(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
559 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
560 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
561 |
@Override |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
562 |
public InputStream getInputStream() throws IOException { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
563 |
if (self == this) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
564 |
return super.getInputStream(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
565 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
566 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
567 |
if (consumedInput != null) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
568 |
return new SequenceInputStream(consumedInput, |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
569 |
self.getInputStream()); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
570 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
571 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
572 |
return self.getInputStream(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
573 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
574 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
575 |
@Override |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
576 |
public OutputStream getOutputStream() throws IOException { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
577 |
if (self == this) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
578 |
return super.getOutputStream(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
579 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
580 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
581 |
return self.getOutputStream(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
582 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
583 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
584 |
@Override |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
585 |
public synchronized void close() throws IOException { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
586 |
if (self == this) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
587 |
super.close(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
588 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
589 |
self.close(); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
590 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
591 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
592 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
593 |
@Override |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
594 |
public synchronized void setSoTimeout(int timeout) throws SocketException { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
595 |
if (self == this) { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
596 |
super.setSoTimeout(timeout); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
597 |
} else { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
598 |
self.setSoTimeout(timeout); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
599 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
600 |
} |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
601 |
|
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
602 |
boolean isLayered() { |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
603 |
return (self != this); |
971f46db533d
7068321: Support TLS Server Name Indication (SNI) Extension in JSSE Server
xuelei
parents:
5506
diff
changeset
|
604 |
} |
2 | 605 |
} |