Package org.dspace.authenticate
Class IPMatcher
- java.lang.Object
-
- org.dspace.authenticate.IPMatcher
-
public class IPMatcher extends Object
Quickly tests whether a given IP address matches an IP range. An
IPMatcheris initialized with a particular IP range specification. Calls tomatchmethod will then quickly determine whether a given IP falls within that range.Supported range specifications are:
- Full IPv4 address, e.g.
12.34.56.78 - Full IPv6 address, e.g.
2001:18e8:3:171:218:8bff:fe2a:56a4 - Partial IPv4 address, e.g.
12.34(which matches any IP starting12.34) - IPv4 network/netmask, e.g.
18.25.0.0/255.255.0.0 - IPv4 or IPv6 CIDR slash notation, e.g.
18.25.0.0/16,2001:18e8:3:171::/64
- Version:
- $Revision$
- Author:
- Robert Tansley, Ben Bosman, Roeland Dillen
- Full IPv4 address, e.g.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanmatch(String ipIn)Determine whether the given full IP falls within the range thisIPMatcherwas initialized with.
-
-
-
Constructor Detail
-
IPMatcher
public IPMatcher(String ipSpec) throws IPMatcherException
Construct an IPMatcher that will test for the given IP specification- Parameters:
ipSpec- IP specification (full or partial address, network/netmask, network/cidr)- Throws:
IPMatcherException- if there is an error parsing the specification (i.e. it is somehow malformed)
-
-
Method Detail
-
match
public boolean match(String ipIn) throws IPMatcherException
Determine whether the given full IP falls within the range thisIPMatcherwas initialized with.- Parameters:
ipIn- IP address as dot-delimited String- Returns:
trueif the IP matches the range of thisIPMatcher;falseotherwise- Throws:
IPMatcherException- if the IP passed in cannot be parsed correctly (i.e. is malformed)
-
-