SSLSocketImpl.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. /* SSLSocketImpl.java -- implementation of an SSL client socket.
  2. Copyright (C) 2006 Free Software Foundation, Inc.
  3. This file is a part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or (at
  7. your option) any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  15. USA
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package gnu.javax.net.ssl.provider;
  32. import gnu.classpath.debug.Component;
  33. import gnu.classpath.debug.SystemLogger;
  34. import java.io.DataInputStream;
  35. import java.io.EOFException;
  36. import java.io.IOException;
  37. import java.io.InputStream;
  38. import java.io.OutputStream;
  39. import java.net.InetAddress;
  40. import java.net.Socket;
  41. import java.net.SocketAddress;
  42. import java.net.SocketException;
  43. import java.nio.ByteBuffer;
  44. import java.nio.channels.SocketChannel;
  45. import java.util.HashSet;
  46. import java.util.Set;
  47. import javax.net.ssl.HandshakeCompletedEvent;
  48. import javax.net.ssl.HandshakeCompletedListener;
  49. import javax.net.ssl.SSLEngineResult;
  50. import javax.net.ssl.SSLException;
  51. import javax.net.ssl.SSLSession;
  52. import javax.net.ssl.SSLSocket;
  53. import javax.net.ssl.SSLEngineResult.HandshakeStatus;
  54. import javax.net.ssl.SSLEngineResult.Status;
  55. /**
  56. * @author Casey Marshall (csm@gnu.org)
  57. */
  58. public class SSLSocketImpl extends SSLSocket
  59. {
  60. private class SocketOutputStream extends OutputStream
  61. {
  62. private final ByteBuffer buffer;
  63. private final OutputStream out;
  64. SocketOutputStream() throws IOException
  65. {
  66. buffer = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]);
  67. if (underlyingSocket != null)
  68. out = underlyingSocket.getOutputStream();
  69. else
  70. out = SSLSocketImpl.super.getOutputStream();
  71. }
  72. @Override public void write(byte[] buf, int off, int len) throws IOException
  73. {
  74. if (!initialHandshakeDone
  75. || engine.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING)
  76. {
  77. doHandshake();
  78. if (handshakeException != null)
  79. throw handshakeException;
  80. }
  81. int k = 0;
  82. while (k < len)
  83. {
  84. synchronized (engine)
  85. {
  86. int l = Math.min(len-k, getSession().getApplicationBufferSize());
  87. ByteBuffer in = ByteBuffer.wrap(buf, off+k, l);
  88. SSLEngineResult result = engine.wrap(in, buffer);
  89. if (result.getStatus() == Status.CLOSED)
  90. return;
  91. if (result.getStatus() != Status.OK)
  92. throw new SSLException("unexpected SSL state " + result.getStatus());
  93. buffer.flip();
  94. out.write(buffer.array(), 0, buffer.limit());
  95. k += result.bytesConsumed();
  96. buffer.clear();
  97. }
  98. }
  99. }
  100. @Override public void write(int b) throws IOException
  101. {
  102. write(new byte[] { (byte) b });
  103. }
  104. @Override public void close() throws IOException
  105. {
  106. SSLSocketImpl.this.close();
  107. }
  108. }
  109. private class SocketInputStream extends InputStream
  110. {
  111. private final ByteBuffer inBuffer;
  112. private final ByteBuffer appBuffer;
  113. private final DataInputStream in;
  114. SocketInputStream() throws IOException
  115. {
  116. inBuffer = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]);
  117. inBuffer.limit(0);
  118. appBuffer = ByteBuffer.allocate(getSession().getApplicationBufferSize());
  119. appBuffer.flip();
  120. if (underlyingSocket != null)
  121. in = new DataInputStream(underlyingSocket.getInputStream());
  122. else
  123. in = new DataInputStream(SSLSocketImpl.super.getInputStream());
  124. }
  125. @Override public int read(byte[] buf, int off, int len) throws IOException
  126. {
  127. if (!initialHandshakeDone ||
  128. engine.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING)
  129. {
  130. doHandshake();
  131. if (handshakeException != null)
  132. throw handshakeException;
  133. }
  134. if (!appBuffer.hasRemaining())
  135. {
  136. int x = in.read();
  137. if (x == -1)
  138. return -1;
  139. inBuffer.clear();
  140. inBuffer.put((byte) x);
  141. inBuffer.putInt(in.readInt());
  142. int reclen = inBuffer.getShort(3) & 0xFFFF;
  143. in.readFully(inBuffer.array(), 5, reclen);
  144. inBuffer.position(0).limit(reclen + 5);
  145. synchronized (engine)
  146. {
  147. appBuffer.clear();
  148. SSLEngineResult result = engine.unwrap(inBuffer, appBuffer);
  149. Status status = result.getStatus();
  150. if (status == Status.CLOSED && result.bytesProduced() == 0)
  151. return -1;
  152. }
  153. inBuffer.compact();
  154. appBuffer.flip();
  155. }
  156. int l = Math.min(len, appBuffer.remaining());
  157. appBuffer.get(buf, off, l);
  158. return l;
  159. }
  160. @Override public int read() throws IOException
  161. {
  162. byte[] b = new byte[1];
  163. if (read(b) == -1)
  164. return -1;
  165. return b[0] & 0xFF;
  166. }
  167. }
  168. private static final SystemLogger logger = SystemLogger.getSystemLogger();
  169. private SSLEngineImpl engine;
  170. private Set<HandshakeCompletedListener> listeners;
  171. private Socket underlyingSocket;
  172. private boolean isHandshaking;
  173. private IOException handshakeException;
  174. private boolean initialHandshakeDone = false;
  175. private final boolean autoClose;
  176. public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port)
  177. {
  178. this(contextImpl, host, port, new Socket(), true);
  179. }
  180. public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port,
  181. Socket underlyingSocket, boolean autoClose)
  182. {
  183. engine = new SSLEngineImpl(contextImpl, host, port);
  184. engine.setUseClientMode(true); // default to client mode
  185. listeners = new HashSet<HandshakeCompletedListener>();
  186. this.underlyingSocket = underlyingSocket;
  187. this.autoClose = autoClose;
  188. }
  189. /* (non-Javadoc)
  190. * @see javax.net.ssl.SSLSocket#addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener)
  191. */
  192. @Override
  193. public void addHandshakeCompletedListener(HandshakeCompletedListener listener)
  194. {
  195. listeners.add(listener);
  196. }
  197. /* (non-Javadoc)
  198. * @see javax.net.ssl.SSLSocket#getEnableSessionCreation()
  199. */
  200. @Override public boolean getEnableSessionCreation()
  201. {
  202. return engine.getEnableSessionCreation();
  203. }
  204. /* (non-Javadoc)
  205. * @see javax.net.ssl.SSLSocket#getEnabledCipherSuites()
  206. */
  207. @Override public String[] getEnabledCipherSuites()
  208. {
  209. return engine.getEnabledCipherSuites();
  210. }
  211. /* (non-Javadoc)
  212. * @see javax.net.ssl.SSLSocket#getEnabledProtocols()
  213. */
  214. @Override public String[] getEnabledProtocols()
  215. {
  216. return engine.getEnabledProtocols();
  217. }
  218. /* (non-Javadoc)
  219. * @see javax.net.ssl.SSLSocket#getNeedClientAuth()
  220. */
  221. @Override public boolean getNeedClientAuth()
  222. {
  223. return engine.getNeedClientAuth();
  224. }
  225. /* (non-Javadoc)
  226. * @see javax.net.ssl.SSLSocket#getSession()
  227. */
  228. @Override public SSLSession getSession()
  229. {
  230. return engine.getSession();
  231. }
  232. /* (non-Javadoc)
  233. * @see javax.net.ssl.SSLSocket#getSupportedCipherSuites()
  234. */
  235. @Override public String[] getSupportedCipherSuites()
  236. {
  237. return engine.getSupportedCipherSuites();
  238. }
  239. /* (non-Javadoc)
  240. * @see javax.net.ssl.SSLSocket#getSupportedProtocols()
  241. */
  242. @Override public String[] getSupportedProtocols()
  243. {
  244. return engine.getSupportedProtocols();
  245. }
  246. /* (non-Javadoc)
  247. * @see javax.net.ssl.SSLSocket#getUseClientMode()
  248. */
  249. @Override public boolean getUseClientMode()
  250. {
  251. return engine.getUseClientMode();
  252. }
  253. /* (non-Javadoc)
  254. * @see javax.net.ssl.SSLSocket#getWantClientAuth()
  255. */
  256. @Override public boolean getWantClientAuth()
  257. {
  258. return engine.getWantClientAuth();
  259. }
  260. /* (non-Javadoc)
  261. * @see javax.net.ssl.SSLSocket#removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener)
  262. */
  263. @Override
  264. public void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
  265. {
  266. listeners.remove(listener);
  267. }
  268. /* (non-Javadoc)
  269. * @see javax.net.ssl.SSLSocket#setEnableSessionCreation(boolean)
  270. */
  271. @Override public void setEnableSessionCreation(boolean enable)
  272. {
  273. engine.setEnableSessionCreation(enable);
  274. }
  275. /* (non-Javadoc)
  276. * @see javax.net.ssl.SSLSocket#setEnabledCipherSuites(java.lang.String[])
  277. */
  278. @Override public void setEnabledCipherSuites(String[] suites)
  279. {
  280. engine.setEnabledCipherSuites(suites);
  281. }
  282. /* (non-Javadoc)
  283. * @see javax.net.ssl.SSLSocket#setEnabledProtocols(java.lang.String[])
  284. */
  285. @Override public void setEnabledProtocols(String[] protocols)
  286. {
  287. engine.setEnabledProtocols(protocols);
  288. }
  289. /* (non-Javadoc)
  290. * @see javax.net.ssl.SSLSocket#setNeedClientAuth(boolean)
  291. */
  292. @Override public void setNeedClientAuth(boolean needAuth)
  293. {
  294. engine.setNeedClientAuth(needAuth);
  295. }
  296. /* (non-Javadoc)
  297. * @see javax.net.ssl.SSLSocket#setUseClientMode(boolean)
  298. */
  299. @Override public void setUseClientMode(boolean clientMode)
  300. {
  301. engine.setUseClientMode(clientMode);
  302. }
  303. /* (non-Javadoc)
  304. * @see javax.net.ssl.SSLSocket#setWantClientAuth(boolean)
  305. */
  306. @Override public void setWantClientAuth(boolean wantAuth)
  307. {
  308. engine.setWantClientAuth(wantAuth);
  309. }
  310. /* (non-Javadoc)
  311. * @see javax.net.ssl.SSLSocket#startHandshake()
  312. */
  313. @Override public void startHandshake() throws IOException
  314. {
  315. if (isHandshaking)
  316. return;
  317. if (handshakeException != null)
  318. throw handshakeException;
  319. Thread t = new Thread(new Runnable()
  320. {
  321. public void run()
  322. {
  323. try
  324. {
  325. doHandshake();
  326. }
  327. catch (IOException ioe)
  328. {
  329. handshakeException = ioe;
  330. }
  331. }
  332. }, "HandshakeThread@" + System.identityHashCode(this));
  333. t.start();
  334. }
  335. void doHandshake() throws IOException
  336. {
  337. synchronized (engine)
  338. {
  339. if (isHandshaking)
  340. {
  341. try
  342. {
  343. engine.wait();
  344. }
  345. catch (InterruptedException ie)
  346. {
  347. }
  348. return;
  349. }
  350. isHandshaking = true;
  351. }
  352. if (initialHandshakeDone)
  353. throw new SSLException("rehandshaking not yet implemented");
  354. long now = -System.currentTimeMillis();
  355. engine.beginHandshake();
  356. HandshakeStatus status = engine.getHandshakeStatus();
  357. assert(status != HandshakeStatus.NOT_HANDSHAKING);
  358. ByteBuffer inBuffer = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]);
  359. inBuffer.position(inBuffer.limit());
  360. ByteBuffer outBuffer = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]);
  361. ByteBuffer emptyBuffer = ByteBuffer.allocate(0);
  362. SSLEngineResult result = null;
  363. DataInputStream sockIn = new DataInputStream(underlyingSocket.getInputStream());
  364. OutputStream sockOut = underlyingSocket.getOutputStream();
  365. try
  366. {
  367. while (status != HandshakeStatus.NOT_HANDSHAKING
  368. && status != HandshakeStatus.FINISHED)
  369. {
  370. logger.logv(Component.SSL_HANDSHAKE, "socket processing state {0}",
  371. status);
  372. if (inBuffer.capacity() != getSession().getPacketBufferSize())
  373. {
  374. ByteBuffer b
  375. = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]);
  376. if (inBuffer.hasRemaining())
  377. b.put(inBuffer).flip();
  378. inBuffer = b;
  379. }
  380. if (outBuffer.capacity() != getSession().getPacketBufferSize())
  381. outBuffer
  382. = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]);
  383. switch (status)
  384. {
  385. case NEED_UNWRAP:
  386. // Read in a single SSL record.
  387. inBuffer.clear();
  388. int i = sockIn.read();
  389. if (i == -1)
  390. throw new EOFException();
  391. if ((i & 0x80) == 0x80) // SSLv2 client hello.
  392. {
  393. inBuffer.put((byte) i);
  394. int v2len = (i & 0x7f) << 8;
  395. i = sockIn.read();
  396. v2len = v2len | (i & 0xff);
  397. inBuffer.put((byte) i);
  398. sockIn.readFully(inBuffer.array(), 2, v2len);
  399. inBuffer.position(0).limit(v2len + 2);
  400. }
  401. else
  402. {
  403. inBuffer.put((byte) i);
  404. inBuffer.putInt(sockIn.readInt());
  405. int reclen = inBuffer.getShort(3) & 0xFFFF;
  406. sockIn.readFully(inBuffer.array(), 5, reclen);
  407. inBuffer.position(0).limit(reclen + 5);
  408. }
  409. result = engine.unwrap(inBuffer, emptyBuffer);
  410. status = result.getHandshakeStatus();
  411. if (result.getStatus() != Status.OK)
  412. throw new SSLException("unexpected SSL status "
  413. + result.getStatus());
  414. break;
  415. case NEED_WRAP:
  416. {
  417. outBuffer.clear();
  418. result = engine.wrap(emptyBuffer, outBuffer);
  419. status = result.getHandshakeStatus();
  420. if (result.getStatus() != Status.OK)
  421. throw new SSLException("unexpected SSL status "
  422. + result.getStatus());
  423. outBuffer.flip();
  424. sockOut.write(outBuffer.array(), outBuffer.position(),
  425. outBuffer.limit());
  426. }
  427. break;
  428. case NEED_TASK:
  429. {
  430. Runnable task;
  431. while ((task = engine.getDelegatedTask()) != null)
  432. task.run();
  433. status = engine.getHandshakeStatus();
  434. }
  435. break;
  436. case FINISHED:
  437. break;
  438. }
  439. }
  440. initialHandshakeDone = true;
  441. HandshakeCompletedEvent hce = new HandshakeCompletedEvent(this, getSession());
  442. for (HandshakeCompletedListener l : listeners)
  443. {
  444. try
  445. {
  446. l.handshakeCompleted(hce);
  447. }
  448. catch (ThreadDeath td)
  449. {
  450. throw td;
  451. }
  452. catch (Throwable x)
  453. {
  454. logger.log(Component.WARNING,
  455. "HandshakeCompletedListener threw exception", x);
  456. }
  457. }
  458. now += System.currentTimeMillis();
  459. if (Debug.DEBUG)
  460. logger.logv(Component.SSL_HANDSHAKE,
  461. "handshake completed in {0}ms in thread {1}", now,
  462. Thread.currentThread().getName());
  463. }
  464. catch (SSLException ssle)
  465. {
  466. handshakeException = ssle;
  467. throw ssle;
  468. }
  469. finally
  470. {
  471. synchronized (engine)
  472. {
  473. isHandshaking = false;
  474. engine.notifyAll();
  475. }
  476. }
  477. }
  478. // Methods overriding Socket.
  479. @Override public void bind(SocketAddress bindpoint) throws IOException
  480. {
  481. underlyingSocket.bind(bindpoint);
  482. }
  483. @Override public void connect(SocketAddress endpoint) throws IOException
  484. {
  485. underlyingSocket.connect(endpoint);
  486. }
  487. @Override public void connect(SocketAddress endpoint, int timeout)
  488. throws IOException
  489. {
  490. underlyingSocket.connect(endpoint, timeout);
  491. }
  492. @Override public InetAddress getInetAddress()
  493. {
  494. return underlyingSocket.getInetAddress();
  495. }
  496. @Override public InetAddress getLocalAddress()
  497. {
  498. return underlyingSocket.getLocalAddress();
  499. }
  500. @Override public int getPort()
  501. {
  502. return underlyingSocket.getPort();
  503. }
  504. @Override public int getLocalPort()
  505. {
  506. return underlyingSocket.getLocalPort();
  507. }
  508. @Override public SocketAddress getRemoteSocketAddress()
  509. {
  510. return underlyingSocket.getRemoteSocketAddress();
  511. }
  512. public SocketAddress getLocalSocketAddress()
  513. {
  514. return underlyingSocket.getLocalSocketAddress();
  515. }
  516. @Override public SocketChannel getChannel()
  517. {
  518. throw new UnsupportedOperationException("use javax.net.ssl.SSLEngine for NIO");
  519. }
  520. @Override public InputStream getInputStream() throws IOException
  521. {
  522. return new SocketInputStream();
  523. }
  524. @Override public OutputStream getOutputStream() throws IOException
  525. {
  526. return new SocketOutputStream();
  527. }
  528. @Override public void setTcpNoDelay(boolean on) throws SocketException
  529. {
  530. underlyingSocket.setTcpNoDelay(on);
  531. }
  532. @Override public boolean getTcpNoDelay() throws SocketException
  533. {
  534. return underlyingSocket.getTcpNoDelay();
  535. }
  536. @Override public void setSoLinger(boolean on, int linger) throws SocketException
  537. {
  538. underlyingSocket.setSoLinger(on, linger);
  539. }
  540. public int getSoLinger() throws SocketException
  541. {
  542. return underlyingSocket.getSoLinger();
  543. }
  544. @Override public void sendUrgentData(int x) throws IOException
  545. {
  546. throw new UnsupportedOperationException("not supported");
  547. }
  548. @Override public void setOOBInline(boolean on) throws SocketException
  549. {
  550. underlyingSocket.setOOBInline(on);
  551. }
  552. @Override public boolean getOOBInline() throws SocketException
  553. {
  554. return underlyingSocket.getOOBInline();
  555. }
  556. @Override public void setSoTimeout(int timeout) throws SocketException
  557. {
  558. underlyingSocket.setSoTimeout(timeout);
  559. }
  560. @Override public int getSoTimeout() throws SocketException
  561. {
  562. return underlyingSocket.getSoTimeout();
  563. }
  564. @Override public void setSendBufferSize(int size) throws SocketException
  565. {
  566. underlyingSocket.setSendBufferSize(size);
  567. }
  568. @Override public int getSendBufferSize() throws SocketException
  569. {
  570. return underlyingSocket.getSendBufferSize();
  571. }
  572. @Override public void setReceiveBufferSize(int size) throws SocketException
  573. {
  574. underlyingSocket.setReceiveBufferSize(size);
  575. }
  576. @Override public int getReceiveBufferSize() throws SocketException
  577. {
  578. return underlyingSocket.getReceiveBufferSize();
  579. }
  580. @Override public void setKeepAlive(boolean on) throws SocketException
  581. {
  582. underlyingSocket.setKeepAlive(on);
  583. }
  584. @Override public boolean getKeepAlive() throws SocketException
  585. {
  586. return underlyingSocket.getKeepAlive();
  587. }
  588. @Override public void setTrafficClass(int tc) throws SocketException
  589. {
  590. underlyingSocket.setTrafficClass(tc);
  591. }
  592. @Override public int getTrafficClass() throws SocketException
  593. {
  594. return underlyingSocket.getTrafficClass();
  595. }
  596. @Override public void setReuseAddress(boolean reuseAddress)
  597. throws SocketException
  598. {
  599. underlyingSocket.setReuseAddress(reuseAddress);
  600. }
  601. @Override public boolean getReuseAddress() throws SocketException
  602. {
  603. return underlyingSocket.getReuseAddress();
  604. }
  605. @Override public void close() throws IOException
  606. {
  607. // XXX closure alerts.
  608. if (autoClose)
  609. underlyingSocket.close();
  610. }
  611. @Override public void shutdownInput() throws IOException
  612. {
  613. underlyingSocket.shutdownInput();
  614. }
  615. @Override public void shutdownOutput() throws IOException
  616. {
  617. underlyingSocket.shutdownOutput();
  618. }
  619. @Override public boolean isConnected()
  620. {
  621. return underlyingSocket.isConnected();
  622. }
  623. @Override public boolean isBound()
  624. {
  625. return underlyingSocket.isBound();
  626. }
  627. @Override public boolean isClosed()
  628. {
  629. return underlyingSocket.isClosed();
  630. }
  631. @Override public boolean isInputShutdown()
  632. {
  633. return underlyingSocket.isInputShutdown();
  634. }
  635. @Override public boolean isOutputShutdown()
  636. {
  637. return underlyingSocket.isOutputShutdown();
  638. }
  639. }