rabbit.filter
Class HTTPBaseFilter

java.lang.Object
  extended by rabbit.filter.HTTPBaseFilter
All Implemented Interfaces:
HTTPFilter

public class HTTPBaseFilter
extends java.lang.Object
implements HTTPFilter

This is a class that filter http headers to make them nice. This filter sets up username and password if supplied and also sets up keepalive.


Field Summary
static java.lang.String NOPROXY
           
 
Constructor Summary
HTTPBaseFilter()
           
 
Method Summary
 HTTPHeader doHTTPInFiltering(java.net.Socket socket, HTTPHeader header, Connection con)
          test if a socket/header combination is valid or return a new HTTPHeader.
 HTTPHeader doHTTPOutFiltering(java.net.Socket socket, HTTPHeader header, Connection con)
          test if a socket/header combination is valid or return a new HTTPHeader.
 java.util.Map<java.lang.String,java.lang.String> getUsers()
          Return the hash of users.
 boolean isPublic(java.net.URL url)
          Check if a given url is a public URL of the Proxy.
 boolean isValidUser(java.lang.String username, java.lang.String password)
          Check if a user/password combination is valid.
static java.util.Map<java.lang.String,java.lang.String> loadUsers(java.io.Reader r)
          Load the users from the given Reader.
 void saveUsers(java.io.Reader r)
          Saves the users from the given Reader.
 void setup(Logger logger, SProperties properties)
          Setup this class with the given properties.
 void setUsers(java.util.Map<java.lang.String,java.lang.String> users)
          Return the hash of users.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOPROXY

public static final java.lang.String NOPROXY
See Also:
Constant Field Values
Constructor Detail

HTTPBaseFilter

public HTTPBaseFilter()
Method Detail

doHTTPInFiltering

public HTTPHeader doHTTPInFiltering(java.net.Socket socket,
                                    HTTPHeader header,
                                    Connection con)
test if a socket/header combination is valid or return a new HTTPHeader.

Specified by:
doHTTPInFiltering in interface HTTPFilter
Parameters:
socket - the Socket that made the request.
header - the actual request made.
con - the Connection handling the request.
Returns:
null if everything is fine or a HTTPHeader describing the error (like a 403).

doHTTPOutFiltering

public HTTPHeader doHTTPOutFiltering(java.net.Socket socket,
                                     HTTPHeader header,
                                     Connection con)
test if a socket/header combination is valid or return a new HTTPHeader.

Specified by:
doHTTPOutFiltering in interface HTTPFilter
Parameters:
socket - the Socket that made the request.
header - the actual request made.
con - the Connection handling the request.
Returns:
null if everything is fine or a HTTPHeader describing the error (like a 403).

setup

public void setup(Logger logger,
                  SProperties properties)
Setup this class with the given properties.

Specified by:
setup in interface HTTPFilter
Parameters:
properties - the new configuration of this class.
logger - the Logger to output errors/warnings on.

loadUsers

public static java.util.Map<java.lang.String,java.lang.String> loadUsers(java.io.Reader r)
                                                                  throws java.io.IOException
Load the users from the given Reader.

Parameters:
r - the Reader with the users.
Throws:
java.io.IOException

saveUsers

public void saveUsers(java.io.Reader r)
               throws java.io.IOException
Saves the users from the given Reader.

Parameters:
r - the Reader with the users.
Throws:
java.io.IOException

getUsers

public java.util.Map<java.lang.String,java.lang.String> getUsers()
Return the hash of users.


setUsers

public void setUsers(java.util.Map<java.lang.String,java.lang.String> users)
Return the hash of users.


isValidUser

public boolean isValidUser(java.lang.String username,
                           java.lang.String password)
Check if a user/password combination is valid.

Parameters:
username - the username.
password - the decrypted password.
Returns:
true if both username and password match a valid user.

isPublic

public boolean isPublic(java.net.URL url)
Check if a given url is a public URL of the Proxy.

Parameters:
url - the URL to check.
Returns:
true if this url has public access, false otherwise.