com.scooterframework.security
Class LoginHelper

java.lang.Object
  extended by com.scooterframework.security.LoginHelper

public class LoginHelper
extends java.lang.Object

LoginHelper class has helper methods for login related requests.


Field Summary
static java.lang.String SESSION_KEY_LOGIN_PASSWORD
           
static java.lang.String SESSION_KEY_LOGIN_USER_ID
           
static java.lang.String SESSION_KEY_LOGIN_USER_OBJECT
           
 
Constructor Summary
LoginHelper()
           
 
Method Summary
static void cacheLoggedInPassword(java.lang.Object password)
          Stores logged-in user's password to the user's http session.
static void cacheLoggedInUser(ActiveRecord user)
          Stores logged-in user record to the user's http session.
static void cacheLoggedInUserId(java.lang.Object userId)
          Stores logged-in user's id to the user's http session.
static boolean isAdminLoggedIn()
          Checks if the admin user is already logged in.
static boolean isLoggedIn()
          Checks if the current user is already logged in.
static boolean isLoggedInUser(java.lang.Object testUserId)
          Checks if a user id is the logged-in user id.
static java.lang.String loginPassword()
          Returns the password of the current logged-in user which has been saved to session.
static ActiveRecord loginUser()
          Returns the current logged-in user record which has been saved to session.
static java.lang.String loginUserId()
          Returns user id of the current logged-in user record which has been saved to session.
static void userLogin(ActiveRecord user)
          Stores user instance to session.
static void userLogout()
          Do something when logging out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_KEY_LOGIN_PASSWORD

public static final java.lang.String SESSION_KEY_LOGIN_PASSWORD
See Also:
Constant Field Values

SESSION_KEY_LOGIN_USER_ID

public static final java.lang.String SESSION_KEY_LOGIN_USER_ID
See Also:
Constant Field Values

SESSION_KEY_LOGIN_USER_OBJECT

public static final java.lang.String SESSION_KEY_LOGIN_USER_OBJECT
See Also:
Constant Field Values
Constructor Detail

LoginHelper

public LoginHelper()
Method Detail

loginUserId

public static java.lang.String loginUserId()
Returns user id of the current logged-in user record which has been saved to session.

Returns:
user id of the current logged-in user.

loginPassword

public static java.lang.String loginPassword()
Returns the password of the current logged-in user which has been saved to session.

Returns:
the password of the current logged-in user.

loginUser

public static ActiveRecord loginUser()
Returns the current logged-in user record which has been saved to session.

Returns:
an ActiveRecord instance of the current logged-in user record.

isLoggedIn

public static boolean isLoggedIn()
Checks if the current user is already logged in.

Returns:
true if the current user is already logged in.

isAdminLoggedIn

public static boolean isAdminLoggedIn()
Checks if the admin user is already logged in.

Returns:
true if the current user is already logged in.

cacheLoggedInUser

public static void cacheLoggedInUser(ActiveRecord user)
Stores logged-in user record to the user's http session.

Parameters:
user - an ActiveRecord instance.

cacheLoggedInUserId

public static void cacheLoggedInUserId(java.lang.Object userId)
Stores logged-in user's id to the user's http session.

Parameters:
userId - the login user id

cacheLoggedInPassword

public static void cacheLoggedInPassword(java.lang.Object password)
Stores logged-in user's password to the user's http session.

Parameters:
password - the login password

isLoggedInUser

public static boolean isLoggedInUser(java.lang.Object testUserId)
Checks if a user id is the logged-in user id. Note: This method compares the logged-in user id saved in session with the test user id, regardless of cases.

Parameters:
testUserId - user id to be tested.
Returns:
true if the user id is the logged-in user id.

userLogin

public static void userLogin(ActiveRecord user)
Stores user instance to session.

Parameters:
user - an ActiveRecord instance representing a user/account

userLogout

public static void userLogout()
Do something when logging out. All session data associated with the login are removed from session.