edu.northwestern.at.wordhoard.server.model
Class Account

java.lang.Object
  extended by edu.northwestern.at.wordhoard.server.model.Account
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Account
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

An account.

Each account has the following attributes:

See Also:
Serialized Form

Constructor Summary
Account()
          Creates a new account.
 
Method Summary
 java.lang.Object clone()
          Clones the account.
 boolean equals(java.lang.Object obj)
          Returns true if some other object is equal to this one.
 boolean getCanManageAccounts()
          Returns true if the account can manage other accounts.
 java.lang.Long getId()
          Gets the unique id.
 java.lang.String getName()
          Gets the name.
 boolean getNuAccount()
          Returns true if the account is an NU account.
 java.lang.String getPassword()
          Gets the encrypted password.
 java.lang.String getUsername()
          Gets the username.
 int hashCode()
          Returns a hash code for the object.
 boolean passwordIsValid(java.lang.String password)
          Validates a password.
 void setCanManageAccounts(boolean canManageAccounts)
          Sets the can manage other accounts attribute.
 void setId(java.lang.Long id)
          Sets the unique id.
 void setName(java.lang.String name)
          Sets the name.
 void setNuAccount(boolean nuAccount)
          Sets the NU account attribute.
 void setPassword(java.lang.String password)
          Sets the password.
 void setUsername(java.lang.String username)
          Sets the username.
 java.lang.String toString()
          Gets a string representation of the account.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Account

public Account()
Creates a new account.

Method Detail

getId

public java.lang.Long getId()
Gets the unique id.

Returns:
The unique id.

setId

public void setId(java.lang.Long id)
Sets the unique id.

Parameters:
id - The unique id.

getUsername

public java.lang.String getUsername()
Gets the username.

Returns:
The username.

setUsername

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

Parameters:
username - The username.

getPassword

public java.lang.String getPassword()
Gets the encrypted password.

Returns:
The encrypted password.

setPassword

public void setPassword(java.lang.String password)
Sets the password.

If the parameter is null or empty, null is stored, otherwise the password is encrypted and then stored.

Parameters:
password - The password.

passwordIsValid

public boolean passwordIsValid(java.lang.String password)
Validates a password.

Parameters:
password - The unencrypted password.
Returns:
True if the password is valid - when encrypted it matches the stored encrypted password. Returns false if either the parameter or the stored password is null.

getName

public java.lang.String getName()
Gets the name.

Returns:
The name.

setName

public void setName(java.lang.String name)
Sets the name.

Parameters:
name - The name.

getNuAccount

public boolean getNuAccount()
Returns true if the account is an NU account.

Returns:
True if NU account.

setNuAccount

public void setNuAccount(boolean nuAccount)
Sets the NU account attribute.

Parameters:
nuAccount - True if NU account.

getCanManageAccounts

public boolean getCanManageAccounts()
Returns true if the account can manage other accounts.

Returns:
True if can manage other accounts.

setCanManageAccounts

public void setCanManageAccounts(boolean canManageAccounts)
Sets the can manage other accounts attribute.

Parameters:
canManageAccounts - True if can manage other accounts.

toString

public java.lang.String toString()
Gets a string representation of the account.

Overrides:
toString in class java.lang.Object
Returns:
The username.

equals

public boolean equals(java.lang.Object obj)
Returns true if some other object is equal to this one.

The two accounts are equal if their usernames are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The other object.
Returns:
True if this object equals the other object.

hashCode

public int hashCode()
Returns a hash code for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

clone

public java.lang.Object clone()
Clones the account.

Overrides:
clone in class java.lang.Object
Returns:
A clone of the account.