org.web_auth.bizobj.impl
Class User

java.lang.Object
  extended byorg.web_auth.bizobj.impl.User
All Implemented Interfaces:
IUser

public abstract class User
extends java.lang.Object
implements IUser

An abstract class that represents a user who is required to use username/password authentication for login.

Version:
1.0
Author:
Zhengrong Tang

Field Summary
protected  java.lang.String password
           
static int PASSWORD_LENGTH_MAX
           
static int PASSWORD_LENGTH_MIN
           
protected  java.lang.String username
           
 
Constructor Summary
User()
           
 
Method Summary
 void add(java.sql.Connection conn)
          This method persists the user object in the database.
 boolean authenticateByUsernamePassword(java.sql.Connection conn)
          This method does username/password authentication.
 void changePassword(java.sql.Connection conn, java.lang.String newPassword)
          This method changes the user password.
 boolean exist(java.sql.Connection conn)
          Check whether this user exists.
 java.lang.String getPassword()
           
 java.lang.String getUsername()
           
abstract  int getUserType()
          Subclass needs to implement this method to return a unique int that represents the type of user.
 void remove(java.sql.Connection conn)
          This method removes the user from the database.
 void setPassword(java.lang.String string)
           
 void setUsername(java.lang.String string)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PASSWORD_LENGTH_MAX

public static final int PASSWORD_LENGTH_MAX
See Also:
Constant Field Values

PASSWORD_LENGTH_MIN

public static final int PASSWORD_LENGTH_MIN
See Also:
Constant Field Values

username

protected java.lang.String username

password

protected java.lang.String password
Constructor Detail

User

public User()
Method Detail

getUserType

public abstract int getUserType()
Subclass needs to implement this method to return a unique int that represents the type of user. For example, 1 means member, 2 means admin, etc.

Returns:
an int that indicates the type of the user

authenticateByUsernamePassword

public boolean authenticateByUsernamePassword(java.sql.Connection conn)
This method does username/password authentication.

Specified by:
authenticateByUsernamePassword in interface IUser
Parameters:
conn - the database connection object for connecting to the database
Returns:
true if the username and password pass authentication; false otherwise

changePassword

public void changePassword(java.sql.Connection conn,
                           java.lang.String newPassword)
                    throws ApplicationException
This method changes the user password.

Specified by:
changePassword in interface IUser
Parameters:
conn - the database connection object for connecting to the database
newPassword - the new password
Throws:
ApplicationException - if the password change is failed; the failure reason get be retrieved by calling ApplicationException.getApplicationResourceKey()

add

public void add(java.sql.Connection conn)
         throws ApplicationException
This method persists the user object in the database.

Specified by:
add in interface IUser
Parameters:
conn - the database connection object for connecting to the database
Throws:
ApplicationException - if the persisting is failed; the failure reason can be retrieved by calling ApplicationException.getApplicationResourceKey()

remove

public void remove(java.sql.Connection conn)
            throws ApplicationException
This method removes the user from the database.

Specified by:
remove in interface IUser
Parameters:
conn - the database connection object for connecting to the database
Throws:
ApplicationException - if the remove operation failedthe failure reason can be retrieved by calling ApplicationException.getApplicationResourceKey()

exist

public boolean exist(java.sql.Connection conn)
Check whether this user exists.

Specified by:
exist in interface IUser
Parameters:
conn - the database connection object for connecting to the database
Returns:
true if the user exists; false otherwise

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface IUser

getUsername

public java.lang.String getUsername()
Specified by:
getUsername in interface IUser

setPassword

public void setPassword(java.lang.String string)
Specified by:
setPassword in interface IUser

setUsername

public void setUsername(java.lang.String string)
Specified by:
setUsername in interface IUser


Copyright © 2003 Zhengrong Tang. All Rights Reserved.