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
A
IoFilter which blocks connections from blacklisted remote
address.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidblock(InetAddress address) Blocks the specified endpoint.voidBlocks the specified subnet.private voidblockSession(IoSession session) private booleanvoidmessageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) FiltersIoHandler.messageReceived(IoSession,Object)event.voidmessageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) FiltersIoHandler.messageSent(IoSession,Object)event.voidsessionClosed(IoFilter.NextFilter nextFilter, IoSession session) FiltersIoHandler.sessionClosed(IoSession)event.voidsessionCreated(IoFilter.NextFilter nextFilter, IoSession session) FiltersIoHandler.sessionCreated(IoSession)event.voidsessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) FiltersIoHandler.sessionIdle(IoSession,IdleStatus)event.voidsessionOpened(IoFilter.NextFilter nextFilter, IoSession session) FiltersIoHandler.sessionOpened(IoSession)event.voidsetBlacklist(Iterable<InetAddress> addresses) Sets the addresses to be blacklisted.voidsetBlacklist(InetAddress[] addresses) Sets the addresses to be blacklisted.voidsetSubnetBlacklist(Iterable<Subnet> subnets) Sets the subnets to be blacklisted.voidsetSubnetBlacklist(Subnet[] subnets) Sets the subnets to be blacklisted.voidunblock(InetAddress address) Unblocks the specified endpoint.voidUnblocks the specified subnet.Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, exceptionCaught, filterClose, filterWrite, init, inputClosed, onPostAdd, onPostRemove, onPreAdd, onPreRemove, toString
-
Field Details
-
blacklist
The list of blocked addresses -
LOGGER
private static final org.slf4j.Logger LOGGERA logger for this class
-
-
Constructor Details
-
BlacklistFilter
public BlacklistFilter()
-
-
Method Details
-
setBlacklist
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
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
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-InetAddressobjects.
-
setSubnetBlacklist
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
Blocks the specified endpoint.- Parameters:
address- The address to block
-
block
Blocks the specified subnet.- Parameters:
subnet- The subnet to block
-
unblock
Unblocks the specified endpoint.- Parameters:
address- The address to unblock
-
unblock
Unblocks the specified subnet.- Parameters:
subnet- The subnet to unblock
-
sessionCreated
FiltersIoHandler.sessionCreated(IoSession)event.- Specified by:
sessionCreatedin interfaceIoFilter- Overrides:
sessionCreatedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event
-
sessionOpened
FiltersIoHandler.sessionOpened(IoSession)event.- Specified by:
sessionOpenedin interfaceIoFilter- Overrides:
sessionOpenedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
Exception- If an error occurred while processing the event
-
sessionClosed
FiltersIoHandler.sessionClosed(IoSession)event.- Specified by:
sessionClosedin interfaceIoFilter- Overrides:
sessionClosedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich 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 FiltersIoHandler.sessionIdle(IoSession,IdleStatus)event.- Specified by:
sessionIdlein interfaceIoFilter- Overrides:
sessionIdlein classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventstatus- TheIdleStatustype- Throws:
Exception- If an error occurred while processing the event
-
messageReceived
FiltersIoHandler.messageReceived(IoSession,Object)event.- Specified by:
messageReceivedin interfaceIoFilter- Overrides:
messageReceivedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventmessage- The received message
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception FiltersIoHandler.messageSent(IoSession,Object)event.- Specified by:
messageSentin interfaceIoFilter- Overrides:
messageSentin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventwriteRequest- TheWriteRequestthat contains the sent message- Throws:
Exception- If an error occurred while processing the event
-
blockSession
-
isBlocked
-