ecologylab.services.authentication
Class AuthenticationListEntry

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.ElementState
          extended by ecologylab.services.authentication.AuthenticationListEntry
All Implemented Interfaces:
AuthLevels, FieldTypes, Mappable<java.lang.String>, XMLTranslationExceptionTypes

public class AuthenticationListEntry
extends ElementState
implements AuthLevels, Mappable<java.lang.String>

An entry for an AuthenticationList. Contains a username matched with a password (which is stored and checked as a SHA-256 hash). This class can be extended to include other pieces of information, such as real names and email addresses; if desired.

Author:
Zachary O. Toups (toupsz@cs.tamu.edu)

Nested Class Summary
 
Nested classes/interfaces inherited from class ecologylab.xml.ElementState
ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_bind_from, ElementState.xml_bind_to, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_format, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_nowrap, ElementState.xml_other_tags, ElementState.xml_scope, ElementState.xml_tag, ElementState.xml_text
 
Field Summary
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, NORMAL, UTF16, UTF16_LE, UTF8
 
Fields inherited from interface ecologylab.services.authentication.AuthLevels
ADMINISTRATOR, NORMAL_USER
 
Fields inherited from interface ecologylab.xml.FieldTypes
ATTRIBUTE, AWFUL_OLD_NESTED_ELEMENT, BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, NESTED_ELEMENT, PSEUDO_FIELD_DESCRIPTOR, ROOT, TEXT_ELEMENT, TEXT_NODE_VALUE, UNSET_TYPE, WRAPPER, XMLNS_ATTRIBUTE, XMLNS_IGNORED
 
Fields inherited from interface ecologylab.xml.XMLTranslationExceptionTypes
FILE_NOT_FOUND, IO_EXCEPTION, NULL_PURL, UNKNOWN
 
Constructor Summary
AuthenticationListEntry()
          No-argument constructor for serialization.
AuthenticationListEntry(java.lang.String username, java.lang.String plaintextPassword)
          Creates a new AuthenticationListEntry with the given username and password.
 
Method Summary
 boolean compareHashedPassword(java.lang.String hashedPassword)
          Compares the given hashed password (such as the kind from the getPassword() method) to the one contained in this object.
 boolean comparePassword(java.lang.String plaintextPassword)
          Compares the given unhashed password against the one stored here by hashing it, then comparing it.
 int getLevel()
           
 java.lang.String getUsername()
           
 int hashCode()
          Returns hashCode() called on username.
 java.lang.String key()
           
 void setAndHashPassword(java.lang.String plaintextPassword)
          Uses SHA-256 encryption to store the password passed to it.
 void setLevel(int level)
           
 void setUsername(java.lang.String username)
          Sets the username of the AuthenticationListEntry.
 java.lang.String toString()
           
 
Methods inherited from class ecologylab.xml.ElementState
buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, classDescriptor, createParentDirs, getChildFieldAccessors, getElementStateById, getFieldDescriptors, getNestedNameSpace, getTextNodeString, hasScalarTextField, lookupNestedNameSpace, parent, recycle, setDeclarationStyle, setParent, setUseDOMForTranslateTo, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXMLCharSequence, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOMCharSequence, translateFromXMLDOMCharSequence, translateFromXMLRootNode, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateToDOM, translateToXML, translateToXML, translateToXML, translateToXML, writePrettyXML, writePrettyXML, writePrettyXML
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AuthenticationListEntry

public AuthenticationListEntry()
No-argument constructor for serialization.


AuthenticationListEntry

public AuthenticationListEntry(java.lang.String username,
                               java.lang.String plaintextPassword)
Creates a new AuthenticationListEntry with the given username and password.

Parameters:
username - - the name of the user.
plaintextPassword - - the password; will be hashed before it is stored.
Method Detail

setUsername

public void setUsername(java.lang.String username)
Sets the username of the AuthenticationListEntry.

Parameters:
username - - the username to set.

setAndHashPassword

public void setAndHashPassword(java.lang.String plaintextPassword)
Uses SHA-256 encryption to store the password passed to it.

Parameters:
plaintextPassword - - the password to hash and store.

compareHashedPassword

public boolean compareHashedPassword(java.lang.String hashedPassword)
Compares the given hashed password (such as the kind from the getPassword() method) to the one contained in this object.

Parameters:
hashedPassword - - the password to check.
Returns:
true if the passwords are identical, false otherwise.

comparePassword

public boolean comparePassword(java.lang.String plaintextPassword)
Compares the given unhashed password against the one stored here by hashing it, then comparing it.

Parameters:
plaintextPassword - - the unhashed password to check.
Returns:
true if the passwords are identical, false otherwise.

getUsername

public java.lang.String getUsername()
Returns:
Returns the username.

hashCode

public int hashCode()
Returns hashCode() called on username.

Overrides:
hashCode in class java.lang.Object

getLevel

public int getLevel()
Returns:
the level

setLevel

public void setLevel(int level)
Parameters:
level - the level to set

toString

public java.lang.String toString()
Overrides:
toString in class Debug
See Also:
Debug.toString()

key

public java.lang.String key()
Specified by:
key in interface Mappable<java.lang.String>