pygmy.handlers
Class BasicWebAuthHandler

java.lang.Object
  extended by pygmy.core.AbstractHandler
      extended by pygmy.handlers.BasicWebAuthHandler
All Implemented Interfaces:
Handler

public class BasicWebAuthHandler
extends AbstractHandler
implements Handler

This handler implements the Basic web authentication protocol outlined in RFC 2617. This handler sits in front of a set of handlers within a chain see DefaultChainHandler. Everything it's in front of will be protected. It checks it's url-prefix configuration to know when it should handle a request. Properties used for configuring:

Parameter NameExplanationDefault ValueRequired
url-prefixThe prefix to filter request urls.NoneYes
realmThis is the realm reported to the client. See RFC 2617 for explanation of the realm parameter.NoneYes
usersThis the path to a file containing all the users and their passwords allowed to access this url. To create a file you can run this class and hand it the file, username, and password to create. WARNING do not put this file in a place where it could be downloaded through this server.NoneYes

Here is the syntax for running this class to create a password file:

java pgymy.handlers.BasicWebAuthHandler <file> <username> <password>

An existing file can be added to by calling this program again.


Field Summary
static ConfigOption REALM_OPTION
           
static ConfigOption USERS_OPTION
           
 
Fields inherited from class pygmy.core.AbstractHandler
handlerName, server, URL_PREFIX_OPTION, urlPrefix
 
Constructor Summary
BasicWebAuthHandler()
           
 
Method Summary
protected  boolean handleBody(HttpRequest request, HttpResponse response)
           
 boolean initialize(java.lang.String handlerName, Server server)
           
static void main(java.lang.String[] args)
           
 boolean shutdown(Server server)
           
 
Methods inherited from class pygmy.core.AbstractHandler
getMimeType, getName, getUrlPrefix, handle, isRequestdForHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface pygmy.core.Handler
getName, handle
 

Field Detail

REALM_OPTION

public static final ConfigOption REALM_OPTION

USERS_OPTION

public static final ConfigOption USERS_OPTION
Constructor Detail

BasicWebAuthHandler

public BasicWebAuthHandler()
Method Detail

initialize

public boolean initialize(java.lang.String handlerName,
                          Server server)
Specified by:
initialize in interface Handler
Overrides:
initialize in class AbstractHandler

handleBody

protected boolean handleBody(HttpRequest request,
                             HttpResponse response)
                      throws java.io.IOException
Overrides:
handleBody in class AbstractHandler
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.security.NoSuchAlgorithmException
Throws:
java.io.IOException
java.security.NoSuchAlgorithmException

shutdown

public boolean shutdown(Server server)
Specified by:
shutdown in interface Handler
Overrides:
shutdown in class AbstractHandler