org.apache.ftpserver.ipfilter
Class DefaultIpFilter

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.concurrent.CopyOnWriteArraySet<org.apache.mina.filter.firewall.Subnet>
              extended by org.apache.ftpserver.ipfilter.DefaultIpFilter
All Implemented Interfaces:
Serializable, Iterable<org.apache.mina.filter.firewall.Subnet>, Collection<org.apache.mina.filter.firewall.Subnet>, Set<org.apache.mina.filter.firewall.Subnet>, IpFilter

public class DefaultIpFilter
extends CopyOnWriteArraySet<org.apache.mina.filter.firewall.Subnet>
implements IpFilter

Default implementation of the IpFilter interface, which uses specific IP addresses or ranges of IP addresses that can be blocked or allowed.

Author:
Apache MINA Project
See Also:
Serialized Form

Constructor Summary
DefaultIpFilter(IpFilterType type)
          Creates a new instance of DefaultIpFilter.
DefaultIpFilter(IpFilterType type, Collection<? extends org.apache.mina.filter.firewall.Subnet> collection)
          Creates a new instance of DefaultIpFilter.
DefaultIpFilter(IpFilterType type, String addresses)
          Creates a new instance of DefaultIpFilter.
 
Method Summary
 boolean accept(InetAddress address)
          Tells whether or not the given IP address is accepted by this filter.
 boolean add(String str)
          Adds the given string representation of InetAddress or CIDR notation to this filter.
 IpFilterType getType()
          Returns the type of this filter.
 void setType(IpFilterType type)
          Sets the type of this filter.
 
Methods inherited from class java.util.concurrent.CopyOnWriteArraySet
add, addAll, clear, contains, containsAll, equals, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSet
hashCode
 
Methods inherited from class java.util.AbstractCollection
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultIpFilter

public DefaultIpFilter(IpFilterType type)
Creates a new instance of DefaultIpFilter.

Parameters:
type - the filter type

DefaultIpFilter

public DefaultIpFilter(IpFilterType type,
                       Collection<? extends org.apache.mina.filter.firewall.Subnet> collection)
Creates a new instance of DefaultIpFilter.

Parameters:
type - the filter type
collection - a collection of Subnets to filter out/in.

DefaultIpFilter

public DefaultIpFilter(IpFilterType type,
                       String addresses)
                throws NumberFormatException,
                       UnknownHostException
Creates a new instance of DefaultIpFilter.

Parameters:
type - the filter type
addresses - a comma, space, tab, LF separated list of IP addresses/CIDRs.
Throws:
UnknownHostException - propagated
NumberFormatException - propagated
Method Detail

getType

public IpFilterType getType()
Returns the type of this filter.

Returns:
the type of this filter.

setType

public void setType(IpFilterType type)
Sets the type of this filter.

Parameters:
type - the type of this filter.

add

public boolean add(String str)
            throws NumberFormatException,
                   UnknownHostException
Adds the given string representation of InetAddress or CIDR notation to this filter.

Parameters:
str - the string representation of InetAddress or CIDR notation
Returns:
if the given element was added or not. true, if the given element was added to the filter; false, if the element already exists in the filter.
Throws:
NumberFormatException - propagated
UnknownHostException - propagated

accept

public boolean accept(InetAddress address)
Description copied from interface: IpFilter
Tells whether or not the given IP address is accepted by this filter.

Specified by:
accept in interface IpFilter
Parameters:
address - the IP address to check
Returns:
true, if the given IP address is accepted by this filter; false, otherwise.


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.