public final class AccessRule extends Object implements AccessRuleContainer
AccessRule object from it.
A descriptor must comply to the following format:
"allow" or "deny";
'/');
SimplePatternParser.
Example of access rule descriptors:
"allow 194.134.168.213/32 *""deny 194.134.168.213/24 _*"'_').| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Disposes this access rule.
|
IPFilter |
getIPFilter()
Returns the IP filter.
|
Boolean |
isAllowed(String ip,
String functionName,
String conventionName)
Determines if the specified IP address is allowed to access the
specified function, returning a
Boolean object or
null. |
boolean |
isAllowRule()
Returns if this rule is an allow or a deny rule.
|
boolean |
match(String ip,
String functionName,
String conventionName)
Determines if the specified IP address and function match this rule.
|
static AccessRule |
parseAccessRule(String descriptor)
Parses the specified character string to construct a new
AccessRule object. |
String |
toString()
Returns a character string representation of this object.
|
public static AccessRule parseAccessRule(String descriptor) throws IllegalArgumentException, ParseException
AccessRule object.descriptor - the access rule descriptor, the character string to parse, cannot be
null.AccessRule instance, never null.IllegalArgumentException - if descriptor == null.ParseException - If there was a parsing error.public boolean isAllowRule()
true if this is an allow rule, or
false if this is a deny rule.public IPFilter getIPFilter()
IPFilter associated with this access rule, never
null.public boolean match(String ip, String functionName, String conventionName) throws IllegalStateException, IllegalArgumentException, ParseException
Calling this function is equivalent to calling:
isAllowed(ip,
functionName) != nullip - the IP address to match, cannot be null.functionName - the name of the function to match, cannot be null.conventionName - the name of the calling convention to match, can be null.true if this rule matches, false otherwise.IllegalStateException - if this access rule is disposed (since XINS 1.3.0).IllegalArgumentException - if ip == null || functionName == null.ParseException - if the specified IP address cannot be parsed.public Boolean isAllowed(String ip, String functionName, String conventionName) throws IllegalStateException, IllegalArgumentException, ParseException
Boolean object or
null.
This method finds the first matching rule and then returns the
allow property of that rule (see
isAllowRule()). If there is no matching rule, then
null is returned.
isAllowed in interface AccessRuleContainerip - the IP address, cannot be null.functionName - the name of the function, cannot be null.conventionName - the name of the calling convention, can be null.Boolean.TRUE if the specified IP address is allowed to access
the specified function, Boolean.FALSE if it is disallowed
access or null if there is no match.IllegalStateException - if this object is disposed (since XINS 1.3.0).IllegalArgumentException - if ip == null || functionName == null.ParseException - if the specified IP address is malformed.public void dispose()
Once disposed, neither match(java.lang.String, java.lang.String, java.lang.String) nor isAllowed(java.lang.String, java.lang.String, java.lang.String) should
be called.
dispose in interface AccessRuleContainerIllegalStateException - if this access rule is already disposed (since XINS 1.3.0).public String toString()
type a.b.c.d/m patternwhere type is either
"allow" or
"deny", a.b.c.d is the base IP address, m
is the mask, and pattern is the function name simple pattern.See http://www.xins.org/.