Package org.apache.mina.proxy.filter
Class ProxyFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.proxy.filter.ProxyFilter
-
- All Implemented Interfaces:
IoFilter
public class ProxyFilter extends IoFilterAdapter
ProxyFilter.java - ProxyIoFilter. Automatically inserted into theIoFilterchain byProxyConnector. 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.
- Since:
- MINA 2.0.0-M3
- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Constructor Summary
Constructors Constructor Description ProxyFilter()Create a newProxyFilter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause)Called when an exception occurs in the chain.voidfilterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)Filters outgoing writes, queueing them up if necessary while a handshake is ongoing.voidmessageReceived(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.voidmessageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)Filter handshake related messages from reaching the messageSent callbacks of downstream filters.voidonPreAdd(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)Called before the filter is added into the filter chain.voidonPreRemove(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)Called when the filter is removed from the filter chain.voidsessionClosed(IoFilter.NextFilter nextFilter, IoSession session)Event is stored in anIoSessionEventQueuefor later delivery to the next filter in the chain when the handshake would have succeed.voidsessionCreated(IoFilter.NextFilter nextFilter, IoSession session)Called when the session is created.voidsessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)Event is stored in anIoSessionEventQueuefor later delivery to the next filter in the chain when the handshake would have succeed.voidsessionOpened(IoFilter.NextFilter nextFilter, IoSession session)Event is stored in anIoSessionEventQueuefor later delivery to the next filter in the chain when the handshake would have succeed.voidwriteData(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest, boolean isHandshakeData)Actually write data.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, event, filterClose, init, inputClosed, onPostAdd, onPostRemove, toString
-
-
-
-
Constructor Detail
-
ProxyFilter
public ProxyFilter()
Create a newProxyFilter.
-
-
Method Detail
-
onPreAdd
public void onPreAdd(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)
Called before the filter is added into the filter chain. Checks if chain already holds anProxyFilterinstance.- Specified by:
onPreAddin interfaceIoFilter- Overrides:
onPreAddin classIoFilterAdapter- Parameters:
chain- the filter chainname- the name assigned to this filternextFilter- the next filter- Throws:
IllegalStateException- if chain already contains an instance ofProxyFilter
-
onPreRemove
public void onPreRemove(IoFilterChain chain, String name, IoFilter.NextFilter nextFilter)
Called when the filter is removed from the filter chain. Cleans theProxyIoSessioninstance from the session.- Specified by:
onPreRemovein interfaceIoFilter- Overrides:
onPreRemovein classIoFilterAdapter- Parameters:
chain- the filter chainname- the name assigned to this filternextFilter- the next filter
-
exceptionCaught
public void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
Called when an exception occurs in the chain. A flag is set in theProxyIoSessionsession's instance to signal that handshake failed.- Specified by:
exceptionCaughtin interfaceIoFilter- Overrides:
exceptionCaughtin classIoFilterAdapter- Parameters:
nextFilter- next filter in the filter chainsession- the MINA sessioncause- the original exception- Throws:
Exception- If an error occurred while processing the event
-
messageReceived
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws ProxyAuthException
Receives data from the remote host, passes to the handler if a handshake is in progress, otherwise passes on transparently.- Specified by:
messageReceivedin interfaceIoFilter- Overrides:
messageReceivedin classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session objectmessage- the object holding the received data- Throws:
ProxyAuthException
-
filterWrite
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
Filters outgoing writes, queueing them up if necessary while a handshake is ongoing.- Specified by:
filterWritein interfaceIoFilter- Overrides:
filterWritein classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session objectwriteRequest- the data to write
-
writeData
public void writeData(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest, boolean isHandshakeData)
Actually write data. Queues the data up unless it relates to the handshake or the handshake is done.- Parameters:
nextFilter- the next filter in filter chainsession- the session objectwriteRequest- the data to writeisHandshakeData- true if writeRequest is written by the proxy classes.
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
Filter handshake related messages from reaching the messageSent callbacks of downstream filters.- Specified by:
messageSentin interfaceIoFilter- Overrides:
messageSentin classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session objectwriteRequest- the data written- Throws:
Exception- If an error occurred while processing the event
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Called when the session is created. Will create the handler able to handle theProxyIoSession.getRequest()request stored in the session. Event is stored in anIoSessionEventQueuefor 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.- Specified by:
sessionCreatedin interfaceIoFilter- Overrides:
sessionCreatedin classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session object- Throws:
Exception- If an error occurred while processing the event
-
sessionOpened
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Event is stored in anIoSessionEventQueuefor 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.- Specified by:
sessionOpenedin interfaceIoFilter- Overrides:
sessionOpenedin classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session object- Throws:
Exception- If an error occurred while processing the event
-
sessionIdle
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
Event is stored in anIoSessionEventQueuefor 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.- Specified by:
sessionIdlein interfaceIoFilter- Overrides:
sessionIdlein classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session objectstatus- TheIdleStatustype- Throws:
Exception- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Event is stored in anIoSessionEventQueuefor 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.- Specified by:
sessionClosedin interfaceIoFilter- Overrides:
sessionClosedin classIoFilterAdapter- Parameters:
nextFilter- the next filter in filter chainsession- the session object- Throws:
Exception- If an error occurred while processing the event
-
-