src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java
branchJDK-8145252-TLS13-branch
changeset 56718 da9979451b7a
parent 56712 bad9f4c7eeec
child 56739 ae0cd8b2e2c2
equal deleted inserted replaced
56717:e4fe7c97b1de 56718:da9979451b7a
    88      * Is the local name service trustworthy?
    88      * Is the local name service trustworthy?
    89      *
    89      *
    90      * If the local name service is not trustworthy, reverse host name
    90      * If the local name service is not trustworthy, reverse host name
    91      * resolution should not be performed for endpoint identification.
    91      * resolution should not be performed for endpoint identification.
    92      */
    92      */
    93     static final boolean trustNameService =
    93     private static final boolean trustNameService =
    94             Utilities.getBooleanProperty("jdk.tls.trustNameService", false);
    94             Utilities.getBooleanProperty("jdk.tls.trustNameService", false);
    95 
    95 
    96     /**
    96     /**
    97      * Package-private constructor used to instantiate an unconnected
    97      * Package-private constructor used to instantiate an unconnected
    98      * socket.
    98      * socket.
   219      * already been consumed/removed from the {@link Socket}'s
   219      * already been consumed/removed from the {@link Socket}'s
   220      * underlying {@link InputStream}.
   220      * underlying {@link InputStream}.
   221      */
   221      */
   222     SSLSocketImpl(SSLContextImpl sslContext, Socket sock,
   222     SSLSocketImpl(SSLContextImpl sslContext, Socket sock,
   223             InputStream consumed, boolean autoClose) throws IOException {
   223             InputStream consumed, boolean autoClose) throws IOException {
   224 
       
   225         super(sock, consumed);
   224         super(sock, consumed);
   226         // We always layer over a connected socket
   225         // We always layer over a connected socket
   227         if (!sock.isConnected()) {
   226         if (!sock.isConnected()) {
   228             throw new SocketException("Underlying socket is not connected");
   227             throw new SocketException("Underlying socket is not connected");
   229         }
   228         }
   297         return CipherSuite.namesOf(conContext.sslConfig.enabledCipherSuites);
   296         return CipherSuite.namesOf(conContext.sslConfig.enabledCipherSuites);
   298     }
   297     }
   299 
   298 
   300     @Override
   299     @Override
   301     public synchronized void setEnabledCipherSuites(String[] suites) {
   300     public synchronized void setEnabledCipherSuites(String[] suites) {
   302         if (suites == null) {
       
   303             throw new IllegalArgumentException("CipherSuites cannot be null");
       
   304         }
       
   305 
       
   306         conContext.sslConfig.enabledCipherSuites =
   301         conContext.sslConfig.enabledCipherSuites =
   307                 CipherSuite.validValuesOf(suites);
   302                 CipherSuite.validValuesOf(suites);
   308     }
   303     }
   309 
   304 
   310     @Override
   305     @Override
   480         }
   475         }
   481 
   476 
   482         startHandshake();
   477         startHandshake();
   483     }
   478     }
   484 
   479 
       
   480     /**
       
   481      * InputStream for application data as returned by
       
   482      * SSLSocket.getInputStream().
       
   483      */
   485     private class AppInputStream extends InputStream {
   484     private class AppInputStream extends InputStream {
   486         // One element array used to implement the single byte read() method
   485         // One element array used to implement the single byte read() method
   487         private final byte[] oneByte = new byte[1];
   486         private final byte[] oneByte = new byte[1];
   488 
   487 
   489         // the temporary buffer used to read network
   488         // the temporary buffer used to read network
   569             }
   568             }
   570 
   569 
   571             appDataIsAvailable = false;
   570             appDataIsAvailable = false;
   572             int volume = 0;
   571             int volume = 0;
   573             try {
   572             try {
       
   573                 /*
       
   574                  * Read data if needed ... notice that the connection
       
   575                  * guarantees that handshake, alert, and change cipher spec
       
   576                  * data streams are handled as they arrive, so we never
       
   577                  * see them here.
       
   578                  */
   574                 while (volume == 0) {
   579                 while (volume == 0) {
   575                     // Clear the buffer for a new record reading.
   580                     // Clear the buffer for a new record reading.
   576                     buffer.clear();
   581                     buffer.clear();
   577 
   582 
   578                     // grow the buffer if needed
   583                     // grow the buffer if needed
   668         }
   673         }
   669 
   674 
   670         return appOutput;
   675         return appOutput;
   671     }
   676     }
   672 
   677 
       
   678 
       
   679     /**
       
   680      * OutputStream for application data as returned by
       
   681      * SSLSocket.getOutputStream().
       
   682      */
   673     private class AppOutputStream extends OutputStream {
   683     private class AppOutputStream extends OutputStream {
   674         // One element array used to implement the write(byte) method
   684         // One element array used to implement the write(byte) method
   675         private final byte[] oneByte = new byte[1];
   685         private final byte[] oneByte = new byte[1];
   676 
   686 
   677         @Override
   687         @Override