public abstract class SSLEngine extends Object
Modifier | Constructor and Description |
---|---|
protected |
SSLEngine()
Creates a new
SSLEngine instance. |
protected |
SSLEngine(String host,
int port)
Creates a new
SSLEngine instance with the specified host and
port. |
Modifier and Type | Method and Description |
---|---|
abstract void |
beginHandshake()
Initiates a handshake on this engine.
|
abstract void |
closeInbound()
Notifies this engine instance that no more inbound network data will be
sent to this engine.
|
abstract void |
closeOutbound()
Notifies this engine instance that no more outbound application data will
be sent to this engine.
|
abstract Runnable |
getDelegatedTask()
Returns a delegate task for this engine instance.
|
abstract String[] |
getEnabledCipherSuites()
Returns the SSL cipher suite names that are enabled in this engine
instance.
|
abstract String[] |
getEnabledProtocols()
Returns the protocol version names that are enabled in this engine
instance.
|
abstract boolean |
getEnableSessionCreation()
Returns whether new SSL sessions may be established by this engine.
|
abstract SSLEngineResult.HandshakeStatus |
getHandshakeStatus()
Returns the status of the handshake of this engine instance.
|
abstract boolean |
getNeedClientAuth()
Returns whether this engine instance will require client authentication.
|
String |
getPeerHost()
Returns the name of the peer host.
|
int |
getPeerPort()
Returns the port number of the peer host.
|
abstract SSLSession |
getSession()
Returns the SSL session for this engine instance.
|
SSLParameters |
getSSLParameters()
Returns a new SSLParameters based on this SSLSocket's current
cipher suites, protocols, and client authentication settings.
|
abstract String[] |
getSupportedCipherSuites()
Returns the SSL cipher suite names that are supported by this engine.
|
abstract String[] |
getSupportedProtocols()
Returns the protocol names that are supported by this engine.
|
abstract boolean |
getUseClientMode()
Returns whether this engine is set to act in client mode when
handshaking.
|
abstract boolean |
getWantClientAuth()
Returns whether this engine will request client authentication.
|
abstract boolean |
isInboundDone()
Returns whether no more inbound data will be accepted by this engine.
|
abstract boolean |
isOutboundDone()
Returns whether no more outbound data will be produced by this engine.
|
abstract void |
setEnabledCipherSuites(String[] suites)
Sets the SSL cipher suite names that should be enabled in this engine
instance.
|
abstract void |
setEnabledProtocols(String[] protocols)
Sets the protocol version names that should be enabled in this engine
instance.
|
abstract void |
setEnableSessionCreation(boolean flag)
Sets whether new SSL sessions may be established by this engine instance.
|
abstract void |
setNeedClientAuth(boolean need)
Sets whether this engine must 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 engine should act in client (or server) mode when
handshaking.
|
abstract void |
setWantClientAuth(boolean want)
Sets whether this engine should request client authentication.
|
SSLEngineResult |
unwrap(ByteBuffer src,
ByteBuffer dst)
Decodes the incoming network data buffer into the application data
buffer.
|
SSLEngineResult |
unwrap(ByteBuffer src,
ByteBuffer[] dsts)
Decodes the incoming network data buffer into the application data
buffers.
|
abstract SSLEngineResult |
unwrap(ByteBuffer src,
ByteBuffer[] dsts,
int offset,
int length)
Decodes the incoming network data buffer into application data buffers.
|
SSLEngineResult |
wrap(ByteBuffer[] srcs,
ByteBuffer dst)
Encodes the outgoing application data buffers into the network data
buffer.
|
abstract SSLEngineResult |
wrap(ByteBuffer[] srcs,
int offset,
int length,
ByteBuffer dst)
Encodes the outgoing application data buffers into the network data
buffer.
|
SSLEngineResult |
wrap(ByteBuffer src,
ByteBuffer dst)
Encodes the outgoing application data buffer into the network data
buffer.
|
protected SSLEngine()
SSLEngine
instance.protected SSLEngine(String host, int port)
SSLEngine
instance with the specified host and
port.host
- the name of the host.port
- the port of the host.public String getPeerHost()
null
if none is available.public int getPeerPort()
-1
is none is
available.public abstract void beginHandshake() throws SSLException
Calling this method is not needed for the initial handshake: it will be
called by wrap
or unwrap
if the initial handshake has not
been started yet.
SSLException
- if starting the handshake fails.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public abstract void closeInbound() throws SSLException
SSLException
- if this engine did not receive a needed protocol specific
close notification message from the peer.public abstract void closeOutbound()
public abstract Runnable getDelegatedTask()
SSLEngineResult
instances returned by this engine may indicate
that a delegated task result is needed. In this case the
run
method of the returned Runnable
delegated task must be called.null
if none are available.public abstract String[] getEnabledCipherSuites()
public abstract String[] getEnabledProtocols()
public abstract boolean getEnableSessionCreation()
true
if new session may be established, false
if
existing sessions must be reused.public abstract SSLEngineResult.HandshakeStatus getHandshakeStatus()
public abstract boolean getNeedClientAuth()
true
if this engine will require client authentication,
false
if no client authentication is needed.public abstract SSLSession getSession()
public abstract String[] getSupportedCipherSuites()
setEnabledCipherSuites(String[])
.public abstract String[] getSupportedProtocols()
setEnabledProtocols(String[])
.public abstract boolean getUseClientMode()
true
if the engine is set to do handshaking in client
mode.public abstract boolean getWantClientAuth()
true
if client authentication will be requested,
false
otherwise.public abstract boolean isInboundDone()
true
if no more inbound data will be accepted by this
engine, false
otherwise.public abstract boolean isOutboundDone()
true
if no more outbound data will be producted by this
engine, otherwise
false.public abstract void setEnabledCipherSuites(String[] suites)
getSupportedCipherSuites()
are allowed.suites
- the SSL cipher suite names to be enabled.IllegalArgumentException
- if one of the specified cipher suites is not supported, or if
suites
is null
.public abstract void setEnabledProtocols(String[] protocols)
getSupportedProtocols()
are
allowed.protocols
- the protocol version names to be enabled.IllegalArgumentException
- if one of the protocol version names is not supported, or if
protocols
is null
.public abstract void setEnableSessionCreation(boolean flag)
flag
- true
if new SSL sessions may be established,
false
if existing SSL sessions must be reused.public abstract void setNeedClientAuth(boolean need)
setWantClientAuth(boolean)
.need
- true
if client authentication is required,
false
if no authentication is needed.public abstract void setUseClientMode(boolean mode)
mode
- true
if this engine should act in client mode,
false
if not.IllegalArgumentException
- if this method is called after starting the initial
handshake.public abstract void setWantClientAuth(boolean want)
setNeedClientAuth(boolean)
.want
- true
if client authentication should be requested,
false
if no authentication is needed.public abstract SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length) throws SSLException
src
- the buffer with incoming network datadsts
- the array of destination buffers for incoming application
data.offset
- the offset in the array of destination buffers to which data
is to be transferred.length
- the maximum number of destination buffers to be used.SSLException
- if a problem occurred while processing the data.IndexOutOfBoundsException
- if length
is greater than
dsts.length - offset
.ReadOnlyBufferException
- if one of the destination buffers is read-only.IllegalArgumentException
- if src
, dsts
, or one of the entries in
dsts
is null
.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public abstract SSLEngineResult wrap(ByteBuffer[] srcs, int offset, int length, ByteBuffer dst) throws SSLException
srcs
- the array of source buffers of outgoing application data.offset
- the offset in the array of source buffers from which data is
to be retrieved.length
- the maximum number of source buffers to be used.dst
- the destination buffer for network data.SSLException
- if a problem occurred while processing the data.IndexOutOfBoundsException
- if length
is greater than
srcs.length - offset
.ReadOnlyBufferException
- if the destination buffer is readonly.IllegalArgumentException
- if srcs
, dst
, or one the entries in
srcs
is null
.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException
src
- the buffer with incoming network datadst
- the destination buffer for incoming application data.SSLException
- if a problem occurred while processing the data.ReadOnlyBufferException
- if one of the destination buffers is read-only.IllegalArgumentException
- if src
or dst
is null
.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts) throws SSLException
src
- the buffer with incoming network datadsts
- the array of destination buffers for incoming application
data.SSLException
- if a problem occurred while processing the data.ReadOnlyBufferException
- if one of the destination buffers is read-only.IllegalArgumentException
- if src
or dsts
is null
.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public SSLEngineResult wrap(ByteBuffer[] srcs, ByteBuffer dst) throws SSLException
srcs
- the array of source buffers of outgoing application data.dst
- the destination buffer for network data.SSLException
- if a problem occurred while processing the data.ReadOnlyBufferException
- if the destination buffer is readonly.IllegalArgumentException
- if srcs
or dst
is null
.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException
src
- the source buffers of outgoing application data.dst
- the destination buffer for network data.SSLException
- if a problem occurred while processing the data.ReadOnlyBufferException
- if the destination buffer is readonly.IllegalArgumentException
- if src
or dst
is null
.IllegalStateException
- if the engine does not have all the needed settings (e.g.
client/server mode not set).public SSLParameters getSSLParameters()
public void setSSLParameters(SSLParameters p)