public abstract class SSLSocket extends Socket
Socket
providing secure protocols like SSL (Secure
Sockets Layer) or TLS (Transport Layer Security).Modifier | Constructor and Description |
---|---|
protected |
SSLSocket()
Only to be used by subclasses.
|
protected |
SSLSocket(InetAddress address,
int port)
Only to be used by subclasses.
|
protected |
SSLSocket(InetAddress address,
int port,
InetAddress clientAddress,
int clientPort)
Only to be used by subclasses.
|
protected |
SSLSocket(String host,
int port)
Only to be used by subclasses.
|
protected |
SSLSocket(String host,
int port,
InetAddress clientAddress,
int clientPort)
Only to be used by subclasses.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addHandshakeCompletedListener(HandshakeCompletedListener listener)
Registers the specified listener to receive notification on completion of a
handshake on this connection.
|
abstract String[] |
getEnabledCipherSuites()
Returns the names of the enabled cipher suites.
|
abstract String[] |
getEnabledProtocols()
Returns the names of the enabled protocols.
|
abstract boolean |
getEnableSessionCreation()
Returns whether new SSL sessions may be created by this socket or if
existing sessions must be reused.
|
abstract boolean |
getNeedClientAuth()
Returns true if the server socket should require client authentication.
|
abstract SSLSession |
getSession()
Returns the
SSLSession for this connection. |
SSLParameters |
getSSLParameters()
Returns a new SSLParameters based on this SSLSocket's current
cipher suites, protocols, and client authentication settings.
|
abstract String[] |
getSupportedCipherSuites()
Returns the names of the supported cipher suites.
|
abstract String[] |
getSupportedProtocols()
Returns the names of the supported protocols.
|
abstract boolean |
getUseClientMode()
Returns true if this connection will act in client mode when handshaking.
|
abstract boolean |
getWantClientAuth()
Returns true if the server should request client authentication.
|
abstract void |
removeHandshakeCompletedListener(HandshakeCompletedListener listener)
Removes the specified handshake completion listener.
|
abstract void |
setEnabledCipherSuites(String[] suites)
Sets the names of the cipher suites to be enabled.
|
abstract void |
setEnabledProtocols(String[] protocols)
Sets the names of the protocols to be enabled.
|
abstract void |
setEnableSessionCreation(boolean flag)
Sets whether new SSL sessions may be created by this socket or if
existing sessions must be reused.
|
abstract void |
setNeedClientAuth(boolean need)
Sets whether the server should require client authentication.
|
void |
setSSLParameters(SSLParameters p)
Sets various SSL handshake parameters based on the SSLParameter
argument.
|
abstract void |
setUseClientMode(boolean mode)
Sets whether this connection should act in client mode when handshaking.
|
abstract void |
setWantClientAuth(boolean want)
Sets whether the server should request client authentication.
|
void |
shutdownInput()
Unsupported for SSL because reading from an SSL socket may require
writing to the network.
|
void |
shutdownOutput()
Unsupported for SSL because writing to an SSL socket may require reading
from the network.
|
abstract void |
startHandshake()
Starts a new SSL handshake on this connection.
|
bind, close, connect, connect, getChannel, getFileDescriptor$, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, toString
protected SSLSocket()
Creates a TCP socket.
protected SSLSocket(String host, int port) throws IOException, UnknownHostException
Creates a TCP socket connection to the specified host at the specified port.
host
- the host name to connect to.port
- the port number to connect to.IOException
- if creating the socket fails.UnknownHostException
- if the specified host is not known.protected SSLSocket(InetAddress address, int port) throws IOException
Creates a TCP socket connection to the specified address at the specified port.
address
- the address to connect to.port
- the port number to connect to.IOException
- if creating the socket fails.protected SSLSocket(String host, int port, InetAddress clientAddress, int clientPort) throws IOException, UnknownHostException
Creates a TCP socket connection to the specified host at the specified port with the client side bound to the specified address and port.
host
- the host name to connect to.port
- the port number to connect to.clientAddress
- the client address to bind toclientPort
- the client port number to bind to.IOException
- if creating the socket fails.UnknownHostException
- if the specified host is not known.protected SSLSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort) throws IOException
Creates a TCP socket connection to the specified address at the specified port with the client side bound to the specified address and port.
address
- the address to connect to.port
- the port number to connect to.clientAddress
- the client address to bind to.clientPort
- the client port number to bind to.IOException
- if creating the socket fails.public void shutdownInput() throws IOException
shutdownInput
in class Socket
IOException
- if an error occurs while closing the socket input stream.SocketException
- if the input stream is already closed.public void shutdownOutput() throws IOException
shutdownOutput
in class Socket
IOException
- if an error occurs while closing the socket output stream.SocketException
- if the output stream is already closed.public abstract String[] getSupportedCipherSuites()
public abstract String[] getEnabledCipherSuites()
public abstract void setEnabledCipherSuites(String[] suites)
getSupportedCipherSuites()
are
allowed.suites
- the names of the to be enabled cipher suites.IllegalArgumentException
- if one of the cipher suite names is not supported.public abstract String[] getSupportedProtocols()
public abstract String[] getEnabledProtocols()
public abstract void setEnabledProtocols(String[] protocols)
getSupportedProtocols()
are allowed.protocols
- the names of the to be enabled protocols.IllegalArgumentException
- if one of the protocols is not supported.public abstract SSLSession getSession()
SSLSession
for this connection. If necessary, a
handshake will be initiated, in which case this method will block until the handshake
has been established. If the handshake fails, an invalid session object
will be returned.public abstract void addHandshakeCompletedListener(HandshakeCompletedListener listener)
listener
- the listener to register.IllegalArgumentException
- if listener
is null
.public abstract void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
listener
- the listener to remove.IllegalArgumentException
- if the specified listener is not registered or null
.public abstract void startHandshake() throws IOException
IOException
- if an error occurs.public abstract void setUseClientMode(boolean mode)
mode
- true
if this connection should act in client mode,
false
if not.public abstract boolean getUseClientMode()
public abstract void setNeedClientAuth(boolean need)
client mode
.
Client authentication is one of the following:
setWantClientAuth(boolean)
.public abstract void setWantClientAuth(boolean want)
setNeedClientAuth(boolean)
this won't stop the negotiation if the client
doesn't authenticate. This does not apply to sockets in client mode
.The client authentication is one of:
setNeedClientAuth(boolean)
.public abstract boolean getNeedClientAuth()
client
mode
.public abstract boolean getWantClientAuth()
client mode
.public abstract void setEnableSessionCreation(boolean flag)
flag
is false and there are
no sessions to resume, handshaking will fail.flag
- true
if new sessions may be created.public abstract boolean getEnableSessionCreation()
true
if new sessions may be created, otherwise
false
.public SSLParameters getSSLParameters()
public void setSSLParameters(SSLParameters p)