com.strangelight.db
Class User

java.lang.Object
  |
  +--com.strangelight.db.TableRow
        |
        +--com.strangelight.db.KeyedRow
              |
              +--com.strangelight.db.User

public class User
extends KeyedRow

This class encapsulates a user of the strangelight.com system. Persistent information about this user is stored in the strangelight database. Changes made to a User object will be transferred to persistent storage in the database when the object is garbage-collected, or when the object's commit() method is called.

See Also:
UserServlet

Constructor Summary
User()
          Creates a new User object, which will be transferred to persistent storage in the database when this User object is garbage-collected, or when this User object's commit() method is called.
User(int uid)
          Attempts to fetch a User object from the database given a user's numerical id.
User(int uid, Cleartext password)
          Attempts to fetch a User object from the database, given a user's numerical id and (cleartext) password.
User(int uid, Cryptword password)
          Attempts to fetch a User object from the database, given a user's numerical id and (encrypted) password.
User(java.lang.Integer uid)
          Attempts to fetch a User object from the database given a user's numerical id.
User(java.lang.Integer uid, Cleartext password)
          Attempts to fetch a User object from the database, given a user's numerical id and (cleartext) password.
User(java.lang.Integer uid, Cryptword password)
          Attempts to fetch a User object from the database, given a user's numerical id and (encrypted) password.
User(java.lang.String username)
          Attempts to fetch a User object from the database given a username.
User(java.lang.String username, Cleartext password)
          Attempts to fetch a User object from the database, given a username and (cleartext) password.
User(java.lang.String username, Cryptword password)
          Attempts to fetch a User object from the database, given a username and (encrypted) password.
 
Method Summary
 void finalize()
           
static Cleartext genRandomPassword()
          generates a truly random 6-character alphanumeric string for use as a random password.
 java.lang.String get_email()
          gets this user's email address.
 java.lang.String get_login()
          gets this user's login name (username).
 Cryptword get_passwd()
          gets this user's (encrypted) password.
protected  java.lang.String getTableName()
           
 boolean is_passwd(Cleartext s)
          tests a given (cleartext) password against the user's password.
 boolean is_passwd(Cryptword s)
          tests a given (encrypted) password against the user's password.
 void set_email(java.lang.String s)
          sets this user's email address.
 void set_login(java.lang.String s)
          sets this user's login name (i.e. username).
 void set_passwd(Cleartext s)
          sets this user's password to the given cleartext String.
 void set_passwd(Cryptword s)
          sets this user's password to the given encrypted String.
 
Methods inherited from class com.strangelight.db.KeyedRow
commit, get_id, getId
 
Methods inherited from class com.strangelight.db.TableRow
drop, getFields, getObject, getString, getWhereClause, setObject, setString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

User

public User()
Creates a new User object, which will be transferred to persistent storage in the database when this User object is garbage-collected, or when this User object's commit() method is called.


User

public User(java.lang.String username,
            Cleartext password)
     throws E_NoSuchEntity,
            E_BadPassword
Attempts to fetch a User object from the database, given a username and (cleartext) password.

Parameters:
username - the user's username (i.e. login name).
password - the user's password, in cleartext form.
Throws:
E_NoSuchEntity - if the user cannot be found in the database
E_BadPassword - if the password is incorrect.

User

public User(int uid,
            Cleartext password)
     throws E_NoSuchEntity,
            E_BadPassword
Attempts to fetch a User object from the database, given a user's numerical id and (cleartext) password.

Parameters:
password - the user's password, in cleartext form.
Throws:
E_NoSuchEntity - if the user cannot be found in the database
E_BadPassword - if the password is incorrect.

User

public User(java.lang.Integer uid,
            Cleartext password)
     throws E_NoSuchEntity,
            E_BadPassword
Attempts to fetch a User object from the database, given a user's numerical id and (cleartext) password.

Parameters:
password - the user's password, in cleartext form.
Throws:
E_NoSuchEntity - if the user cannot be found in the database
E_BadPassword - if the password is incorrect.

User

public User(java.lang.String username,
            Cryptword password)
     throws E_NoSuchEntity,
            E_BadPassword
Attempts to fetch a User object from the database, given a username and (encrypted) password.

Parameters:
username - the user's username (i.e. login name).
password - the user's password, in encrypted form.
Throws:
E_NoSuchEntity - if the user cannot be found in the database
E_BadPassword - if the password is incorrect.

User

public User(int uid,
            Cryptword password)
     throws E_NoSuchEntity,
            E_BadPassword
Attempts to fetch a User object from the database, given a user's numerical id and (encrypted) password.

Parameters:
password - the user's password, in encrypted form.
Throws:
E_NoSuchEntity - if the user cannot be found in the database
E_BadPassword - if the password is incorrect.

User

public User(java.lang.Integer uid,
            Cryptword password)
     throws E_NoSuchEntity,
            E_BadPassword
Attempts to fetch a User object from the database, given a user's numerical id and (encrypted) password.

Parameters:
password - the user's password, in encrypted form.
Throws:
E_NoSuchEntity - if the user cannot be found in the database
E_BadPassword - if the password is incorrect.

User

public User(java.lang.String username)
     throws E_NoSuchEntity
Attempts to fetch a User object from the database given a username. Because this method does not do any password verification, applications should take special care that they do not use the returned object in a way that would compromise security.

Parameters:
username - the user's username (i.e. login name).
Throws:
E_NoSuchEntity - if the user cannot be found in the database

User

public User(java.lang.Integer uid)
     throws E_NoSuchEntity
Attempts to fetch a User object from the database given a user's numerical id. Because this method does not do any password verification, applications should take special care that they do not use the returned object in a way that would compromise security.

Throws:
E_NoSuchEntity - if the user cannot be found in the database

User

public User(int uid)
     throws E_NoSuchEntity
Attempts to fetch a User object from the database given a user's numerical id. Because this method does not do any password verification, applications should take special care that they do not use the returned object in a way that would compromise security.

Throws:
E_NoSuchEntity - if the user cannot be found in the database
Method Detail

getTableName

protected java.lang.String getTableName()
Specified by:
getTableName in class TableRow
Returns:
the name of the table that this TableRow class encapsulates. Subclasses typically implement this method by simply returning a static String object. For example, a typical implementation might be:
                         protected String getTableName() { return "MyTable"; }
                 

set_login

public void set_login(java.lang.String s)
sets this user's login name (i.e. username).

Parameters:
s - the user's new login name.

set_passwd

public void set_passwd(Cleartext s)
sets this user's password to the given cleartext String.

Parameters:
s - the user's new password (as cleartext).
See Also:
Cleartext

set_passwd

public void set_passwd(Cryptword s)
sets this user's password to the given encrypted String.

Parameters:
s - the user's new password (as an encrypted String).
See Also:
Cryptword

set_email

public void set_email(java.lang.String s)
sets this user's email address.

Parameters:
s - the user's new email addie.

get_login

public java.lang.String get_login()
gets this user's login name (username).

Returns:
the user's login name.

is_passwd

public boolean is_passwd(Cleartext s)
tests a given (cleartext) password against the user's password.

Parameters:
s - the password to test (as a cleartext string).
Returns:
true if s is the user's password, false otherwise.

is_passwd

public boolean is_passwd(Cryptword s)
tests a given (encrypted) password against the user's password.

Parameters:
s - the password to test (as an encrypted string).
Returns:
true if s is the user's password, false otherwise.

get_email

public java.lang.String get_email()
gets this user's email address.

Returns:
the user's email addie.

get_passwd

public Cryptword get_passwd()
gets this user's (encrypted) password.

Returns:
the user's password as an encrypted string.
See Also:
Cryptword

genRandomPassword

public static Cleartext genRandomPassword()
generates a truly random 6-character alphanumeric string for use as a random password.

Returns:
a random, 6-letter string.

finalize

public void finalize()
Overrides:
finalize in class KeyedRow
See Also:
TableRow.commit()