This is a normal connection type socket, implementing SSL over some lower level socket, such as TCP. Because it is layered over some lower level socket, it MUST override all default socket methods.
This API offers a non-traditional option for establishing SSL connections. You may first establish the connection directly, then pass that connection to the SSL socket constructor with a flag saying which role should be taken in the handshake protocol. (The two ends of the connection must not choose the same role!) This allows setup of SSL proxying or tunneling, and also allows the kind of "role reversal" that is required for most FTP data transfers.
javax.net.ssl.SSLSocket
, SSLServerSocket
Modifier and Type | Class and Description |
---|---|
private class | SSLSocketImpl.
InputStream for application data as returned by SSLSocket.getInputStream(). |
private class | SSLSocketImpl.
OutputStream for application data as returned by SSLSocket.getOutputStream(). |
Modifier and Type | Field and Description |
---|---|
private final SSLSocketImpl. | |
private final SSLSocketImpl. | |
private boolean | |
pack-priv final TransportContext | |
private static final int | |
private final ReentrantLock | |
private boolean | |
private String | |
private final ReentrantLock | |
pack-priv final SSLContextImpl | sslContext
ERROR HANDLING GUIDELINES (which exceptions to throw and catch and which not to throw and catch) - if there is an IOException (SocketException) when accessing the underlying Socket, pass it through - do not throw IOExceptions, throw SSLExceptions (or a subclass) |
private volatile boolean | |
private static final boolean |
Access | Constructor and Description |
---|---|
pack-priv | SSLSocketImpl(SSLContextImpl sslContext)
Package-private constructor used to instantiate an unconnected socket. |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, SSLConfiguration sslConfig)
Package-private constructor used to instantiate a server socket. |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, String peerHost, int peerPort)
Constructs an SSL connection to a named host at a specified port, using the authentication context provided. |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, InetAddress address, int peerPort)
Constructs an SSL connection to a server at a specified address, and TCP port, using the authentication context provided. |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, String peerHost, int peerPort, InetAddress localAddr, int localPort)
Constructs an SSL connection to a named host at a specified port, using the authentication context provided. |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, InetAddress peerAddr, int peerPort, InetAddress localAddr, int localPort)
Constructs an SSL connection to a server at a specified address, and TCP port, using the authentication context provided. |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, Socket sock, InputStream consumed, boolean autoClose)
Creates a server mode |
pack-priv | SSLSocketImpl(SSLContextImpl sslContext, Socket sock, String peerHost, int port, boolean autoClose)
Layer SSL traffic over an existing connection, rather than creating a new connection. |
Modifier and Type | Method and Description |
---|---|
public void | addHandshakeCompletedListener(HandshakeCompletedListener
the HandShake Completed event listener listener)Implements abstract javax. Registers an event listener to receive notifications that an SSL handshake has completed on this connection. |
private void | |
public void | close()
Overrides sun. Implements java. Closes this socket. |
pack-priv void | |
private void | |
public void | connect(SocketAddress
the endpoint, int SocketAddress the timeout value to be used in milliseconds. timeout)Overrides java. Connects this socket to the server with a specified timeout value. |
private Plaintext | |
private void | |
pack-priv void | |
private void | |
private void | |
private void | |
public String | getApplicationProtocol()
Overrides javax. Returns the most recent application protocol value negotiated for this connection. |
public String[] | getEnabledCipherSuites()
Implements abstract javax. Returns the names of the SSL cipher suites which are currently enabled for use on this connection. |
public String[] | getEnabledProtocols()
Implements abstract javax. Returns the names of the protocol versions which are currently enabled for use on this connection. |
public boolean | getEnableSessionCreation()
Implements abstract javax. Returns true if new SSL sessions may be established by this socket. |
public String | getHandshakeApplicationProtocol()
Overrides javax. Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress. |
public BiFunction | getHandshakeApplicationProtocolSelector()
Overrides javax. Retrieves the callback function that selects an application protocol value during a SSL/TLS/DTLS handshake. |
public SSLSession | getHandshakeSession()
Overrides javax. Returns the |
public InputStream | getInputStream()
Overrides sun. Returns an input stream for this socket. |
public boolean | getNeedClientAuth()
Implements abstract javax. Returns true if the socket will require client authentication. |
public OutputStream | getOutputStream()
Overrides sun. Returns an output stream for this socket. |
public String | getPeerHost()
Implements sun. Returns the host name of the peer. |
public int | getPeerPort()
Implements sun. Returns the port number of the peer. |
public SSLSession | getSession()
Implements abstract javax. Returns the SSL Session in use by this connection. |
public SSLParameters | getSSLParameters()
Overrides javax. Returns the SSLParameters in effect for this SSLSocket. |
public String[] | getSupportedCipherSuites()
Implements abstract javax. Returns the names of the cipher suites which could be enabled for use on this connection. |
public String[] | getSupportedProtocols()
Implements abstract javax. Returns the names of the protocols which could be enabled for use on an SSL connection. |
public boolean | getUseClientMode()
Implements abstract javax. Returns true if the socket is set to use client mode when handshaking. |
public boolean | getWantClientAuth()
Implements abstract javax. Returns true if the socket will request client authentication. |
private Plaintext | |
private void | |
public boolean | |
public boolean | isInputShutdown()
Overrides sun. Returns the input state of the socket |
public boolean | isOutputShutdown()
Overrides sun. Returns the output state of the socket |
private ByteBuffer | |
private int | |
public void | removeHandshakeCompletedListener(HandshakeCompletedListener
the HandShake Completed event listener listener)Implements abstract javax. Removes a previously registered handshake completion listener. |
public void | setEnabledCipherSuites(String[]
Names of all the cipher suites to enable suites)Implements abstract javax. Sets the cipher suites enabled for use on this connection. |
public void | setEnabledProtocols(String[]
Names of all the protocols to enable. protocols)Implements abstract javax. Sets the protocol versions enabled for use on this connection. |
public void | setEnableSessionCreation(boolean
true indicates that sessions may be created; this
is the default. false indicates that an existing session
must be resumed flag)Implements abstract javax. Controls whether new SSL sessions may be established by this socket. |
public void | setHandshakeApplicationProtocolSelector(BiFunction<SSLSocket, List<String>, String>
the callback function, or null to de-register. selector)Overrides javax. Registers a callback function that selects an application protocol value for a SSL/TLS/DTLS handshake. |
public void | |
public void | setNeedClientAuth(boolean
set to true if client authentication is required,
or false if no client authentication is desired. need)Implements abstract javax. Configures the socket to require client authentication. |
public void | setSSLParameters(SSLParameters
the parameters params)Overrides javax. Applies SSLParameters to this socket. |
public void | setUseClientMode(boolean
true if the socket should start its handshaking
in "client" mode mode)Implements abstract javax. Configures the socket to use client (or server) mode when handshaking. |
public void | setWantClientAuth(boolean
set to true if client authentication is requested,
or false if no client authentication is desired. want)Implements abstract javax. Configures the socket to request client authentication. |
public void | |
public void | shutdownInput()
Overrides sun. Places the input stream for this socket at "end of stream". |
private void | |
public void | shutdownOutput()
Overrides sun. Disables the output stream for this socket. |
public void | startHandshake()
Implements abstract javax. Starts an SSL handshake on this connection. |
private void | |
public String | |
private void | |
private void | |
public boolean | useDelegatedTask()
Implements sun. Return true if delegated tasks used for handshaking operations. |
private void | |
private void |