|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xins.server.AccessRule
Access rule. This class can take a character string to produce an
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 _*"
'_'
).
Method Summary | |
void |
dispose()
Disposes this access rule. |
IPFilter |
getIPFilter()
Returns the IP filter. |
Boolean |
isAllowed(String ip,
String functionName)
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)
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
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) throws IllegalStateException, IllegalArgumentException, ParseException
Calling this function is equivalent to calling:
isAllowed
(ip,
functionName) != null
ip
- the IP address to match, cannot be null
.functionName
- the name of the function to match, cannot 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) 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 AccessRuleContainer
ip
- the IP address, cannot be null
.functionName
- the name of the function, cannot 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)
nor isAllowed(java.lang.String, java.lang.String)
should
be called.
dispose
in interface AccessRuleContainer
IllegalStateException
- 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.
null
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |