|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tomcat.util.net.NioChannel org.apache.tomcat.util.net.SecureNioChannel
public class SecureNioChannel
Implementation of a secure socket channel
Nested Class Summary | |
---|---|
static interface |
SecureNioChannel.ApplicationBufferHandler
Callback interface to be able to expand buffers when buffer overflow exceptions happen |
Field Summary | |
---|---|
protected boolean |
closed
|
protected boolean |
closing
|
protected boolean |
handshakeComplete
|
protected SSLEngineResult.HandshakeStatus |
handshakeStatus
|
protected ByteBuffer |
netInBuffer
|
protected ByteBuffer |
netOutBuffer
|
protected NioSelectorPool |
pool
|
protected SSLEngine |
sslEngine
|
Fields inherited from class org.apache.tomcat.util.net.NioChannel |
---|
bufHandler, emptyBuf, poller, sc, sendFile |
Constructor Summary | |
---|---|
SecureNioChannel(SocketChannel channel,
SSLEngine engine,
SecureNioChannel.ApplicationBufferHandler bufHandler,
NioSelectorPool pool)
|
Method Summary | |
---|---|
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 |
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 |
int |
getBufferSize()
|
SecureNioChannel.ApplicationBufferHandler |
getBufHandler()
getBufHandler |
ByteBuffer |
getEmptyBuf()
|
SocketChannel |
getIOChannel()
getIOChannel |
int |
getOutboundRemaining()
|
SSLEngine |
getSslEngine()
|
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()
isClosing |
boolean |
isHandshakeComplete()
isInitHandshakeComplete |
int |
read(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer. |
void |
rehandshake(long timeout)
Force a blocking handshake to take place for this key. |
void |
reset()
|
void |
reset(SSLEngine engine)
|
void |
setBufHandler(SecureNioChannel.ApplicationBufferHandler bufHandler)
|
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. |
Methods inherited from class org.apache.tomcat.util.net.NioChannel |
---|
getAttachment, getPoller, isOpen, isSendFile, setIOChannel, setPoller, setSendFile, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ByteBuffer netInBuffer
protected ByteBuffer netOutBuffer
protected SSLEngine sslEngine
protected boolean handshakeComplete
protected SSLEngineResult.HandshakeStatus handshakeStatus
protected boolean closed
protected boolean closing
protected NioSelectorPool pool
Constructor Detail |
---|
public SecureNioChannel(SocketChannel channel, SSLEngine engine, SecureNioChannel.ApplicationBufferHandler bufHandler, NioSelectorPool pool) throws IOException
IOException
Method Detail |
---|
public void reset(SSLEngine engine) throws IOException
IOException
public void reset() throws IOException
reset
in class NioChannel
IOException
public int getBufferSize()
getBufferSize
in class NioChannel
public boolean flush(boolean block, Selector s, long timeout) throws IOException
flush
in class NioChannel
block
- Should a blocking write be used?s
- timeout
-
true
if the network buffer has been flushed out and
is empty else false
IOException
protected boolean flush(ByteBuffer buf) throws IOException
buf
- ByteBuffer
IOException
public int handshake(boolean read, boolean write) throws IOException
handshake
in class NioChannel
read
- boolean - true if the underlying channel is readablewrite
- boolean - true if the underlying channel is writable
IOException
public void rehandshake(long timeout) throws IOException
timeout
- - timeout in milliseconds for each socket operation
IOException
- - if an IO exception occurs or if application or network buffers contain data
SocketTimeoutException
- - if a socket operation timed outprotected SSLEngineResult.HandshakeStatus tasks()
protected SSLEngineResult handshakeWrap(boolean doWrite) throws IOException
doWrite
- boolean
IOException
protected SSLEngineResult handshakeUnwrap(boolean doread) throws IOException
doread
- boolean
IOException
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 Closeable
close
in interface Channel
close
in class NioChannel
IOException
- if an I/O error occurs
IOException
- if there is data on the outgoing network buffer and we are unable to flush it
TODO Implement this java.io.Closeable methodpublic void close(boolean force) throws IOException
close
in class NioChannel
force
- boolean
IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in class NioChannel
dst
- The buffer into which bytes are to be transferred
IOException
- If some other I/O error occurs
IllegalArgumentException
- if the destination buffer is different than bufHandler.getReadBuffer()
TODO Implement this java.nio.channels.ReadableByteChannel methodpublic int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
write
in class NioChannel
src
- The buffer from which bytes are to be retrieved
IOException
- If some other I/O error occurs
TODO Implement this java.nio.channels.WritableByteChannel methodpublic int getOutboundRemaining()
getOutboundRemaining
in class NioChannel
public boolean flushOutbound() throws IOException
NioChannel
flushOutbound
in class NioChannel
IOException
public SecureNioChannel.ApplicationBufferHandler getBufHandler()
NioChannel
getBufHandler
in class NioChannel
public boolean isHandshakeComplete()
NioChannel
isHandshakeComplete
in class NioChannel
public boolean isClosing()
NioChannel
isClosing
in class NioChannel
public SSLEngine getSslEngine()
public ByteBuffer getEmptyBuf()
public void setBufHandler(SecureNioChannel.ApplicationBufferHandler bufHandler)
public SocketChannel getIOChannel()
NioChannel
getIOChannel
in class NioChannel
|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |