public class SecureNioChannel extends NioChannel
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected boolean |
closing |
protected boolean |
handshakeComplete |
protected SSLEngineResult.HandshakeStatus |
handshakeStatus |
protected ByteBuffer |
netInBuffer |
protected ByteBuffer |
netOutBuffer |
protected NioSelectorPool |
pool |
protected boolean |
sniComplete |
protected SSLEngine |
sslEngine |
bufHandler, emptyBuf, sc, socketWrapper| Constructor and Description |
|---|
SecureNioChannel(SocketBufferHandler bufHandler,
NioSelectorPool pool,
NioEndpoint endpoint) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Sends an SSL close message, will not physically close the connection here.
|
void |
close(boolean force)
Close the connection.
|
boolean |
flush(boolean block,
Selector s,
long timeout)
Flush the channel.
|
protected boolean |
flush(ByteBuffer buf)
Flushes the buffer to the network, non blocking
|
boolean |
flushOutbound()
Return true if the buffer wrote data.
|
void |
free()
Free the channel memory
|
ByteBuffer |
getEmptyBuf() |
int |
getOutboundRemaining() |
SSLEngine |
getSslEngine() |
SSLSupport |
getSSLSupport() |
int |
handshake(boolean read,
boolean write)
Performs SSL handshake, non blocking, but performs NEED_TASK on the same
thread.
|
protected SSLEngineResult |
handshakeUnwrap(boolean doread)
Perform handshake unwrap
|
protected SSLEngineResult |
handshakeWrap(boolean doWrite)
Performs the WRAP function
|
boolean |
isClosing() |
boolean |
isHandshakeComplete() |
int |
read(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
|
long |
read(ByteBuffer[] dsts,
int offset,
int length) |
void |
rehandshake(long timeout)
Force a blocking handshake to take place for this key.
|
void |
reset(SocketChannel channel,
NioEndpoint.NioSocketWrapper socketWrapper)
Reset the channel
|
protected SSLEngineResult.HandshakeStatus |
tasks()
Executes all the tasks needed on the same thread.
|
int |
write(ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
|
long |
write(ByteBuffer[] srcs,
int offset,
int length) |
checkInterruptStatus, getAppReadBufHandler, getBufHandler, getIOChannel, isOpen, read, setAppReadBufHandler, toString, writeprotected ByteBuffer netInBuffer
protected ByteBuffer netOutBuffer
protected SSLEngine sslEngine
protected boolean sniComplete
protected boolean handshakeComplete
protected SSLEngineResult.HandshakeStatus handshakeStatus
protected boolean closed
protected boolean closing
protected NioSelectorPool pool
public SecureNioChannel(SocketBufferHandler bufHandler, NioSelectorPool pool, NioEndpoint endpoint)
public void reset(SocketChannel channel, NioEndpoint.NioSocketWrapper socketWrapper) throws IOException
NioChannelreset in class NioChannelchannel - the socket channelsocketWrapper - the socket wrapperIOException - If a problem was encountered resetting the channelpublic void free()
NioChannelfree in class NioChannelpublic boolean flush(boolean block,
Selector s,
long timeout)
throws IOException
flush in class NioChannelblock - Should a blocking write be used?s - The selector to use for blocking, if null then a busy
write will be initiatedtimeout - The timeout for this write operation in milliseconds,
-1 means no timeouttrue if the network buffer has been flushed out and
is empty else falseIOException - If an I/O error occurs during the operationprotected boolean flush(ByteBuffer buf) throws IOException
buf - ByteBufferIOException - An IO error occurred writing datapublic int handshake(boolean read,
boolean write)
throws IOException
handshake in class NioChannelread - boolean - true if the underlying channel is readablewrite - boolean - true if the underlying channel is writableIOException - If an I/O error occurs during the handshake or if the
handshake fails during wrapping or unwrappingpublic void rehandshake(long timeout)
throws IOException
timeout - - timeout in milliseconds for each socket operationIOException - - if an IO exception occurs or if application or network buffers contain dataSocketTimeoutException - - if a socket operation timed outprotected SSLEngineResult.HandshakeStatus tasks()
protected SSLEngineResult handshakeWrap(boolean doWrite) throws IOException
doWrite - booleanIOException - An IO error occurredprotected SSLEngineResult handshakeUnwrap(boolean doread) throws IOException
doread - booleanIOException - An IO error occurredpublic SSLSupport getSSLSupport()
public void close()
throws IOException
close();
while (isOpen() && !myTimeoutFunction()) Thread.sleep(25);
if ( isOpen() ) close(true); //forces a close if you timed out
close in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in class NioChannelIOException - if an I/O error occursIOException - if there is data on the outgoing network buffer and
we are unable to flush itpublic void close(boolean force)
throws IOException
NioChannelclose in class NioChannelforce - Should the underlying socket be forcibly closed?IOException - If closing the secure channel fails.public int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in class NioChanneldst - The buffer into which bytes are to be transferred-1 if
the channel has reached end-of-streamIOException - If some other I/O error occursIllegalArgumentException - if the destination buffer is different
than getBufHandler().getReadBuffer()public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read in interface ScatteringByteChannelread in class NioChannelIOExceptionpublic int write(ByteBuffer src) throws IOException
write in interface WritableByteChannelwrite in class NioChannelsrc - The buffer from which bytes are to be retrievedIOException - If some other I/O error occurspublic long write(ByteBuffer[] srcs, int offset, int length) throws IOException
write in interface GatheringByteChannelwrite in class NioChannelIOExceptionpublic int getOutboundRemaining()
getOutboundRemaining in class NioChannelpublic boolean flushOutbound()
throws IOException
NioChannelflushOutbound in class NioChannelfalse for non-secure channelIOException - Never for non-secure channelpublic boolean isHandshakeComplete()
isHandshakeComplete in class NioChannelpublic boolean isClosing()
isClosing in class NioChannelpublic SSLEngine getSslEngine()
public ByteBuffer getEmptyBuf()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.