|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xins.server.IPFilter
An IPFilter
instance is created using a so-called
filter expression. This filter expression specifies the IP address
and mask to use for matching a subject IP address.
A filter expression must match the following format:
"a.a.a.a"
, optionally followed by:/n
, where a is a number between 0 and 255, with no leading zeroes, and n is a number between 0 and 32, no leading zeroes; if n is not specified.
An IPFilter
object is
created and used as follows:
IPFilter filter = IPFilter.parseFilter("10.0.0.0/24");
if (filter.match("10.0.0.1")) {
// IP is granted access
} else {
// IP is denied access
}
Method Summary | |
String |
getBaseIP()
Returns the base IP address. |
String |
getExpression()
Returns the filter expression. |
int |
getMask()
Returns the mask. |
boolean |
match(String ipString)
Determines if the specified IP address is authorized. |
static IPFilter |
parseIPFilter(String expression)
Creates an IPFilter object for the specified filter
expression. |
String |
toString()
Returns a textual representation of this filter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public static final IPFilter parseIPFilter(String expression) throws IllegalArgumentException, ParseException
IPFilter
object for the specified filter
expression. The expression consists of a base IP address and a bit
count. The bit count indicates how many bits in an IP address must match
the bits in the base IP address.
expression
- the filter expression, cannot be null
and must match
the format for a filter expression.
then 32 is assumed.
IPFilter
object, never
null
.
IllegalArgumentException
- if expression == null
.
ParseException
- if expression
does not match the specified format.public final String getExpression()
null
.public final String getBaseIP()
a.a.a.a/n
,
where a is a number between 0 and 255, with no leading
zeroes; never null
.public final int getMask()
public final boolean match(String ipString) throws IllegalArgumentException, ParseException
ipString
- the IP address of which must be determined if it is authorized,
cannot be null
and must match the form:
a.a.a.a/n
,
where a is a number between 0 and 255, with no leading
zeroes.
true
if the IP address is authorized to access the
protected resource, otherwise false
.
IllegalArgumentException
- if ipString == null
.
ParseException
- if ip
does not match the specified format.public final String toString()
null
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |