public class SSLHandler
extends java.lang.Object
Each connection has a SSLEngine that is used through the lifetime of the connection. We allocate byte buffers for use as the outbound and inbound network buffers. These buffers handle all of the intermediary data for the SSL connection. To make things easy, we'll require outNetBuffer be completely flushed before trying to wrap any more data.
Constructor and Description |
---|
SSLHandler(SSLFilter parent,
javax.net.ssl.SSLContext sslc,
org.apache.mina.common.IoSession session)
Constuctor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
closeOutbound()
Start SSL shutdown process.
|
static org.apache.mina.common.ByteBuffer |
copy(java.nio.ByteBuffer src)
Creates a new Mina byte buffer that is a deep copy of the remaining bytes
in the given buffer (between index buf.position() and buf.limit())
|
void |
destroy()
Release allocated ByteBuffers.
|
void |
encrypt(java.nio.ByteBuffer src)
Encrypt provided buffer.
|
void |
flushPreHandshakeEvents() |
void |
flushScheduledEvents() |
java.nio.ByteBuffer |
getAppBuffer()
Get decrypted application data.
|
java.nio.ByteBuffer |
getOutNetBuffer()
Get encrypted data to be sent.
|
SSLFilter |
getParent() |
org.apache.mina.common.IoSession |
getSession() |
void |
handshake(org.apache.mina.common.IoFilter.NextFilter nextFilter)
Perform any handshaking processing.
|
void |
init() |
boolean |
isHandshakeComplete()
Check if handshake is completed.
|
boolean |
isInboundDone() |
boolean |
isOutboundDone() |
boolean |
isWritingEncryptedData()
Check we are writing encrypted data.
|
void |
messageReceived(org.apache.mina.common.IoFilter.NextFilter nextFilter,
java.nio.ByteBuffer buf)
Call when data read from net.
|
boolean |
needToCompleteHandshake()
Check if there is any need to complete handshake.
|
void |
scheduleFilterWrite(org.apache.mina.common.IoFilter.NextFilter nextFilter,
org.apache.mina.common.IoFilter.WriteRequest writeRequest) |
void |
scheduleMessageReceived(org.apache.mina.common.IoFilter.NextFilter nextFilter,
java.lang.Object message) |
void |
schedulePreHandshakeWriteRequest(org.apache.mina.common.IoFilter.NextFilter nextFilter,
org.apache.mina.common.IoFilter.WriteRequest writeRequest) |
org.apache.mina.common.WriteFuture |
writeNetBuffer(org.apache.mina.common.IoFilter.NextFilter nextFilter) |
public SSLHandler(SSLFilter parent, javax.net.ssl.SSLContext sslc, org.apache.mina.common.IoSession session) throws javax.net.ssl.SSLException
sslc
- javax.net.ssl.SSLException
public void init() throws javax.net.ssl.SSLException
javax.net.ssl.SSLException
public void destroy()
public SSLFilter getParent()
public org.apache.mina.common.IoSession getSession()
public boolean isWritingEncryptedData()
public boolean isHandshakeComplete()
public boolean isInboundDone()
public boolean isOutboundDone()
public boolean needToCompleteHandshake()
public void schedulePreHandshakeWriteRequest(org.apache.mina.common.IoFilter.NextFilter nextFilter, org.apache.mina.common.IoFilter.WriteRequest writeRequest)
public void flushPreHandshakeEvents() throws javax.net.ssl.SSLException
javax.net.ssl.SSLException
public void scheduleFilterWrite(org.apache.mina.common.IoFilter.NextFilter nextFilter, org.apache.mina.common.IoFilter.WriteRequest writeRequest)
public void scheduleMessageReceived(org.apache.mina.common.IoFilter.NextFilter nextFilter, java.lang.Object message)
public void flushScheduledEvents()
public void messageReceived(org.apache.mina.common.IoFilter.NextFilter nextFilter, java.nio.ByteBuffer buf) throws javax.net.ssl.SSLException
buf
- buffer to decryptjavax.net.ssl.SSLException
- on errorspublic java.nio.ByteBuffer getAppBuffer()
public java.nio.ByteBuffer getOutNetBuffer()
public void encrypt(java.nio.ByteBuffer src) throws javax.net.ssl.SSLException
src
- data to encryptjavax.net.ssl.SSLException
- on errorspublic boolean closeOutbound() throws javax.net.ssl.SSLException
javax.net.ssl.SSLException
- on errorspublic void handshake(org.apache.mina.common.IoFilter.NextFilter nextFilter) throws javax.net.ssl.SSLException
javax.net.ssl.SSLException
public org.apache.mina.common.WriteFuture writeNetBuffer(org.apache.mina.common.IoFilter.NextFilter nextFilter) throws javax.net.ssl.SSLException
javax.net.ssl.SSLException
public static org.apache.mina.common.ByteBuffer copy(java.nio.ByteBuffer src)
src
- the buffer to copy