org.openlaszlo.lzproject.model
Class User

java.lang.Object
  extended by org.openlaszlo.lzproject.model.PersistenceBaseClass
      extended by org.openlaszlo.lzproject.model.User
All Implemented Interfaces:
java.io.Serializable

public class User
extends PersistenceBaseClass
implements java.io.Serializable

Class User is the representation of a user in the model.

Author:
raju
See Also:
Serialized Form

Field Summary
private  java.lang.String email
          The email.
private  int id
          The user id, the primary key value in the DB table.
private  java.util.Date lastLogin
          Last login date and time.
private  org.apache.log4j.Logger log
          Log4J logger.
private  java.lang.String login
          The login or user name.
private  java.lang.String password
          MD5 hash of the user's password.
private  java.lang.String realName
          User's real name.
private static long serialVersionUID
          serialVersionUID used for serialization.
 
Fields inherited from class org.openlaszlo.lzproject.model.PersistenceBaseClass
bundle, conn, dbName, realPath
 
Constructor Summary
User()
          Defaul constructor for User class.
User(java.lang.String path)
          Constructor for User class.
 
Method Summary
private  boolean authorize(java.lang.String checksum)
          Compare the MD5 hash passed to this method with the user's password hash.
 RestServiceResult create(RestServiceResult result)
          Create a new user in the database.
 RestServiceResult deleteByLogin(RestServiceResult result)
          Delete a user by login name.
 java.lang.String getEmail()
          Getter for email.
 int getId()
          Getter for user id.
 java.util.Date getLastLogin()
          Getter for last login.
 java.lang.String getLogin()
          Getter for login.
 java.lang.String getPassword()
          Getter for password (MD5 hashed)
 java.lang.String getRealName()
          Getter for real name.
 RestServiceResult login(javax.servlet.http.HttpSession session, RestServiceResult result)
          Handle a user login request.
 RestServiceResult logout(javax.servlet.http.HttpSession session, RestServiceResult result)
          Handle a logout request.
private  java.lang.String md5(java.lang.String pass)
          Generate an MD5 hash for the string passed to the method.
 void setEmail(java.lang.String email)
          Setter for email.
 void setId(int id)
          Setter for user id.
 void setLastLogin(java.util.Date lastLogin)
          Setter for last login.
 void setLogin(java.lang.String login)
          Setter for login.
 void setPassword(java.lang.String password)
          Setter for password.
 void setRealName(java.lang.String realName)
          Setter for real name.
private  java.lang.String toHexString(byte b)
          Convert a byte into a hexadezimal string representation.
 RestServiceResult update(RestServiceResult result)
          Update a users data.
 
Methods inherited from class org.openlaszlo.lzproject.model.PersistenceBaseClass
dbConnect, dbDisconnect, getBundle, handleSQLError, setBundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
serialVersionUID used for serialization.

See Also:
Constant Field Values

id

private int id
The user id, the primary key value in the DB table.


realName

private java.lang.String realName
User's real name.


login

private java.lang.String login
The login or user name.


email

private java.lang.String email
The email.


log

private transient org.apache.log4j.Logger log
Log4J logger.


password

private java.lang.String password
MD5 hash of the user's password.


lastLogin

private java.util.Date lastLogin
Last login date and time.

Constructor Detail

User

public User()
Defaul constructor for User class.


User

public User(java.lang.String path)
Constructor for User class.

Parameters:
path - The real path to the WEB-INF folder.
Method Detail

create

public RestServiceResult create(RestServiceResult result)
Create a new user in the database.

In case of failure the error is passed back contained in the RestServiceResult returned.

Parameters:
result - The RestServiceResult which will contain the localized messages and SQL state.
Returns:
The RestServiceResult containing the outcome of this operation.

update

public RestServiceResult update(RestServiceResult result)
Update a users data.

In case of failure the error is passed back contained in the RestServiceResult returned.

Parameters:
result - The RestServiceResult which will contain the localized messages and SQL state.
Returns:
The RestServiceResult containing the outcome of this operation.

deleteByLogin

public RestServiceResult deleteByLogin(RestServiceResult result)
Delete a user by login name.

In case of failure the error is passed back contained in the RestServiceResult returned.

Parameters:
result - The RestServiceResult which will contain the localized messages and SQL state.
Returns:
The RestServiceResult containing the outcome of this operation.

login

public RestServiceResult login(javax.servlet.http.HttpSession session,
                               RestServiceResult result)
Handle a user login request.

In case of failure the error is passed back contained in the RestServiceResult returned.

Parameters:
result - The RestServiceResult which will contain the localized messages and SQL state.
Returns:
The RestServiceResult containing the outcome of this operation.

logout

public RestServiceResult logout(javax.servlet.http.HttpSession session,
                                RestServiceResult result)
Handle a logout request.

In case of failure the error is passed back contained in the RestServiceResult returned.

Parameters:
result - The RestServiceResult which will contain the localized messages and SQL state.
Returns:
The RestServiceResult containing the outcome of this operation.

authorize

private boolean authorize(java.lang.String checksum)
Compare the MD5 hash passed to this method with the user's password hash. Returns true if they match, false if they don't match.

Parameters:
checksum - The MD5 hash of the entered password.
Returns:
true, if authorized; false, if not authorized

md5

private java.lang.String md5(java.lang.String pass)
Generate an MD5 hash for the string passed to the method.

Parameters:
pass - The string for which we need to generate the hash.
Returns:
The MD5 hash.

toHexString

private java.lang.String toHexString(byte b)
Convert a byte into a hexadezimal string representation.

Parameters:
b - The byte to be converted.
Returns:
The hex String.

getId

public int getId()
Getter for user id.

Returns:
The user id.

setId

public void setId(int id)
Setter for user id.

Parameters:
id - The new id.

getLogin

public java.lang.String getLogin()
Getter for login.

Returns:
The login.

setLogin

public void setLogin(java.lang.String login)
Setter for login.

Parameters:
login - The new login.

getRealName

public java.lang.String getRealName()
Getter for real name.

Returns:
The real name.

setRealName

public void setRealName(java.lang.String realName)
Setter for real name.

Parameters:
realName - The new real name.

getPassword

public java.lang.String getPassword()
Getter for password (MD5 hashed)

Returns:
The password's hash.

setPassword

public void setPassword(java.lang.String password)
Setter for password.

Parameters:
password - The new password.

getLastLogin

public java.util.Date getLastLogin()
Getter for last login.

Returns:
Last login's date and time.

setLastLogin

public void setLastLogin(java.util.Date lastLogin)
Setter for last login.

Parameters:
lastLogin - The new last login date and time.

getEmail

public java.lang.String getEmail()
Getter for email.

Returns:
The email.

setEmail

public void setEmail(java.lang.String email)
Setter for email.

Parameters:
email - The new email.