public class SecureNio2Channel extends Nio2Channel
| Modifier and Type | Class and Description |
|---|---|
static interface |
SecureNio2Channel.ApplicationBufferHandler
Callback interface to be able to expand buffers
when buffer overflow exceptions happen
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected boolean |
closing |
protected Nio2Endpoint |
endpoint |
protected boolean |
handshakeComplete |
protected SSLEngineResult.HandshakeStatus |
handshakeStatus |
protected static Log |
log |
protected ByteBuffer |
netInBuffer |
protected ByteBuffer |
netOutBuffer |
protected boolean |
readPending |
protected static StringManager |
sm |
protected SSLEngine |
sslEngine |
protected boolean |
writePending |
bufHandler, emptyBuf, sc, socket| Constructor and Description |
|---|
SecureNio2Channel(SSLEngine engine,
SecureNio2Channel.ApplicationBufferHandler bufHandler,
Nio2Endpoint endpoint0) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Sends a SSL close message, will not physically close the connection here.
|
void |
close(boolean force)
Force a close, can throw an IOException
|
Future<Boolean> |
flush()
Flush the channel.
|
int |
getBufferSize() |
SecureNio2Channel.ApplicationBufferHandler |
getBufHandler() |
ByteBuffer |
getEmptyBuf() |
AsynchronousSocketChannel |
getIOChannel() |
SSLEngine |
getSslEngine() |
int |
handshake()
Performs SSL handshake, non blocking, but performs NEED_TASK on the same thread.
|
protected int |
handshakeInternal(boolean async) |
protected SSLEngineResult |
handshakeUnwrap()
Perform handshake unwrap
|
protected SSLEngineResult |
handshakeWrap()
Performs the WRAP function
|
boolean |
isClosing() |
boolean |
isHandshakeComplete() |
Future<Integer> |
read(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
|
<A> void |
read(ByteBuffer dst,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Integer,? super A> handler) |
void |
rehandshake()
Force a blocking handshake to take place for this key.
|
void |
reset(AsynchronousSocketChannel channel,
SocketWrapper<Nio2Channel> socket)
Reset the channel
|
void |
setBufHandler(SecureNio2Channel.ApplicationBufferHandler bufHandler) |
void |
setSSLEngine(SSLEngine engine) |
protected SSLEngineResult.HandshakeStatus |
tasks()
Executes all the tasks needed on the same thread.
|
Future<Integer> |
write(ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
|
<A> void |
write(ByteBuffer[] srcs,
int offset,
int length,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Long,? super A> handler) |
<A> void |
write(ByteBuffer src,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Integer,? super A> handler) |
protected static final Log log
protected static final StringManager sm
protected ByteBuffer netInBuffer
protected ByteBuffer netOutBuffer
protected SSLEngine sslEngine
protected final Nio2Endpoint endpoint
protected boolean handshakeComplete
protected SSLEngineResult.HandshakeStatus handshakeStatus
protected boolean closed
protected boolean closing
protected volatile boolean readPending
protected volatile boolean writePending
public SecureNio2Channel(SSLEngine engine, SecureNio2Channel.ApplicationBufferHandler bufHandler, Nio2Endpoint endpoint0)
public void setSSLEngine(SSLEngine engine)
public void reset(AsynchronousSocketChannel channel, SocketWrapper<Nio2Channel> socket) throws IOException
Nio2Channelreset in class Nio2ChannelIOException - If a problem was encountered resetting the channelpublic int getBufferSize()
getBufferSize in class Nio2Channelpublic Future<Boolean> flush()
flush in class Nio2Channeltrue if the network buffer has been flushed out and
is empty else false (as a future)public int handshake()
throws IOException
handshake in class Nio2ChannelIOExceptionprotected int handshakeInternal(boolean async)
throws IOException
IOExceptionpublic void rehandshake()
throws IOException
IOException - - 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() throws IOException
IOExceptionprotected SSLEngineResult handshakeUnwrap() throws IOException
IOExceptionpublic 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 AsynchronousChannelclose in interface Channelclose in class Nio2ChannelIOException - 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
close in class Nio2Channelforce - booleanIOExceptionpublic Future<Integer> read(ByteBuffer dst)
read in interface AsynchronousByteChannelread in class Nio2Channeldst - The buffer into which bytes are to be transferredIllegalStateException - if the handshake was not completedpublic Future<Integer> write(ByteBuffer src)
write in interface AsynchronousByteChannelwrite in class Nio2Channelsrc - The buffer from which bytes are to be retrievedpublic <A> void read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer,? super A> handler)
read in class Nio2Channelpublic <A> void write(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer,? super A> handler)
write in class Nio2Channelpublic <A> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long,? super A> handler)
write in class Nio2Channelpublic SecureNio2Channel.ApplicationBufferHandler getBufHandler()
getBufHandler in class Nio2Channelpublic boolean isHandshakeComplete()
isHandshakeComplete in class Nio2Channelpublic boolean isClosing()
isClosing in class Nio2Channelpublic SSLEngine getSslEngine()
public ByteBuffer getEmptyBuf()
public void setBufHandler(SecureNio2Channel.ApplicationBufferHandler bufHandler)
public AsynchronousSocketChannel getIOChannel()
getIOChannel in class Nio2ChannelCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.