|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcox.jmatt.java.MathTools.util.SimpleAuthenticator
public class SimpleAuthenticator
This class provides a fully-functional MAuthenticator
implementation. It can be used as-is for authentication code generation or it can serve
as an example of how an implementation should work. To function properly SimpleAuthenticator
must be initialized with a prime number. There is a
default value but another can be used if desired. The number should be at least three digits but no more than five and it must be prime otherwise duplicate
codes may be generated.
Three levels of codes are generated: Student, Proctor, and Instructor. ADMIN and NONE automatically authenticate to false. The code formats are:
All necessary information is contained within the authentication code itself. Nothing outside this class is required to generate or use the codes. More complex or secure implementations might look up information from a database or a dedicated server; but such is beyond the scope of this class.
IMPORTANT NOTE: Although this implementation is self-contained, codes will not work if the authenticator is initialized with a value different from the one used to generate them!
Field Summary | |
---|---|
static java.lang.String |
MYSELF
String constant holding the fully-qualified class name. |
Fields inherited from interface cox.jmatt.java.MathTools.util.MAuthenticator |
---|
AUTH_ADMIN, AUTH_INSTRUCTOR, AUTH_NONE, AUTH_PROCTOR, AUTH_STUDENT |
Constructor Summary | |
---|---|
SimpleAuthenticator()
Zero-argument constructor required for CapCom use. |
Method Summary | |
---|---|
java.lang.String[] |
generateCodes(byte pLevel,
int pNumberOf,
java.lang.Object... pIgnored)
Generate codes. |
void |
initMAuthenticator(java.lang.Object pPrimeInt)
All authentication codes operate around a non-negative prime integer. |
boolean |
mAuthenticate(byte pLevel,
java.lang.String pCode)
Authenticate a code. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MYSELF
Constructor Detail |
---|
public SimpleAuthenticator()
CapCom
use.
Method Detail |
---|
public final void initMAuthenticator(java.lang.Object pPrimeInt)
initMAuthenticator
in interface MAuthenticator
pPrimeInt
- A non-negative prime integer (int or long), sent in as a String.public final boolean mAuthenticate(byte pLevel, java.lang.String pCode)
mAuthenticate
in interface MAuthenticator
pLevel
- The AUTH_ constant for the desired authentication level.pCode
- The authentication code to check at the specified level.
public final java.lang.String[] generateCodes(byte pLevel, int pNumberOf, java.lang.Object... pIgnored)
generateCodes
in interface MAuthenticator
pLevel
- The level of authentication codes to generate.pNumberOf
- The number of codes to generate. If less than one, one is generated.pIgnored
- Not used.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |