eTextReader.clientInterface
Class DBAuthenticator

java.lang.Object
  extended by eTextReader.clientInterface.DBAuthenticator
All Implemented Interfaces:
Authenticator

public class DBAuthenticator
extends java.lang.Object
implements Authenticator

This class is an Authenticator which stores a user's password in a database; the password is stored in encrypted form using the encryption provided by a StringCrypto object

Author:
mcfall

Nested Class Summary
 
Nested classes/interfaces inherited from interface eTextReader.authentication.Authenticator
Authenticator.AUTHENTICATION_RESULT
 
Field Summary
(package private)  DBClient client
           
(package private)  StringCrypto crypto
           
 
Constructor Summary
DBAuthenticator()
           
 
Method Summary
 Authenticator.AUTHENTICATION_RESULT authenticate(java.lang.Object identity, java.lang.Object secret)
          Attempts to verify the user identified by identity using the supplied secret.
 java.lang.String getOperationalErrorDescription()
          Provides feedback when an Authenticator specific operational error occurs.
 java.lang.String getOtherErrorDescription()
          Provides feedback when a Authenticator specific error condition arises.
 Authenticator.AUTHENTICATION_RESULT updateSecret(java.lang.Object identity, java.lang.Object oldSecret, java.lang.Object newSecret)
          Provides a mechanism for a user's secret to be updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

crypto

StringCrypto crypto

client

DBClient client
Constructor Detail

DBAuthenticator

public DBAuthenticator()
                throws java.io.IOException,
                       java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException
Method Detail

authenticate

public Authenticator.AUTHENTICATION_RESULT authenticate(java.lang.Object identity,
                                                        java.lang.Object secret)
Description copied from interface: Authenticator

Attempts to verify the user identified by identity using the supplied secret.

If the supplied secret matches that known to this Authenticator, then the enum value SUCCESS should be returned. If authentication fails, the Authenticator can choose to provide specific feedback, such as the fact that an unknown identity was presented, at the Authenticator implementor's discretion. If specified feedback is not desired, the enum value FAILED should be returned. Implementors can indicate custom return values through the use of the OTHER_ERROR enum value. If OTHER_ERROR is returned, then the result the method getOtherErrorDescription should return a description of the error so that the user can be provided with feedback.

If an implementation specific error occurs, such as a failure to contact a specific database, then the enum value OPERATIONAL_ERROR should be returned, and the method getOperationalErrorDescription should return a description of the error so that the user can be provided with feedback.

Specified by:
authenticate in interface Authenticator
Parameters:
identity - an object used to identify a given individual
secret - an object known/possessed by only the individual identified by identity
Returns:
an AUTHENTICATION_RESULT object indicating the results of authenticating the given entity

getOperationalErrorDescription

public java.lang.String getOperationalErrorDescription()
Description copied from interface: Authenticator
Provides feedback when an Authenticator specific operational error occurs. If a previous call to either authenticate or updateSecret has not result in a return value of OTHER_ERROR, then this method may return invalid information.

Specified by:
getOperationalErrorDescription in interface Authenticator
Returns:
a String describing the error that occurred

getOtherErrorDescription

public java.lang.String getOtherErrorDescription()
Description copied from interface: Authenticator
Provides feedback when a Authenticator specific error condition arises. If a previous call to either authenticate or updateSecret has not result in a return value of OTHER_ERROR, then this method may return invalid information.

Specified by:
getOtherErrorDescription in interface Authenticator
Returns:
a String describing the error that occurred

updateSecret

public Authenticator.AUTHENTICATION_RESULT updateSecret(java.lang.Object identity,
                                                        java.lang.Object oldSecret,
                                                        java.lang.Object newSecret)
Description copied from interface: Authenticator
Provides a mechanism for a user's secret to be updated. The user's identity is first verified by calling authenticate using the supplied identity and oldSecret. If this succeeds, the secret is updated.

Specified by:
updateSecret in interface Authenticator
Parameters:
identity - an object used to identify a given user
oldSecret - the user's current secret
newSecret - the new secret to be used for the given user
Returns:
an AUTHENTICATION_RESULT, which should correspond to the description given in the authenticate method.