public interface SocketIF
SocketChannel
implementations. These can be either of a PlainSocket
implementation or a SecureSocket
implementation. The interface is needed to envelop the underlying
SocketChannel
implementations such that the secure channel can
perform handshaking, encryption and decryption of the data, as only the
Oracle SocketChannel
implementation is allowed to be associated with
a Selector
.
Modifier and Type | Method and Description |
---|---|
void |
close()
Pass-through implementation of
AbstractInterruptibleChannel.close() |
java.nio.channels.SelectableChannel |
configureBlocking(boolean block)
Pass-through implementation of
AbstractSelectableChannel.configureBlocking(boolean block) |
boolean |
connect(java.net.SocketAddress remote)
Pass-through implementation of
SocketChannel.connect(SocketAddress remote) |
boolean |
finishConnect()
Pass-through implementation of
SocketChannel.finishConnect() |
java.nio.channels.SocketChannel |
getSocket()
Returns the underlying
SocketChannel . |
boolean |
handshakePending()
Used to identify whether the handshaking performed from the underlying
SSLEngine is still pending. |
void |
initHandshake()
Initialize SSL/TLS handshaking.
|
void |
invalidateSession()
Invalidate the current
SSLSession . |
void |
processHandshake()
Performs SSL/TLS handshaking.
|
int |
read(java.nio.ByteBuffer buffer)
Pass-through implementation of
SocketChannel.read(ByteBuffer buffer) |
java.nio.channels.SelectionKey |
register(java.nio.channels.Selector sel,
int ops)
Pass-through implementation of
SelectableChannel.register(Selector sel, int ops) |
void |
setTaskPending(boolean taskPending)
Sets whether or not there is an
SSLEngine task
pending, during an SSL/TLS handshake. |
void |
updateResult()
Update the
SSLEngineResult and
setTaskPending(boolean) to false. |
int |
write(java.nio.ByteBuffer buffer)
Pass-through implementation of
SocketChannel.write(ByteBuffer buffer) |
java.nio.channels.SocketChannel getSocket()
SocketChannel
. This is done in order to
register the current socket with a Selector
, as only the
SocketChannel
implementation is allowed to be associated with a
Selector
.boolean connect(java.net.SocketAddress remote) throws java.io.IOException
SocketChannel.connect(SocketAddress remote)
remote
- The remote address to which this channel is to be connectedjava.io.IOException
- Propagated exceptions from the underlying
SocketChannel.connect(SocketAddress remote)
implementation.boolean finishConnect() throws java.io.IOException
SocketChannel.finishConnect()
java.io.IOException
- Propagated exceptions from the underlying
SocketChannel.finishConnect()
implementation.java.nio.channels.SelectionKey register(java.nio.channels.Selector sel, int ops) throws java.nio.channels.ClosedChannelException
SelectableChannel.register(Selector sel, int ops)
sel
- The selector with which this channel is to be registeredops
- The interest set for the resulting keyjava.nio.channels.ClosedChannelException
- Propagated exceptions from the underlying
SelectableChannel.register(Selector sel, int ops)
implementation.java.nio.channels.SelectableChannel configureBlocking(boolean block) throws java.io.IOException
AbstractSelectableChannel.configureBlocking(boolean block)
block
- If true then this channel will be placed in blocking mode;
if false then it will be placed in non-blocking modejava.io.IOException
- Propagated exceptions from the underlying
AbstractSelectableChannel.configureBlocking(boolean block)
implementation.int read(java.nio.ByteBuffer buffer) throws java.io.IOException
SocketChannel.read(ByteBuffer buffer)
buffer
- The buffer into which bytes are to be transferredjava.io.IOException
- Propagated exceptions from the underlying
SocketChannel.read(ByteBuffer buffer)
implementation.int write(java.nio.ByteBuffer buffer) throws java.io.IOException
SocketChannel.write(ByteBuffer buffer)
buffer
- java.io.IOException
- Propagated exceptions from the underlying
SocketChannel.write(ByteBuffer buffer)
implementation.void close() throws java.io.IOException
AbstractInterruptibleChannel.close()
java.io.IOException
- Propagated exceptions from the underlying
SocketChannel.close() implementation.void invalidateSession()
SSLSession
. This method
could be periodically used via a Timeout
to perform SSL/TLS
session rotation if needed. This method has NO EFFECT for a
PlainSocket
implementation.
void initHandshake() throws java.io.IOException
This method has NO EFFECT for a
PlainSocket
implementation.
java.io.IOException
- propagated exceptions from
processHandshake()
javax.net.ssl.SSLException
- if there is an SSL/TLS problem with
the call to the underlying
SSLEngine.beginHandshake()
.SecureSocket.initHandshake()
void updateResult()
SSLEngineResult
and
setTaskPending(boolean)
to false. This method has NO EFFECT
for a PlainSocket
implementation.
SecureSocket.updateResult()
boolean handshakePending()
SSLEngine
is still pending. This method has NO
EFFECT for a PlainSocket
implementation.
PlainSocket
implementationSecureSocket.handshakePending()
void setTaskPending(boolean taskPending)
SSLEngine
task
pending, during an SSL/TLS handshake. This method has NO EFFECT for a
PlainSocket
implementation.
taskPending
- Set whether or not there is a
SSLEngine
task pending for the
SSLEngine
associated with the underlying
SocketChannel
. Has no effect in a single threaded implementation.SecureSocket.setTaskPending(boolean)
void processHandshake() throws java.io.IOException
This method has NO EFFECT for a
PlainSocket
implementation.
java.io.IOException
- If there is an underlying IOException while
performing the handshakejavax.net.ssl.SSLException
- If there is an exception thrown by the
underlying SSLEngine
while performing the handshakeSecureSocket.processHandshake()