com.pow2.user
Class UserManager

java.lang.Object
  extended bycom.pow2.user.UserManager

public class UserManager
extends Object

Manage the User entities.
This class is a facade to the user package functions.

Author:
Luca Fossato

Field Summary
static String USER_KEY
          Session User key
 
Method Summary
 void deleteUser(HttpServletRequest request)
          Remove the current user from the Session context.
 void deleteUser(String id)
          Remove the User entry having the input identifier from the database.
 User getUser(HttpServletRequest request)
          Retrieve the User object from the Session context.
 User getUser(HttpServletRequest request, boolean authenticate)
          Get the User object.
 User getUser(String login, String passwd)
          Retrieve a registered User object from the database.
static UserManager instance()
          Get the unique instance of UserManager class.
 void setGuestUser(HttpServletRequest request)
          Set a guest user into the session context.
 void setGuestUser(HttpServletRequest request, Class userClass)
          Set a guest user into the session context.
 void setUser(HttpServletRequest request, User user)
          Store the input User object into the session context.
 void setUser(User user)
          Persist the user informations into the database.
 void setUser(User user, RegistrationForm form, boolean update)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_KEY

public static final String USER_KEY
Session User key

See Also:
Constant Field Values
Method Detail

instance

public static UserManager instance()
Get the unique instance of UserManager class.

Returns:
the instance of UserManager class

getUser

public User getUser(HttpServletRequest request)
Retrieve the User object from the Session context.

Parameters:
request - Description of the Parameter
Returns:
the retrieved User object, or null if the Session context does not have any User reference

getUser

public User getUser(String login,
                    String passwd)
             throws Exception
Retrieve a registered User object from the database.

Parameters:
login - the user login
passwd - the user password
Returns:
the registered user object, or null if:
  • the input login and passwd attributes don't match any user profile
  • the validation process fails
Throws:
Exception

getUser

public User getUser(HttpServletRequest request,
                    boolean authenticate)
             throws Exception
Get the User object.
Retrieve the User object from the Session context; if it does not exists, create a new one.
If authenticate is true: Else return the retrieved user (or the new instance) without execute the authentication process.
 

Parameters:
request - the HttpServletRequest object
authenticate - true if the user must be authenticated versus the user database; false otherwise.
Returns:
the User object
Throws:
Exception

deleteUser

public void deleteUser(HttpServletRequest request)
Remove the current user from the Session context.

Parameters:
request - Description of the Parameter

deleteUser

public void deleteUser(String id)
Remove the User entry having the input identifier from the database.

Parameters:
id - the identifier of the User entry to remove from the database

setGuestUser

public void setGuestUser(HttpServletRequest request)
                  throws Exception
Set a guest user into the session context.
This method first checks for an existant user object into the session context. If the user reference does not exist, setGuestUser creates and place the new not-authenticated user into the session context.

Parameters:
request - the HttpServletRequest object
Throws:
Exception - if any error occurs

setGuestUser

public void setGuestUser(HttpServletRequest request,
                         Class userClass)
                  throws Exception
Set a guest user into the session context.
This method first checks for an existant user object into the session context. If the user reference does not exist, setGuestUser creates and place the new not-authenticated user into the session context.

Parameters:
request - the HttpServletRequest object
userClass - the class of the User object to store into the session context. The class MUST extends com.pow2.user.User.
Throws:
Exception - if any error occurs

setUser

public void setUser(HttpServletRequest request,
                    User user)
Store the input User object into the session context.

Parameters:
request - the HttpServletRequest request used to retrieve the current Session object or to create a new one
user - the user object to store into the Session context

setUser

public void setUser(User user)
Persist the user informations into the database.
This method updates or insert a new User entry into the database depending on the user id value.

Parameters:
user - the user object to persist into the database

setUser

public void setUser(User user,
                    RegistrationForm form,
                    boolean update)
Parameters:
user -


Copyright © 2002-2004 Power Of Two S.R.L. All Rights Reserved.