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, filterClose, init, onPostAdd, onPostRemove, toStringpublic ProxyFilter()
ProxyFilter.public void onPreAdd(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)
ProxyFilter instance.onPreAdd in interface IoFilteronPreAdd in class IoFilterAdapterchain - the filter chainname - the name assigned to this filternextFilter - the next filterIllegalStateException - if chain already contains an instance of
ProxyFilterpublic void onPreRemove(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)
ProxyIoSession instance from the session.onPreRemove in interface IoFilteronPreRemove in class IoFilterAdapterchain - 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 IoFilterexceptionCaught in class IoFilterAdapterchain - the filter chainname - the name assigned to this filternextFilter - the next filterExceptionpublic void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws ProxyAuthException
messageReceived in interface IoFiltermessageReceived in class IoFilterAdapternextFilter - the next filter in filter chainsession - the session objectmessage - the object holding the received dataProxyAuthExceptionpublic void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
filterWrite in interface IoFilterfilterWrite in class IoFilterAdapternextFilter - 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 IoFiltermessageSent in class IoFilterAdapternextFilter - the next filter in filter chainsession - the session objectwriteRequest - the data writtenExceptionpublic 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 IoFiltersessionCreated in class IoFilterAdapternextFilter - the next filter in filter chainsession - the session objectExceptionpublic 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 IoFiltersessionOpened in class IoFilterAdapternextFilter - the next filter in filter chainsession - the session objectExceptionpublic 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 IoFiltersessionIdle in class IoFilterAdapternextFilter - the next filter in filter chainsession - the session objectExceptionpublic 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 IoFiltersessionClosed in class IoFilterAdapternextFilter - the next filter in filter chainsession - the session objectException