net.anotheria.net.util
Class PlainIPFilter

java.lang.Object
  extended by net.anotheria.net.util.PlainIPFilter

public class PlainIPFilter
extends Object

This is a helper class which determines whether an ip adress is in specified range. Used for cms access control among others.

Author:
lrosenberg

Constructor Summary
PlainIPFilter()
          Creates a new filter.
 
Method Summary
 void addRange(String ipAdress, int mask)
          Adds an ip (allowed)range to the filter.
static void main(String[] a)
           
 boolean mayPass(String ipAddress)
          Returns true if the parameter ip-adress is in one of the configured ranges.
static boolean mayPass(String ipAddress, List<IPRange> ranges)
          Returns true if the parameter ip-adress is in one of the ranges.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlainIPFilter

public PlainIPFilter()
Creates a new filter.

Method Detail

addRange

public void addRange(String ipAdress,
                     int mask)
Adds an ip (allowed)range to the filter. For example 10.0.0.0/8 will allow each ip adress starting with 10 to pass.

Parameters:
ipAdress - an adress.
mask - a network (byte)mask.

mayPass

public static boolean mayPass(String ipAddress,
                              List<IPRange> ranges)
Returns true if the parameter ip-adress is in one of the ranges.

Parameters:
ipAdress - the adress to check.
ranges - to pass through
Returns:

mayPass

public boolean mayPass(String ipAddress)
Returns true if the parameter ip-adress is in one of the configured ranges.

Parameters:
ipAdress - the adress to check.
Returns:

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] a)


Copyright © 2010-2013 anotheria.net. All Rights Reserved.