SPT Core API

com.sptci.auth.digest
Class Authenticator

java.lang.Object
  extended by com.sptci.auth.digest.Authenticator
All Implemented Interfaces:
com.withay.http.PasswordRetriever
Direct Known Subclasses:
DatabaseAuthenticator

public abstract class Authenticator
extends Object
implements com.withay.http.PasswordRetriever

An abstract PasswordRetriever implementation that performs authentication.

Copyright 2006, Sans Pareil Technologies, Inc.

Version:
$Id: Authenticator.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2006-11-15

Nested Class Summary
protected static class Authenticator.ManagerTask
          A TimerTask that is used to clear the userMap periodically.
 
Field Summary
protected static Logger logger
          The logger that is used to log errors or other messages.
protected  User user
          The User object that was fetched through the authentication request.
protected static Map<String,User> userMap
          A Map used to cache userName and User values.
protected  String userName
          The username that was specified in the authentication request.
 
Constructor Summary
Authenticator()
           
 
Method Summary
protected abstract  User fetchUser()
          Fetch the user object from the data store and populate the fields of user.
 String getPassword(String userName)
          Implementation of the PasswordRetriever.getPassword method.
 User getUser()
          Returns user.
 String getUserName()
          Returns userName.
protected  void setUser(User user)
          Set user.
protected  void setUserName(String userName)
          Set userName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger
The logger that is used to log errors or other messages.


userMap

protected static final Map<String,User> userMap
A Map used to cache userName and User values. Users who do not exist will be stored with a null object.


user

protected User user
The User object that was fetched through the authentication request.


userName

protected String userName
The username that was specified in the authentication request.

Constructor Detail

Authenticator

public Authenticator()
Method Detail

getPassword

public String getPassword(String userName)
                   throws com.withay.http.PasswordRetrievalException
Implementation of the PasswordRetriever.getPassword method. Find the User object corresponding to the userName specified.

Specified by:
getPassword in interface com.withay.http.PasswordRetriever
Parameters:
userName - - The User.userName of the user
Returns:
String - The password for the user.
Throws:
com.withay.http.PasswordRetrievalException - - If the userName specified could not be found in the users table.
See Also:
fetchUser()

fetchUser

protected abstract User fetchUser()
                           throws com.withay.http.PasswordRetrievalException
Fetch the user object from the data store and populate the fields of user. Adds a new entry into userMap.

Returns:
User The properly initialised object.
Throws:
com.withay.http.PasswordRetrievalException - If errors are encountered while fetching the database object.

getUser

public User getUser()
Returns user.

Returns:
The value/reference of/to user.

setUser

protected void setUser(User user)
Set user.

Parameters:
user - The value to set.

getUserName

public String getUserName()
Returns userName.

Returns:
The value/reference of/to userName.

setUserName

protected void setUserName(String userName)
Set userName.

Parameters:
userName - The value to set.

SPT Core API