FileDocCategorySizeDatePackage
AbstractNetworkMatcher.javaAPI DocApache James 2.3.13588Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.matchers

AbstractNetworkMatcher

public abstract class AbstractNetworkMatcher extends org.apache.mailet.GenericMatcher
AbstractNetworkMatcher makes writing IP Address matchers easier. AbstractNetworkMatcher provides a means for checking to see whether a particular IP address or domain is within a set of subnets These subnets may be expressed in one of several formats: Format Example explicit address 127.0.0.1 address with a wildcard 127.0.0.* domain name myHost.com domain name + prefix-length myHost.com/24 domain name + mask myHost.com/255.255.255.0 IP address + prefix-length 127.0.0.0/8 IP + mask 127.0.0.0/255.0.0.0 For more information, see also: RFC 1518 and RFC 1519.
version
$ID$

Fields Summary
private org.apache.james.util.NetMatcher
authorizedNetworks
This is a Network Matcher that should be configured to contain authorized networks
Constructors Summary
Methods Summary
protected java.util.CollectionallowedNetworks()

        Collection networks = null;
        if (getCondition() != null) {
            StringTokenizer st = new StringTokenizer(getCondition(), ", ", false);
            networks = new java.util.ArrayList();
            while (st.hasMoreTokens()) networks.add(st.nextToken());
        }
        return networks;
    
public voidinit()


         
        Collection nets = allowedNetworks();
        if (nets != null) {
            authorizedNetworks = new NetMatcher() {
                protected void log(String s) {
                    AbstractNetworkMatcher.this.log(s);
                }
            };
            authorizedNetworks.initInetNetworks(allowedNetworks());
            log("Authorized addresses: " + authorizedNetworks.toString());
        }
    
protected booleanmatchNetwork(java.net.InetAddress addr)

        return authorizedNetworks == null ? false : authorizedNetworks.matchInetNetwork(addr);
    
protected booleanmatchNetwork(java.lang.String addr)

        return authorizedNetworks == null ? false : authorizedNetworks.matchInetNetwork(addr);