Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.http.handler
Class IPAccessHandler  view IPAccessHandler download IPAccessHandler.java

java.lang.Object
  extended byorg.mortbay.http.handler.AbstractHttpHandler
      extended byorg.mortbay.http.handler.IPAccessHandler
All Implemented Interfaces:
org.mortbay.http.HttpHandler, org.mortbay.util.LifeCycle, java.io.Serializable

public class IPAccessHandler
extends AbstractHttpHandler

Handler to authenticate access from certain IP-addresses.

A server configuration-XML-file can look something like this:
<Configure class="org.mortbay.jetty.Server">
...
<Call name="addContext">
...
<Call name="addHandler">
<Arg>
<New class="IPAccessHandler">
<Set name="Standard">deny</Set>
<Set name="AllowIP">192.168.0.103</Set>
<Set name="AllowIP">192.168.0.100</Set>
</New>
</Arg>
</Call>
...

This would deny access for everyone except the requests from the IPs 192.168.0.100 and 192.168.0.103.

Version:
v0.1 2002/03/20

Field Summary
(package private)  java.util.Hashtable ips
          Hashtable where the configured IPs are kept
(package private)  boolean standard
          The standard way to deal with not configured IPs (true=allowed)
 
Fields inherited from class org.mortbay.http.handler.AbstractHttpHandler
 
Constructor Summary
IPAccessHandler()
          Constructor for the class
 
Method Summary
 boolean checkIP(java.lang.String ipstring)
          Checks if the given ipstring (x.x.x.x) is authorized or not
 void handle(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response)
          Handles the incoming request
private static void main(java.lang.String[] args)
          Main method for testing & debugging.
 void setAllowIP(java.lang.String ipstring)
          Allow the given ip-address access
 void setDenyIP(java.lang.String ipstring)
          Deny the given ip-address access
 void setStandard(java.lang.String s)
          Set the standard action beeing taken when not registred IPs wants access
 
Methods inherited from class org.mortbay.http.handler.AbstractHttpHandler
getHttpContext, getName, handleTrace, initialize, isStarted, setName, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

standard

boolean standard
The standard way to deal with not configured IPs (true=allowed)


ips

java.util.Hashtable ips
Hashtable where the configured IPs are kept

Constructor Detail

IPAccessHandler

public IPAccessHandler()
Constructor for the class

Method Detail

checkIP

public boolean checkIP(java.lang.String ipstring)
Checks if the given ipstring (x.x.x.x) is authorized or not


handle

public void handle(java.lang.String pathInContext,
                   java.lang.String pathParams,
                   org.mortbay.http.HttpRequest request,
                   org.mortbay.http.HttpResponse response)
            throws org.mortbay.http.HttpException,
                   java.io.IOException
Handles the incoming request


setAllowIP

public void setAllowIP(java.lang.String ipstring)
Allow the given ip-address access


setDenyIP

public void setDenyIP(java.lang.String ipstring)
Deny the given ip-address access


setStandard

public void setStandard(java.lang.String s)
Set the standard action beeing taken when not registred IPs wants access


main

private static void main(java.lang.String[] args)
Main method for testing & debugging.