public class SecureNioChannel extends NioChannel
NioChannel.ClosedNioChannel| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected boolean |
closing |
protected boolean |
handshakeComplete |
protected javax.net.ssl.SSLEngineResult.HandshakeStatus |
handshakeStatus |
protected java.nio.ByteBuffer |
netInBuffer |
protected java.nio.ByteBuffer |
netOutBuffer |
protected NioSelectorPool |
pool |
protected boolean |
sniComplete |
protected javax.net.ssl.SSLEngine |
sslEngine |
bufHandler, emptyBuf, sc, socketWrapper| Constructor and Description |
|---|
SecureNioChannel(java.nio.channels.SocketChannel channel,
SocketBufferHandler bufHandler,
NioSelectorPool pool,
NioEndpoint endpoint) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Sends a SSL close message, will not physically close the connection here.
|
void |
close(boolean force)
Close the connection.
|
boolean |
flush(boolean block,
java.nio.channels.Selector s,
long timeout)
Flush the channel.
|
protected boolean |
flush(java.nio.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
|
java.nio.ByteBuffer |
getEmptyBuf() |
int |
getOutboundRemaining() |
javax.net.ssl.SSLEngine |
getSslEngine() |
int |
handshake(boolean read,
boolean write)
Performs SSL handshake, non blocking, but performs NEED_TASK on the same
thread.
|
protected javax.net.ssl.SSLEngineResult |
handshakeUnwrap(boolean doread)
Perform handshake unwrap
|
protected javax.net.ssl.SSLEngineResult |
handshakeWrap(boolean doWrite)
Performs the WRAP function
|
boolean |
isClosing() |
boolean |
isHandshakeComplete() |
int |
read(java.nio.ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
|
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length) |
void |
rehandshake(long timeout)
Force a blocking handshake to take place for this key.
|
void |
reset()
Reset the channel
|
protected javax.net.ssl.SSLEngineResult.HandshakeStatus |
tasks()
Executes all the tasks needed on the same thread.
|
int |
write(java.nio.ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
|
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length) |
checkInterruptStatus, getAppReadBufHandler, getBufHandler, getIOChannel, isOpen, read, setAppReadBufHandler, setIOChannel, toString, writeprotected java.nio.ByteBuffer netInBuffer
protected java.nio.ByteBuffer netOutBuffer
protected javax.net.ssl.SSLEngine sslEngine
protected boolean sniComplete
protected boolean handshakeComplete
protected javax.net.ssl.SSLEngineResult.HandshakeStatus handshakeStatus
protected boolean closed
protected boolean closing
protected NioSelectorPool pool
public SecureNioChannel(java.nio.channels.SocketChannel channel,
SocketBufferHandler bufHandler,
NioSelectorPool pool,
NioEndpoint endpoint)
public void reset()
throws java.io.IOException
NioChannelreset in class NioChanneljava.io.IOException - If a problem was encountered resetting the channelpublic void free()
NioChannelfree in class NioChannelpublic boolean flush(boolean block,
java.nio.channels.Selector s,
long timeout)
throws java.io.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 falsejava.io.IOException - If an I/O error occurs during the operationprotected boolean flush(java.nio.ByteBuffer buf)
throws java.io.IOException
buf - ByteBufferjava.io.IOException - An IO error occurred writing datapublic int handshake(boolean read,
boolean write)
throws java.io.IOException
handshake in class NioChannelread - boolean - true if the underlying channel is readablewrite - boolean - true if the underlying channel is writablejava.io.IOException - If an I/O error occurs during the handshake or if the
handshake fails during wrapping or unwrappingpublic void rehandshake(long timeout)
throws java.io.IOException
timeout - - timeout in milliseconds for each socket operationjava.io.IOException - - if an IO exception occurs or if application or network buffers contain datajava.net.SocketTimeoutException - - if a socket operation timed outprotected javax.net.ssl.SSLEngineResult.HandshakeStatus tasks()
protected javax.net.ssl.SSLEngineResult handshakeWrap(boolean doWrite)
throws java.io.IOException
doWrite - booleanjava.io.IOException - An IO error occurredprotected javax.net.ssl.SSLEngineResult handshakeUnwrap(boolean doread)
throws java.io.IOException
doread - booleanjava.io.IOException - An IO error occurredpublic void close()
throws java.io.IOException
close();
while (isOpen() && !myTimeoutFunction()) Thread.sleep(25);
if ( isOpen() ) close(true); //forces a close if you timed out
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in class NioChanneljava.io.IOException - if an I/O error occursjava.io.IOException - if there is data on the outgoing network buffer and
we are unable to flush itpublic void close(boolean force)
throws java.io.IOException
NioChannelclose in class NioChannelforce - Should the underlying socket be forcibly closed?java.io.IOException - If closing the secure channel fails.public int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelread in class NioChanneldst - The buffer into which bytes are to be transferredjava.io.IOException - If some other I/O error occursjava.lang.IllegalArgumentException - if the destination buffer is different
than getBufHandler().getReadBuffer()public long read(java.nio.ByteBuffer[] dsts,
int offset,
int length)
throws java.io.IOException
read in interface java.nio.channels.ScatteringByteChannelread in class NioChanneljava.io.IOExceptionpublic int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.WritableByteChannelwrite in class NioChannelsrc - The buffer from which bytes are to be retrievedjava.io.IOException - If some other I/O error occurspublic long write(java.nio.ByteBuffer[] srcs,
int offset,
int length)
throws java.io.IOException
write in interface java.nio.channels.GatheringByteChannelwrite in class NioChanneljava.io.IOExceptionpublic int getOutboundRemaining()
getOutboundRemaining in class NioChannelpublic boolean flushOutbound()
throws java.io.IOException
NioChannelflushOutbound in class NioChannelfalse for non-secure channeljava.io.IOException - Never for non-secure channelpublic boolean isHandshakeComplete()
isHandshakeComplete in class NioChannelpublic boolean isClosing()
isClosing in class NioChannelpublic javax.net.ssl.SSLEngine getSslEngine()
public java.nio.ByteBuffer getEmptyBuf()
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.