org.bioquery.bqutils
Class BQUser

java.lang.Object
  |
  +--org.bioquery.bqutils.BQUser
All Implemented Interfaces:
java.io.Serializable

public final class BQUser
extends java.lang.Object
implements java.io.Serializable

This class models the user and simply stores the username and password.

Author:
James Brundege
See Also:
Serialized Form

Field Summary
static int MIN_PASSWORD_LENGTH
          The minimum length for a valid password.
static int MIN_USERNAME_LENGTH
          The minimum length for a valid username.
 
Constructor Summary
BQUser(java.lang.String username, char[] password)
          Constructor accepts and sets the username and password for this account.
 
Method Summary
 boolean checkPassword(char[] pass)
          Confirms whether the given password matches the password for this user.
 boolean checkUser(java.lang.String username, char[] pass)
          Checks whether the username and password given match the username and password of this user object.
 char[] getPassword()
          Returns the password for this user.
 java.lang.String getUsername()
          Returns the username for this user.
 boolean isComplete()
          Checks whether this user object has a completed username and password of at least the minimum length.
 void setPassword(char[] password)
          Set the password.
 void setUsername(java.lang.String username)
          Set the username.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_USERNAME_LENGTH

public static final int MIN_USERNAME_LENGTH
The minimum length for a valid username.

MIN_PASSWORD_LENGTH

public static final int MIN_PASSWORD_LENGTH
The minimum length for a valid password.
Constructor Detail

BQUser

public BQUser(java.lang.String username,
              char[] password)
Constructor accepts and sets the username and password for this account. This constructor does not test whether the username and password given are valid. The programmer should independently test this with the isComplete() method.
Parameters:
username - the username for this account.
password - the password for this account.
Method Detail

getUsername

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

setUsername

public void setUsername(java.lang.String username)
Set the username.
Parameters:
username - the username for this user.

setPassword

public void setPassword(char[] password)
Set the password.
Parameters:
password - the password for this user.

getPassword

public char[] getPassword()
Returns the password for this user.
Returns:
the password for this user.

checkPassword

public boolean checkPassword(char[] pass)
Confirms whether the given password matches the password for this user.
Parameters:
pass - the password for this account.
Returns:
true if the given password is correct for this user, false otherwise.

checkUser

public boolean checkUser(java.lang.String username,
                         char[] pass)
Checks whether the username and password given match the username and password of this user object.
Parameters:
username - the username for this account.
password - the password for this account.
Returns:
true if the given username and password are correct for this user, false otherwise.

isComplete

public boolean isComplete()
Checks whether this user object has a completed username and password of at least the minimum length. The minimum lengths are defined by the MIN_USERNAME_LENGTH and MIN_PASSWORD_LENGTH fields.
Returns:
true if the username and password are valid, false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object