Sea 0.4.0

gov.lbl.dsd.sea.nio.auth
Class SmartHostAuthorizationRules

java.lang.Object
  extended bygov.lbl.dsd.sea.nio.auth.SmartHostAuthorizationRules
All Implemented Interfaces:
HostAuthorizationRules, Serializable

public class SmartHostAuthorizationRules
extends Object
implements HostAuthorizationRules, Serializable

Powerful authorization rules to be used by SmartHostAuthorizer; Supports allow and deny rules based on exact or patterned DNS host names, exact or patterned IP addresses, as well as regular expressions on "hostName/IPaddress" pairs.

Can be configured programmatically or via a configuration file (see file "authorization.properties") for an example.

Version:
$Revision: 1.7 $, $Date: 2004/12/01 20:59:31 $
See Also:
Serialized Form

Field Summary
static String ALL
          Meta match all hosts (no matter what DNS name or IP address)
static String COMMON_DOMAIN
          Relative to localhost, meta match hosts in the same DNS domain
static String COMMON_SUBNET
          Relative to localhost, meta match hosts in the same IP subnet
static String LOOPBACK
          Relative to localhost, meta match loopback hosts (including localhost)
 
Constructor Summary
SmartHostAuthorizationRules()
          Creates an empty instance with no rules (isMatch(x) returns false).
 
Method Summary
 SmartHostAuthorizationRules addHost(String host)
          Adds the given host or pattern to the set of rules.
 SmartHostAuthorizationRules addRegex(String regex)
          Adds the given regular expression on "hostName/IPaddress" to the set of rules.
static SmartHostAuthorizer createHostAuthorizer(ExtendedProperties properties)
          Creates an authorizer from the given configuration properties.
static SmartHostAuthorizer createHostAuthorizer(String fileName)
          Creates an authorizer from the properties in the given configuration file.
 boolean isMatch(InetAddress address)
          Returns whether or not the given host (aka InetAddress) matches ANY of the current rules.
static void main(String[] args)
          Program to quickly test whether or not a given host is allowed; Useful to assist in becoming familiar with the configuration file syntax; Example usage: java [class] [configFileName] [hostName]
 String toString()
          Returns a summary string representation of the receiver.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final String ALL
Meta match all hosts (no matter what DNS name or IP address)

See Also:
Constant Field Values

LOOPBACK

public static final String LOOPBACK
Relative to localhost, meta match loopback hosts (including localhost)

See Also:
Constant Field Values

COMMON_DOMAIN

public static final String COMMON_DOMAIN
Relative to localhost, meta match hosts in the same DNS domain

See Also:
Constant Field Values

COMMON_SUBNET

public static final String COMMON_SUBNET
Relative to localhost, meta match hosts in the same IP subnet

See Also:
Constant Field Values
Constructor Detail

SmartHostAuthorizationRules

public SmartHostAuthorizationRules()
Creates an empty instance with no rules (isMatch(x) returns false).

Method Detail

createHostAuthorizer

public static SmartHostAuthorizer createHostAuthorizer(ExtendedProperties properties)
Creates an authorizer from the given configuration properties.

Parameters:
properties - the configuration properties to use

createHostAuthorizer

public static SmartHostAuthorizer createHostAuthorizer(String fileName)
                                                throws IOException
Creates an authorizer from the properties in the given configuration file.

Parameters:
fileName - the configuration file to use
Throws:
IOException

addHost

public SmartHostAuthorizationRules addHost(String host)
Adds the given host or pattern to the set of rules.

Parameters:
host - the host to pattern to add.

Exact address example: "131.243.2.165", Prefix patterned address example: "131.243."

Exact name example: "doggy.lbl.gov", Suffix patterned name example: ".lbl.gov"

Meta pattern examples: "all", "loopback", "common-domain", "common-subnet"

Returns:
this (for convenience only)

addRegex

public SmartHostAuthorizationRules addRegex(String regex)
Adds the given regular expression on "hostName/IPaddress" to the set of rules.

Parameters:
regex - Example: "clusternode.+?\.lbl\.gov/.*"
Returns:
this (for convenience only)

isMatch

public boolean isMatch(InetAddress address)
Returns whether or not the given host (aka InetAddress) matches ANY of the current rules.

Specified by:
isMatch in interface HostAuthorizationRules
Returns:
true if at least one rule matches; false otherwise

toString

public String toString()
Returns a summary string representation of the receiver.


main

public static void main(String[] args)
                 throws IOException
Program to quickly test whether or not a given host is allowed; Useful to assist in becoming familiar with the configuration file syntax; Example usage: java [class] [configFileName] [hostName]

Throws:
IOException

Sea 0.4.0