public class SslFilter extends IoFilterAdapter
The initial handshake is automatically enabled for "client" sessions once the filter is added to the filter-chain and the session is connected.
IoFilter.NextFilter| Modifier and Type | Field and Description |
|---|---|
protected String[] |
enabledCipherSuites
The enabled Ciphers.
|
protected String[] |
enabledProtocols
The list of enabled SSL/TLS protocols.
|
protected static Executor |
EXECUTOR
Task executor for processing handshakes
|
protected static org.slf4j.Logger |
LOGGER
The logger
|
protected boolean |
needClientAuth
A flag set if client authentication is required
|
protected static AttributeKey |
SSL_HANDLER
Returns the SSL2Handler object
|
static AttributeKey |
SSL_SECURED
SSLSession object when the session is secured, otherwise null.
|
protected SSLContext |
sslContext |
protected boolean |
wantClientAuth
A flag set if client authentication is requested
|
| Constructor and Description |
|---|
SslFilter(SSLContext sslContext)
Creates a new SSL filter using the specified
SSLContext. |
SslFilter(SSLContext sslContext,
boolean autoStart)
Creates a new SSL filter using the specified
SSLContext. |
| Modifier and Type | Method and Description |
|---|---|
protected SSLEngine |
createEngine(IoSession session,
InetSocketAddress addr)
Customization handler for creating the engine
|
void |
filterWrite(IoFilter.NextFilter next,
IoSession session,
WriteRequest request)
Filters
IoSession.write(Object) method invocation. |
String[] |
getEnabledCipherSuites() |
String[] |
getEnabledProtocols() |
String |
getEndpointIdentificationAlgorithm() |
boolean |
isNeedClientAuth() |
boolean |
isWantClientAuth() |
void |
messageReceived(IoFilter.NextFilter next,
IoSession session,
Object message)
Filters
IoHandler.messageReceived(IoSession,Object) event. |
void |
messageSent(IoFilter.NextFilter next,
IoSession session,
WriteRequest request)
Filters
IoHandler.messageSent(IoSession,Object) event. |
protected void |
onClose(IoFilter.NextFilter next,
IoSession session,
boolean linger)
Called when the session is going to be closed.
|
protected void |
onConnected(IoFilter.NextFilter next,
IoSession session)
Internal method for performing post-connect operations; this can be triggered
during normal connect event or after the filter is added to the chain.
|
void |
onPostAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter next)
Invoked after this filter is added to the specified
parent. |
void |
onPreAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter next)
Invoked before this filter is added to the specified
parent. |
void |
onPreRemove(IoFilterChain parent,
String name,
IoFilter.NextFilter next)
Invoked before this filter is removed from the specified
parent. |
void |
sessionClosed(IoFilter.NextFilter next,
IoSession session)
Filters
IoHandler.sessionClosed(IoSession) event. |
void |
sessionOpened(IoFilter.NextFilter next,
IoSession session)
Filters
IoHandler.sessionOpened(IoSession) event. |
void |
setEnabledCipherSuites(String... enabledCipherSuites)
Sets the list of cipher suites to be enabled when
SSLEngine is
initialized. |
void |
setEnabledProtocols(String... enabledProtocols)
Sets the list of protocols to be enabled when
SSLEngine is
initialized. |
void |
setEndpointIdentificationAlgorithm(String identificationAlgorithm)
Sets the endpoint identification algorithm to be used when
SSLEngine
is initialized. |
void |
setNeedClientAuth(boolean needClientAuth)
Configures the engine to require client authentication.
|
void |
setUseNonBlockingPipeline(boolean enable)
Configures the use of the Non Blocking SSL processor.
|
void |
setWantClientAuth(boolean wantClientAuth)
Configures the engine to request client authentication.
|
destroy, event, exceptionCaught, filterClose, init, inputClosed, onPostRemove, sessionCreated, sessionIdle, toStringpublic static final AttributeKey SSL_SECURED
protected static final AttributeKey SSL_HANDLER
protected static final org.slf4j.Logger LOGGER
protected static final Executor EXECUTOR
protected final SSLContext sslContext
protected boolean needClientAuth
protected boolean wantClientAuth
protected String[] enabledCipherSuites
protected String[] enabledProtocols
public SslFilter(SSLContext sslContext)
SSLContext.sslContext - The SSLContext to usepublic SslFilter(SSLContext sslContext, boolean autoStart)
SSLContext.
If the autostart flag is set to true, the
handshake will start immediately after the filter has been added
to the chain.sslContext - The SSLContext to useautoStart - The flag used to tell the filter to start the handshake immediatelypublic void setUseNonBlockingPipeline(boolean enable)
enable - true if the non blocking SSL processor is enabledpublic boolean isNeedClientAuth()
true if the engine will require client
authentication. This option is only useful to engines in the server
mode.public void setNeedClientAuth(boolean needClientAuth)
needClientAuth - A flag set when client authentication is requiredpublic boolean isWantClientAuth()
true if the engine will request client
authentication. This option is only useful to engines in the server
mode.public void setWantClientAuth(boolean wantClientAuth)
wantClientAuth - A flag set when client authentication is requestedpublic String[] getEnabledCipherSuites()
public void setEnabledCipherSuites(String... enabledCipherSuites)
SSLEngine is
initialized.enabledCipherSuites - The list of enabled Cipher.
null means 'use SSLEngine's default.'public String getEndpointIdentificationAlgorithm()
public void setEndpointIdentificationAlgorithm(String identificationAlgorithm)
SSLEngine
is initialized.identificationAlgorithm - null means 'use SSLEngine's default.'public String[] getEnabledProtocols()
public void setEnabledProtocols(String... enabledProtocols)
SSLEngine is
initialized.enabledProtocols - The list of enabled SSL/TLS protocols.
null means 'use SSLEngine's default.'public void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter next) throws Exception
parent.
Please note that this method can be invoked more than once if
this filter is added to more than one parents. This method is not
invoked before IoFilter.init() is invoked.onPreAdd in interface IoFilteronPreAdd in class IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternext - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventpublic void onPostAdd(IoFilterChain parent, String name, IoFilter.NextFilter next) throws Exception
parent.
Please note that this method can be invoked more than once if
this filter is added to more than one parents. This method is not
invoked before IoFilter.init() is invoked.onPostAdd in interface IoFilteronPostAdd in class IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternext - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventpublic void onPreRemove(IoFilterChain parent, String name, IoFilter.NextFilter next) throws Exception
parent.
Please note that this method can be invoked more than once if
this filter is removed from more than one parents.
This method is always invoked before IoFilter.destroy() is invoked.onPreRemove in interface IoFilteronPreRemove in class IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternext - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventprotected void onConnected(IoFilter.NextFilter next, IoSession session) throws SSLException
next - The nextFilter to call in the chainsession - The session instanceSSLException - Any exception thrown by the SslHandler closingprotected void onClose(IoFilter.NextFilter next, IoSession session, boolean linger) throws SSLException
next - The nextFilter to call in the chainsession - The session instancelinger - if true, write any queued messages before closingSSLException - Any exception thrown by the SslHandler closingprotected SSLEngine createEngine(IoSession session, InetSocketAddress addr)
session - source sessionaddr - socket address used for fast reconnectpublic void sessionOpened(IoFilter.NextFilter next, IoSession session) throws Exception
IoHandler.sessionOpened(IoSession) event.sessionOpened in interface IoFiltersessionOpened in class IoFilterAdapternext - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventpublic void sessionClosed(IoFilter.NextFilter next, IoSession session) throws Exception
IoHandler.sessionClosed(IoSession) event.sessionClosed in interface IoFiltersessionClosed in class IoFilterAdapternext - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventpublic void messageReceived(IoFilter.NextFilter next, IoSession session, Object message) throws Exception
IoHandler.messageReceived(IoSession,Object) event.messageReceived in interface IoFiltermessageReceived in class IoFilterAdapternext - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventmessage - The received messageException - If an error occurred while processing the eventpublic void messageSent(IoFilter.NextFilter next, IoSession session, WriteRequest request) throws Exception
IoHandler.messageSent(IoSession,Object) event.messageSent in interface IoFiltermessageSent in class IoFilterAdapternext - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventrequest - The WriteRequest that contains the sent messageException - If an error occurred while processing the eventpublic void filterWrite(IoFilter.NextFilter next, IoSession session, WriteRequest request) throws Exception
IoSession.write(Object) method invocation.filterWrite in interface IoFilterfilterWrite in class IoFilterAdapternext - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has to process this invocationrequest - The WriteRequest to processException - If an error occurred while processing the eventCopyright © 2004–2024 Apache MINA Project. All rights reserved.