Package org.apache.catalina.util
Class NetMaskSet
- java.lang.Object
- 
- org.apache.catalina.util.NetMaskSet
 
- 
 public class NetMaskSet extends java.lang.ObjectThis class maintains a Set of NetMask objects and allows to check if a given IP address is matched by any of the NetMasks, making it easy to create Allow and Deny lists of CIDR networks and hosts.
- 
- 
Constructor SummaryConstructors Constructor Description NetMaskSet()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.String input)Creates a NetMask object from the input string and adds it to the set.booleanadd(NetMask netmask)Adds a NetMask object to the set if the set does not contain itjava.util.List<java.lang.String>addAll(java.lang.String input)voidclear()removes all entries from the setbooleancontains(java.lang.String ipAddress)Tests if the provided IP address matches any of theNetMasks in the set.booleancontains(java.net.InetAddress inetAddress)Tests if the provided InetAddress matches any of theNetMasks in the set.booleanisEmpty()Tests if the set is empty.java.lang.StringtoString()Provides a string representation of this NetMaskSet.
 
- 
- 
- 
Method Detail- 
containspublic boolean contains(java.net.InetAddress inetAddress) Tests if the provided InetAddress matches any of theNetMasks in the set.- Parameters:
- inetAddress- An InetAddress to check
- Returns:
- trueif the passed inetAddress is matched by any of the- NetMasks in the set
 
 - 
containspublic boolean contains(java.lang.String ipAddress) throws java.net.UnknownHostExceptionTests if the provided IP address matches any of theNetMasks in the set.- Parameters:
- ipAddress- an IP address to check
- Returns:
- trueif the passed IP address is matched by any of the- NetMasks in the set
- Throws:
- java.net.UnknownHostException- if the passed input is not a valid IP address
 
 - 
addpublic boolean add(NetMask netmask) Adds a NetMask object to the set if the set does not contain it- Parameters:
- netmask- The NetMask to add
- Returns:
- true if the object was added
 
 - 
addpublic boolean add(java.lang.String input) Creates a NetMask object from the input string and adds it to the set.- Parameters:
- input- The string from which to construct the NetMask
- Returns:
- true if the object was added
- Throws:
- java.lang.IllegalArgumentException- if the input is not a valid CIDR format.
 
 - 
clearpublic void clear() removes all entries from the set
 - 
isEmptypublic boolean isEmpty() Tests if the set is empty.- Returns:
- trueif the set is empty, otherwise- false
 
 - 
addAllpublic java.util.List<java.lang.String> addAll(java.lang.String input) Adds aNetMasklist from a string input containing a comma-separated list of (hopefully valid)NetMasks.- Parameters:
- input- The input string
- Returns:
- a list of processing error messages (empty when no errors)
 
 - 
toStringpublic java.lang.String toString() Provides a string representation of this NetMaskSet. The format of the String is not guaranteed to remain fixed.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- a comma separated list of the NetMasks in this set
 
 
- 
 
-