public class ProxyFilter extends IoFilterAdapter
IoFilter
.
Automatically inserted into the IoFilter
chain by ProxyConnector
.
Sends the initial handshake message to the proxy and handles any response
to the handshake. Once the handshake has completed and the proxied connection has been
established this filter becomes transparent to data flowing through the connection.
Based upon SSLFilter from mina-filter-ssl.
IoFilter.NextFilter
Constructor and Description |
---|
ProxyFilter()
Create a new
ProxyFilter . |
Modifier and Type | Method and Description |
---|---|
void |
exceptionCaught(IoFilter.NextFilter nextFilter,
IoSession session,
Throwable cause)
Called when an exception occurs in the chain.
|
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters outgoing writes, queueing them up if necessary while a handshake
is ongoing.
|
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
Object message)
Receives data from the remote host, passes to the handler if a handshake is in progress,
otherwise passes on transparently.
|
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filter handshake related messages from reaching the messageSent callbacks of
downstream filters.
|
void |
onPreAdd(IoFilterChain chain,
String name,
IoFilter.NextFilter nextFilter)
Called before the filter is added into the filter chain.
|
void |
onPreRemove(IoFilterChain chain,
String name,
IoFilter.NextFilter nextFilter)
Called when the filter is removed from the filter chain.
|
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Event is stored in an
IoSessionEventQueue for later delivery to the next filter
in the chain when the handshake would have succeed. |
void |
sessionCreated(IoFilter.NextFilter nextFilter,
IoSession session)
Called when the session is created.
|
void |
sessionIdle(IoFilter.NextFilter nextFilter,
IoSession session,
IdleStatus status)
Event is stored in an
IoSessionEventQueue for later delivery to the next filter
in the chain when the handshake would have succeed. |
void |
sessionOpened(IoFilter.NextFilter nextFilter,
IoSession session)
Event is stored in an
IoSessionEventQueue for later delivery to the next filter
in the chain when the handshake would have succeed. |
void |
writeData(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest,
boolean isHandshakeData)
Actually write data.
|
destroy, event, filterClose, init, inputClosed, onPostAdd, onPostRemove, toString
public ProxyFilter()
ProxyFilter
.public void onPreAdd(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)
ProxyFilter
instance.onPreAdd
in interface IoFilter
onPreAdd
in class IoFilterAdapter
chain
- the filter chainname
- the name assigned to this filternextFilter
- the next filterIllegalStateException
- if chain already contains an instance of
ProxyFilter
public void onPreRemove(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)
ProxyIoSession
instance from the session.onPreRemove
in interface IoFilter
onPreRemove
in class IoFilterAdapter
chain
- the filter chainname
- the name assigned to this filternextFilter
- the next filterpublic void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
ProxyIoSession
session's instance to signal that handshake
failed.exceptionCaught
in interface IoFilter
exceptionCaught
in class IoFilterAdapter
nextFilter
- next filter in the filter chainsession
- the MINA sessioncause
- the original exceptionException
- If an error occurred while processing the eventpublic void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws ProxyAuthException
messageReceived
in interface IoFilter
messageReceived
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectmessage
- the object holding the received dataProxyAuthException
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
filterWrite
in interface IoFilter
filterWrite
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectwriteRequest
- the data to writepublic void writeData(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest, boolean isHandshakeData)
nextFilter
- the next filter in filter chainsession
- the session objectwriteRequest
- the data to writeisHandshakeData
- true if writeRequest is written by the proxy classes.public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
messageSent
in interface IoFilter
messageSent
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectwriteRequest
- the data writtenException
- If an error occurred while processing the eventpublic void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
ProxyIoSession.getRequest()
request stored in the session. Event
is stored in an IoSessionEventQueue
for later delivery to the next filter
in the chain when the handshake would have succeed. This will prevent the rest of
the filter chain from being affected by this filter internals.
Please note that this event can occur multiple times because of some http
proxies not handling keep-alive connections thus needing multiple sessions
during the handshake.sessionCreated
in interface IoFilter
sessionCreated
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectException
- If an error occurred while processing the eventpublic void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoSessionEventQueue
for later delivery to the next filter
in the chain when the handshake would have succeed. This will prevent the rest of
the filter chain from being affected by this filter internals.sessionOpened
in interface IoFilter
sessionOpened
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectException
- If an error occurred while processing the eventpublic void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
IoSessionEventQueue
for later delivery to the next filter
in the chain when the handshake would have succeed. This will prevent the rest of
the filter chain from being affected by this filter internals.sessionIdle
in interface IoFilter
sessionIdle
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectstatus
- The IdleStatus
typeException
- If an error occurred while processing the eventpublic void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoSessionEventQueue
for later delivery to the next filter
in the chain when the handshake would have succeed. This will prevent the rest of
the filter chain from being affected by this filter internals.sessionClosed
in interface IoFilter
sessionClosed
in class IoFilterAdapter
nextFilter
- the next filter in filter chainsession
- the session objectException
- If an error occurred while processing the eventCopyright © 2004–2021 Apache MINA Project. All rights reserved.