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 static Log | 
log  | 
protected java.nio.ByteBuffer | 
netInBuffer  | 
protected java.nio.ByteBuffer | 
netOutBuffer  | 
protected boolean | 
readPending  | 
protected static StringManager | 
sm  | 
protected javax.net.ssl.SSLEngine | 
sslEngine  | 
protected boolean | 
writePending  | 
bufHandler, emptyBuf, sc, socket| Constructor and Description | 
|---|
SecureNio2Channel(javax.net.ssl.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 
 | 
java.util.concurrent.Future<java.lang.Boolean> | 
flush()
Flush the channel. 
 | 
int | 
getBufferSize()  | 
SecureNio2Channel.ApplicationBufferHandler | 
getBufHandler()  | 
java.nio.ByteBuffer | 
getEmptyBuf()  | 
javax.net.ssl.SSLEngine | 
getSslEngine()  | 
int | 
handshake()
Performs SSL handshake, non blocking, but performs NEED_TASK on the same
 thread. 
 | 
protected int | 
handshakeInternal(boolean async)  | 
protected javax.net.ssl.SSLEngineResult | 
handshakeUnwrap()
Perform handshake unwrap 
 | 
protected javax.net.ssl.SSLEngineResult | 
handshakeWrap()
Performs the WRAP function 
 | 
boolean | 
isClosing()  | 
boolean | 
isHandshakeComplete()  | 
java.util.concurrent.Future<java.lang.Integer> | 
read(java.nio.ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer. 
 | 
<A> void | 
read(java.nio.ByteBuffer dst,
    long timeout,
    java.util.concurrent.TimeUnit unit,
    A attachment,
    java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)  | 
void | 
rehandshake()
Force a blocking handshake to take place for this key. 
 | 
void | 
reset(java.nio.channels.AsynchronousSocketChannel channel,
     SocketWrapper<Nio2Channel> socket)
Reset the channel 
 | 
void | 
setBufHandler(SecureNio2Channel.ApplicationBufferHandler bufHandler)  | 
void | 
setSSLEngine(javax.net.ssl.SSLEngine engine)  | 
protected javax.net.ssl.SSLEngineResult.HandshakeStatus | 
tasks()
Executes all the tasks needed on the same thread. 
 | 
java.util.concurrent.Future<java.lang.Integer> | 
write(java.nio.ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer. 
 | 
<A> void | 
write(java.nio.ByteBuffer[] srcs,
     int offset,
     int length,
     long timeout,
     java.util.concurrent.TimeUnit unit,
     A attachment,
     java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler)  | 
<A> void | 
write(java.nio.ByteBuffer src,
     long timeout,
     java.util.concurrent.TimeUnit unit,
     A attachment,
     java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)  | 
getIOChannel, getSocket, isOpen, read, toString, writeprotected static final Log log
protected static final StringManager sm
protected java.nio.ByteBuffer netInBuffer
protected java.nio.ByteBuffer netOutBuffer
protected javax.net.ssl.SSLEngine sslEngine
protected final Nio2Endpoint endpoint
protected boolean closed
protected boolean closing
protected volatile boolean readPending
protected volatile boolean writePending
public SecureNio2Channel(javax.net.ssl.SSLEngine engine,
                 SecureNio2Channel.ApplicationBufferHandler bufHandler,
                 Nio2Endpoint endpoint0)
public void setSSLEngine(javax.net.ssl.SSLEngine engine)
public void reset(java.nio.channels.AsynchronousSocketChannel channel,
         SocketWrapper<Nio2Channel> socket)
           throws java.io.IOException
Nio2Channelreset in class Nio2Channeljava.io.IOException - If a problem was encountered resetting the channelpublic int getBufferSize()
getBufferSize in class Nio2Channelpublic java.util.concurrent.Future<java.lang.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 java.io.IOException
The return for this operation is 0 if the handshake is complete and a positive value if it is not complete. In the event of a positive value coming back, the appropriate read/write will already have been called with an appropriate CompletionHandler.
handshake in class Nio2Channeljava.io.IOExceptionprotected int handshakeInternal(boolean async)
                         throws java.io.IOException
java.io.IOExceptionpublic void rehandshake()
                 throws java.io.IOException
java.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()
                                               throws java.io.IOException
java.io.IOExceptionprotected javax.net.ssl.SSLEngineResult handshakeUnwrap()
                                                 throws java.io.IOException
java.io.IOExceptionpublic 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.AsynchronousChannelclose in interface java.nio.channels.Channelclose in class Nio2Channeljava.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
close in class Nio2Channelforce - booleanjava.io.IOExceptionpublic java.util.concurrent.Future<java.lang.Integer> read(java.nio.ByteBuffer dst)
read in interface java.nio.channels.AsynchronousByteChannelread in class Nio2Channeldst - The buffer into which bytes are to be transferredjava.lang.IllegalStateException - if the handshake was not completedpublic java.util.concurrent.Future<java.lang.Integer> write(java.nio.ByteBuffer src)
write in interface java.nio.channels.AsynchronousByteChannelwrite in class Nio2Channelsrc - The buffer from which bytes are to be retrievedpublic <A> void read(java.nio.ByteBuffer dst,
            long timeout,
            java.util.concurrent.TimeUnit unit,
            A attachment,
            java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
read in class Nio2Channelpublic <A> void write(java.nio.ByteBuffer src,
             long timeout,
             java.util.concurrent.TimeUnit unit,
             A attachment,
             java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
write in class Nio2Channelpublic <A> void write(java.nio.ByteBuffer[] srcs,
             int offset,
             int length,
             long timeout,
             java.util.concurrent.TimeUnit unit,
             A attachment,
             java.nio.channels.CompletionHandler<java.lang.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 javax.net.ssl.SSLEngine getSslEngine()
public java.nio.ByteBuffer getEmptyBuf()
public void setBufHandler(SecureNio2Channel.ApplicationBufferHandler bufHandler)
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.