Package org.apache.mina.filter.firewall
Class BlacklistFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.firewall.BlacklistFilter
-
- All Implemented Interfaces:
IoFilter
public class BlacklistFilter extends IoFilterAdapter
AIoFilter
which blocks connections from blacklisted remote address.- 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 BlacklistFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
block(InetAddress address)
Blocks the specified endpoint.void
block(Subnet subnet)
Blocks the specified subnet.void
messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
FiltersIoHandler.messageReceived(IoSession,Object)
event.void
messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoHandler.messageSent(IoSession,Object)
event.void
sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionClosed(IoSession)
event.void
sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionCreated(IoSession)
event.void
sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.void
sessionOpened(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionOpened(IoSession)
event.void
setBlacklist(Iterable<InetAddress> addresses)
Sets the addresses to be blacklisted.void
setBlacklist(InetAddress[] addresses)
Sets the addresses to be blacklisted.void
setSubnetBlacklist(Iterable<Subnet> subnets)
Sets the subnets to be blacklisted.void
setSubnetBlacklist(Subnet[] subnets)
Sets the subnets to be blacklisted.void
unblock(InetAddress address)
Unblocks the specified endpoint.void
unblock(Subnet subnet)
Unblocks the specified subnet.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, exceptionCaught, filterClose, filterWrite, init, inputClosed, onPostAdd, onPostRemove, onPreAdd, onPreRemove, toString
-
-
-
-
Method Detail
-
setBlacklist
public void setBlacklist(InetAddress[] addresses)
Sets the addresses to be blacklisted. NOTE: this call will remove any previously blacklisted addresses.- Parameters:
addresses
- an array of addresses to be blacklisted.
-
setSubnetBlacklist
public void setSubnetBlacklist(Subnet[] subnets)
Sets the subnets to be blacklisted. NOTE: this call will remove any previously blacklisted subnets.- Parameters:
subnets
- an array of subnets to be blacklisted.
-
setBlacklist
public void setBlacklist(Iterable<InetAddress> addresses)
Sets the addresses to be blacklisted. NOTE: this call will remove any previously blacklisted addresses.- Parameters:
addresses
- a collection of InetAddress objects representing the addresses to be blacklisted.- Throws:
IllegalArgumentException
- if the specified collections contains non-InetAddress
objects.
-
setSubnetBlacklist
public void setSubnetBlacklist(Iterable<Subnet> subnets)
Sets the subnets to be blacklisted. NOTE: this call will remove any previously blacklisted subnets.- Parameters:
subnets
- an array of subnets to be blacklisted.
-
block
public void block(InetAddress address)
Blocks the specified endpoint.- Parameters:
address
- The address to block
-
block
public void block(Subnet subnet)
Blocks the specified subnet.- Parameters:
subnet
- The subnet to block
-
unblock
public void unblock(InetAddress address)
Unblocks the specified endpoint.- Parameters:
address
- The address to unblock
-
unblock
public void unblock(Subnet subnet)
Unblocks the specified subnet.- Parameters:
subnet
- The subnet to unblock
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionCreated(IoSession)
event.- Specified by:
sessionCreated
in interfaceIoFilter
- Overrides:
sessionCreated
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event
-
sessionOpened
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionOpened(IoSession)
event.- Specified by:
sessionOpened
in interfaceIoFilter
- Overrides:
sessionOpened
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionClosed(IoSession)
event.- Specified by:
sessionClosed
in interfaceIoFilter
- Overrides:
sessionClosed
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
sessionIdle
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
Description copied from class:IoFilterAdapter
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.- Specified by:
sessionIdle
in interfaceIoFilter
- Overrides:
sessionIdle
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventstatus
- TheIdleStatus
type- Throws:
Exception
- If an error occurred while processing the event
-
messageReceived
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
Description copied from class:IoFilterAdapter
FiltersIoHandler.messageReceived(IoSession,Object)
event.- Specified by:
messageReceived
in interfaceIoFilter
- Overrides:
messageReceived
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventmessage
- The received message
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
Description copied from class:IoFilterAdapter
FiltersIoHandler.messageSent(IoSession,Object)
event.- Specified by:
messageSent
in interfaceIoFilter
- Overrides:
messageSent
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventwriteRequest
- TheWriteRequest
that contains the sent message- Throws:
Exception
- If an error occurred while processing the event
-
-