public class AccessRuleFile extends Object implements AccessRuleContainer
An AccessRuleFile
instance is constructed using a
descriptor and a file watch interval. The descriptor is a character string
that is parsed to determine which file should be parsed and monitored for
changes. Such a descriptor must match the following pattern:
file filename
where filename is the name of the file to parse and watch.
The file watch interval is specified in seconds. At the specified interval, the file will be checked for modifications. If there are any modifications, then the file is reloaded and the access rules are re-applied.
If the file watch interval is set to 0
, then the watching
is disabled, and no automatic reloading will be performed.
Constructor and Description |
---|
AccessRuleFile(String descriptor,
int interval)
Constructs a new
AccessRuleFile based on a descriptor and
a file watch interval. |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes this access rule.
|
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 . |
String |
toString() |
public AccessRuleFile(String descriptor, int interval) throws IllegalArgumentException, ParseException
AccessRuleFile
based on a descriptor and
a file watch interval.
If the specified interval is 0
, then no watching will be
performed.
descriptor
- the access rule file descriptor, the character string to parse,
cannot be null
.interval
- the interval to check the ACL file for modifications, in seconds,
must be >= 0.ParseException
- If the token is incorrectly formatted.IllegalArgumentException
- if descriptor == null || interval < 0
.public Boolean isAllowed(String ip, String functionName, String conventionName) throws IllegalArgumentException, ParseException
Boolean
object or
null
.
This method finds the first matching rule and then returns the
allow property of that rule (see
AccessRule.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
.conventionName
- the name of the calling convention to match, 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.IllegalArgumentException
- if ip == null || functionName == null
.ParseException
- if the specified IP address is malformed.public void dispose() throws IllegalStateException
Once disposed, the isAllowed(java.lang.String, java.lang.String, java.lang.String)
method should no longer be
called.
dispose
in interface AccessRuleContainer
IllegalStateException
- if dispose()
has been called previously
(since XINS 1.3.0).See http://www.xins.org/.