org.xins.server
Class AccessRuleFile

java.lang.Object
  extended byorg.xins.server.AccessRuleFile
All Implemented Interfaces:
AccessRuleContainer

public class AccessRuleFile
extends Object
implements AccessRuleContainer

Collection of access rules that are read from a separate file.

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.

Since:
XINS 1.1.0
Version:
$Revision: 1.28 $ $Date: 2006/10/25 09:39:35 $
Author:
Ernst de Haan, Anthony Goubard

Constructor Summary
AccessRuleFile(String descriptor, int interval)
          Constructs a new AccessRuleFile based on a descriptor and a file watch interval.
 
Method Summary
 void dispose()
          Disposes this access rule.
 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccessRuleFile

public AccessRuleFile(String descriptor,
                      int interval)
               throws IllegalArgumentException,
                      ParseException
Constructs a new AccessRuleFile based on a descriptor and a file watch interval.

If the specified interval is 0, then no watching will be performed.

Parameters:
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.
Throws:
ParseException - If the token is incorrectly formatted.
IllegalArgumentException - if descriptor == null || interval < 0.
Method Detail

isAllowed

public Boolean isAllowed(String ip,
                         String functionName)
                  throws IllegalArgumentException,
                         ParseException
Determines if the specified IP address is allowed to access the specified function, returning a 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.

Specified by:
isAllowed in interface AccessRuleContainer
Parameters:
ip - the IP address, cannot be null.
functionName - the name of the function, cannot be null.
Returns:
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.
Throws:
IllegalArgumentException - if ip == null || functionName == null.
ParseException - if the specified IP address is malformed.

dispose

public void dispose()
             throws IllegalStateException
Disposes this access rule. All claimed resources are freed as much as possible.

Once disposed, the isAllowed(java.lang.String, java.lang.String) method should no longer be called.

Specified by:
dispose in interface AccessRuleContainer
Throws:
IllegalStateException - if dispose() has been called previously (since XINS 1.3.0).

toString

public String toString()


See http://www.xins.org/.