mmhttp.server
Class Authenticator

java.lang.Object
  extended by mmhttp.server.Authenticator
Direct Known Subclasses:
PromiscuousAuthenticator

public abstract class Authenticator
extends java.lang.Object

Base class for all authentication implementations. HTTP 1.1 allows for digest authentication whereby a username and password may be provided in the request headers. To make use of the digest authentication and require login for various parts of your site, you must provide the server with an implementation of Authenticator.


Constructor Summary
Authenticator()
           
 
Method Summary
 Responder authenticate(Server server, Request request, Responder privilegedResponder)
          This is the primary method used for authenticating a user for a given request.
abstract  boolean isAuthenticated(java.lang.String username, java.lang.String password)
          Should be overriden to validate the credentials.
 boolean isRestricted(Responder privilegedResponder)
          Should be overridden to determine if the specifed Responder should require a valid user to be logged in.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Authenticator

public Authenticator()
Method Detail

authenticate

public Responder authenticate(Server server,
                              Request request,
                              Responder privilegedResponder)
                       throws java.lang.Exception
This is the primary method used for authenticating a user for a given request. Typically, you will not wat to override this method, though you may. By default the credentials will be pulled out of the request and cheched for validity. If the credentials are not valid, the Responder is checked to see if it is restricted. If the Responder is restricted and the credentials are not valid, then the request will not be processed an Unauthorized response will be returned.

Parameters:
server -
request -
privilegedResponder -
Returns:
a Responder, either the requested one or an UnauthorizedResponder
Throws:
java.lang.Exception

isRestricted

public boolean isRestricted(Responder privilegedResponder)
Should be overridden to determine if the specifed Responder should require a valid user to be logged in.

Parameters:
privilegedResponder -
Returns:
false by default

isAuthenticated

public abstract boolean isAuthenticated(java.lang.String username,
                                        java.lang.String password)
                                 throws java.lang.Exception
Should be overriden to validate the credentials.

Parameters:
username -
password -
Returns:
true is the user credentials are valid
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009 Micah Martin. All Rights Reserved.