Package org.apache.mina.filter.ssl
Class SslHandler
- java.lang.Object
-
- org.apache.mina.filter.ssl.SslHandler
-
- Direct Known Subclasses:
SSLHandlerG0
public abstract class SslHandler extends Object
Default interface for SSL exposed to theSslFilter- Author:
- Jonathan Valliere, Apache MINA Project
-
-
Field Summary
Fields Modifier and Type Field Description protected static LoggerLOGGERStatic loggerprotected Deque<WriteRequest>mAckQueueRequests which have been sent to the socket and waiting acknowledgmentprotected static intMAX_ENCODER_BUFFER_PACKETSMaximum size of encoder buffer in packetsprotected IoBuffermDecodeBufferProgressive decoder bufferprotected Deque<WriteRequest>mEncodeQueueWrite Requests which are enqueued prior to the completion of the handshakingprotected SSLEnginemEngineSSL Engineprotected ExecutormExecutorTask executorprotected static intMIN_ENCODER_BUFFER_PACKETSMinimum size of encoder buffer in packetsprotected IoSessionmSessionSocket sessionprotected static IoBufferZEROZero length buffer used to prime the ssl engine
-
Constructor Summary
Constructors Constructor Description SslHandler(SSLEngine p, Executor e, IoSession s)Instantiates a new handler
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidack(IoFilter.NextFilter next, WriteRequest request)Acknowledge that aWriteRequesthas been successfully written to theIoSessionprotected IoBufferallocate_app_buffer(int estimate)Allocates the default decoder buffer for the given source sizeprotected IoBufferallocate_encode_buffer(int estimate)Allocates the default encoder buffer for the given source sizeabstract voidclose(IoFilter.NextFilter next, boolean linger)Closes the encryption session and writes any required messagesabstract booleanisConnected()abstract booleanisOpen()abstract voidopen(IoFilter.NextFilter next)Opens the encryption session, this may include sending the initial handshake messageabstract voidreceive(IoFilter.NextFilter next, IoBuffer message)Decodes encrypted messages and passes the results to thenextfilter.protected IoBufferresume_decode_buffer(IoBuffer source)Combines the received data with any previously received dataprotected voidsuspend_decode_buffer(IoBuffer source)Stores data for later use if any is remainingStringtoString()abstract voidwrite(IoFilter.NextFilter next, WriteRequest request)Encrypts and writes the specifiedWriteRequestto theIoSessionor enqueues it to be processed later.
-
-
-
Field Detail
-
MIN_ENCODER_BUFFER_PACKETS
protected static final int MIN_ENCODER_BUFFER_PACKETS
Minimum size of encoder buffer in packets- See Also:
- Constant Field Values
-
MAX_ENCODER_BUFFER_PACKETS
protected static final int MAX_ENCODER_BUFFER_PACKETS
Maximum size of encoder buffer in packets- See Also:
- Constant Field Values
-
ZERO
protected static final IoBuffer ZERO
Zero length buffer used to prime the ssl engine
-
LOGGER
protected static final Logger LOGGER
Static logger
-
mEncodeQueue
protected final Deque<WriteRequest> mEncodeQueue
Write Requests which are enqueued prior to the completion of the handshaking
-
mAckQueue
protected final Deque<WriteRequest> mAckQueue
Requests which have been sent to the socket and waiting acknowledgment
-
mEngine
protected final SSLEngine mEngine
SSL Engine
-
mExecutor
protected final Executor mExecutor
Task executor
-
mSession
protected final IoSession mSession
Socket session
-
mDecodeBuffer
protected IoBuffer mDecodeBuffer
Progressive decoder buffer
-
-
Method Detail
-
isOpen
public abstract boolean isOpen()
- Returns:
trueif the encryption session is open
-
isConnected
public abstract boolean isConnected()
- Returns:
trueif the encryption session is connected and secure
-
open
public abstract void open(IoFilter.NextFilter next) throws SSLException
Opens the encryption session, this may include sending the initial handshake message- Parameters:
next- The next filter- Throws:
SSLException- The thrown exception
-
receive
public abstract void receive(IoFilter.NextFilter next, IoBuffer message) throws SSLException
Decodes encrypted messages and passes the results to thenextfilter.- Parameters:
next- The next filtermessage- the received message- Throws:
SSLException- The thrown exception
-
ack
public abstract void ack(IoFilter.NextFilter next, WriteRequest request) throws SSLException
Acknowledge that aWriteRequesthas been successfully written to theIoSessionThis functionality is used to enforce flow control by allowing only a specific number of pending write operations at any moment of time. When one
WriteRequestis acknowledged, another can be encoded and written.- Parameters:
next- The next filterrequest- The request to ack- Throws:
SSLException- The thrown exception
-
write
public abstract void write(IoFilter.NextFilter next, WriteRequest request) throws SSLException, WriteRejectedException
Encrypts and writes the specifiedWriteRequestto theIoSessionor enqueues it to be processed later.The encryption session may be currently handshaking preventing application messages from being written.
- Parameters:
next- The next filterrequest- The request to write- Throws:
SSLException- The thrown exceptionWriteRejectedException- when the session is closing
-
close
public abstract void close(IoFilter.NextFilter next, boolean linger) throws SSLException
Closes the encryption session and writes any required messages- Parameters:
next- The next filterlinger- if true, write any queued messages before closing- Throws:
SSLException- The thrown exception
-
resume_decode_buffer
protected IoBuffer resume_decode_buffer(IoBuffer source)
Combines the received data with any previously received data- Parameters:
source- received data- Returns:
- buffer to decode
-
suspend_decode_buffer
protected void suspend_decode_buffer(IoBuffer source)
Stores data for later use if any is remaining- Parameters:
source- the buffer previously returned byresume_decode_buffer(IoBuffer)
-
allocate_encode_buffer
protected IoBuffer allocate_encode_buffer(int estimate)
Allocates the default encoder buffer for the given source size- Parameters:
estimate- The estimated remaining size- Returns:
- buffer The allocated buffer
-
allocate_app_buffer
protected IoBuffer allocate_app_buffer(int estimate)
Allocates the default decoder buffer for the given source size- Parameters:
estimate- The estimated remaining size- Returns:
- buffer The allocated buffer
-
-