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 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 . |
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() |
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 |
setNeedClientAuth(boolean needClientAuth)
Configures the engine to require client authentication.
|
void |
setWantClientAuth(boolean wantClientAuth)
Configures the engine to request client authentication.
|
destroy, event, exceptionCaught, filterClose, init, inputClosed, onPostRemove, sessionCreated, sessionIdle, toString
public static final AttributeKey SSL_SECURED
protected static final AttributeKey SSL_HANDLER
protected static final 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 boolean isNeedClientAuth()
public void setNeedClientAuth(boolean needClientAuth)
needClientAuth
- A flag set when client authentication is requiredpublic boolean isWantClientAuth()
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[] 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
IoFilter.init()
is invoked.onPreAdd
in interface IoFilter
onPreAdd
in class IoFilterAdapter
parent
- 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
IoFilter.init()
is invoked.onPostAdd
in interface IoFilter
onPostAdd
in class IoFilterAdapter
parent
- 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
IoFilter.destroy()
is invoked.onPreRemove
in interface IoFilter
onPreRemove
in class IoFilterAdapter
parent
- 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 nextFolter 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 nextFolter 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 IoFilter
sessionOpened
in class IoFilterAdapter
next
- 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 IoFilter
sessionClosed
in class IoFilterAdapter
next
- 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 IoFilter
messageReceived
in class IoFilterAdapter
next
- 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 IoFilter
messageSent
in class IoFilterAdapter
next
- 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 IoFilter
filterWrite
in class IoFilterAdapter
next
- 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–2022 Apache MINA Project. All rights reserved.