cox.jmatt.java.MathTools.util
Interface MAuthenticator

All Known Implementing Classes:
SimpleAuthenticator

public interface MAuthenticator

This interface specifies a generic way to authenticate at three levels: student, proctor, and instructor. It is of use if MathTools is deployed as a part of an independent testing package. The specific authentication methodology used is not specified. Rather, authentication is handled very generically at one of the three levels. One method is provided to initialize an implementation ant the other is the acutal authentication method.

The pre-defined authentication levels are:

  1. Student level represents a person taking a test or whose authentication should be the most limited.
  2. Proctor access is for a person giving or proctoring a test; it should be higher than student level.
  3. Instructor level is for the person creating the test and ultimately responsible for its handling and disposition.
Two debugging and development levels are also provided: ADMIN and NONE. The former is for development and program testing, the latter is used to indicate that no authentication level is given/required.

CapCom provides a method to specify a global Authenticator along with a method to check authentication using it. It is set using the full name of the class implementing this interface along with the context Object used to initialize the impementation. Classes implementing the MAuthenticator interface must provide a zero-argument contstructor; CapCom uses it when creating the Authenticator.

Generating Authentication Codes

MAuthenticator specifies the generateCodes() method to generate authentication codes. This method is optional but is provided if needed. Implementations not using it should simply return an empty array. Implementations that do use it must accept an authenticaion level for the codes generated and the number of codes to generate. An Object... parameter is also supplied for implementation-specific use.


Field Summary
static byte AUTH_ADMIN
          Static constant used to indicate authentication at Admin level.
static byte AUTH_INSTRUCTOR
          Static constant used to indicate authentication at Instructor level.
static byte AUTH_NONE
          Static constant used to indicate no authentication level.
static byte AUTH_PROCTOR
          Static constant used to indicate authentication at Proctor level.
static byte AUTH_STUDENT
          Static constant used to indicate authentication at Student level.
 
Method Summary
 java.lang.String[] generateCodes(byte pLevel, int pNum, java.lang.Object... pParams)
          This method, if defined, is used to generate authentication codes at the specified level.
 void initMAuthenticator(java.lang.Object pContext)
          Implement this method to initialize a MAuthenticator implementation.
 boolean mAuthenticate(byte pLevel, java.lang.String pCode)
          The raison d'etre for this interface.
 

Field Detail

AUTH_STUDENT

static final byte AUTH_STUDENT
Static constant used to indicate authentication at Student level.

See Also:
Constant Field Values

AUTH_PROCTOR

static final byte AUTH_PROCTOR
Static constant used to indicate authentication at Proctor level.

See Also:
Constant Field Values

AUTH_INSTRUCTOR

static final byte AUTH_INSTRUCTOR
Static constant used to indicate authentication at Instructor level.

See Also:
Constant Field Values

AUTH_ADMIN

static final byte AUTH_ADMIN
Static constant used to indicate authentication at Admin level. This is intended primarily for debugging and development and should not be used as a deployment level.

See Also:
Constant Field Values

AUTH_NONE

static final byte AUTH_NONE
Static constant used to indicate no authentication level.

See Also:
Constant Field Values
Method Detail

initMAuthenticator

void initMAuthenticator(java.lang.Object pContext)
Implement this method to initialize a MAuthenticator implementation. By intent this method should be called once but can be called more than once. Each call should not only initialize and configure whatever the authenticator needs to function, it should also clear out any old data left from prior use. More specifically, calling this method with the same context Object should yield the same authenticator regardless of whether it is the first, tenth, or hundredth call.

Parameters:
pContext - The context Object containing information necessary to initialize the instance.

mAuthenticate

boolean mAuthenticate(byte pLevel,
                      java.lang.String pCode)
The raison d'etre for this interface. The return value indicates whether or not the supplied authentication code is valid for the level specified.

Parameters:
pLevel - The AUTH_ constant for the desired authentication level.
pCode - The authentication code to check at the specified level.
Returns:
true if the code is valid, false otherwise.

generateCodes

java.lang.String[] generateCodes(byte pLevel,
                                 int pNum,
                                 java.lang.Object... pParams)
This method, if defined, is used to generate authentication codes at the specified level. Implementations that do not use this method should return an empty array but may return null instead. The mandatory arguments are the AUTH_ level of the codes to generate and the number of codes to generate. The Object... argument is supplied for implementations to use as required and must be specified in the documentation!

Parameters:
pLevel - The AUTH_ level constant for the desired codes.
pNum - The number of codes to generate.
pParams - Implementation-specific parameters for generating the codes.