org.mentawai.action
Class BaseLoginAction

java.lang.Object
  extended by org.mentawai.core.BaseAction
      extended by org.mentawai.action.BaseLoginAction
All Implemented Interfaces:
Action, StickyAction, AuthenticationFree

public abstract class BaseLoginAction
extends BaseAction
implements AuthenticationFree

This action implements the basic functionality for a Login action. You should override this class to create your Login action. You should also use its static methods for retrieving the session user and for checking if the user is logged.

Author:
Sergio Oliveira

Field Summary
static String GROUPS_KEY
          The default key used to store the user authorization groups in the session.
static String LOCALE_KEY
          The default key used to store the user locale in the session.
static String USER_KEY
          The default key used to store the user object in the session.
 
Fields inherited from class org.mentawai.core.BaseAction
application, cookies, input, loc, msgContext, output, session
 
Fields inherited from interface org.mentawai.core.Action
ACCESSDENIED, ADD, AJAX, ALREADY, BACK, BLOCKED, CREATED, EDIT, ERROR, EXCEPTION, HTML, INDEX, JSON, JSP, LIST, LOGIN, MAIN, NEXT, NOT_FOUND, NULL, REMOVED, SHOW, STREAM, SUCCESS, TEST, UPDATED, XML
 
Constructor Summary
BaseLoginAction()
           
 
Method Summary
 boolean bypassAuthentication(String innerAction)
           
 Object getSessionObj()
           
static Object getSessionObj(Context session)
           
static Object getSessionObj(javax.servlet.http.HttpSession session)
           
 List<Object> getUserGroups()
          Return the user authorization groups.
static List<Object> getUserGroups(Context session)
          Return the user authorization groups.
static List<Object> getUserGroups(javax.servlet.http.HttpSession session)
          Return the user authorization groups.
 Locale getUserLocale()
          Return the user locale.
static Locale getUserLocale(Context session)
          Return the user locale.
static Locale getUserLocale(javax.servlet.http.HttpSession session)
          Return the user locale.
 Object getUserSession()
          Return the user session object.
static Object getUserSession(Context session)
          Return the user session object.
static Object getUserSession(javax.servlet.http.HttpSession session)
          Return the user session object.
static Object getUserSession(Map<String,Object> session)
           
 boolean isLogged()
          Check if the user is logged.
static boolean isLogged(Context session)
          Check if the user is logged.
static boolean isLogged(javax.servlet.http.HttpSession session)
          Check if the user is logged.
 void replaceSessionObj(Object value)
           
static void replaceSessionObj(Object value, Context session)
           
static void replaceSessionObj(Object value, Map<String,Object> session)
           
 void replaceUserSession(Object newUser)
          Replace the user object from the session for this new one WITHOUT reseting the session.
static void replaceUserSession(Object newUser, Context session)
          Replace the user object from the session for this new one WITHOUT reseting the session.
static void replaceUserSession(Object newUser, Map<String,Object> session)
          Replace the user object from the session for this new one WITHOUT reseting the session.
 void setSessionGroup(String group)
           
 void setSessionLocale(Locale loc)
           
static void setSessionLocale(Locale loc, Context session)
           
 void setSessionLocale(String loc)
           
 void setSessionObj(Object value)
           
static void setSessionObj(Object value, Context session)
           
static void setSessionObj(Object value, Map<String,Object> session)
           
 void setUserGroup(Group group)
           
static void setUserGroup(Group group, Context session)
           
static void setUserGroup(int groupId, Context session)
           
 void setUserGroup(String group)
           
static void setUserGroup(String group, Context session)
           
static void setUserGroups(Context session, Group... groups)
           
static void setUserGroups(Context session, String... groups)
           
 void setUserGroups(Group... groups)
           
 void setUserGroups(List groups)
          Place the user authorization groups in the session.
static void setUserGroups(List groups, Context session)
          Place the user authorization groups in the session.
 void setUserGroups(String... groups)
           
 void setUserGroups(String groups)
          Deprecated.  
static void setUserGroups(String groups, Context session)
          Deprecated.  
 void setUserLocale(Locale loc)
          Place the user locale in the session.
static void setUserLocale(Locale loc, Context session)
          Place the user locale in the session.
 void setUserLocale(String loc)
           
static void setUserLocale(String loc, Context session)
           
 void setUserSession(Object value)
          Place an user object in the session.
static void setUserSession(Object value, Context session)
          Place an user object in the session.
static void setUserSession(Object value, Map<String,Object> session)
           
 
Methods inherited from class org.mentawai.core.BaseAction
addError, addError, addError, addError, addError, addError, addError, addError, addError, addError, addError, addError, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, addMessage, adhere, ajax, application, commit, commit, cookies, disjoin, execute, findValue, findValue, getApplication, getContextPath, getCookies, getError, getInput, getLocale, getLocalizedText, getLocalizedText, getMessageTokens, getMessageTokens, getOutput, getPrettyURL, getSession, getSessionLocale, hasError, init, init, input, isAjaxRequest, isAjaxRequest, isEmpty, isGet, isGet, isPost, isPost, isPrettyURL, loc, onRemoved, output, redir, rollback, rollback, session, setApplication, setCookies, setInput, setLocale, setMessageContext, setOutput, setSession, setSessionGroup, setSessionGroups, setSessionGroups, setSessionUser, stream, stream, stream
 
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
The default key used to store the user object in the session.

See Also:
Constant Field Values

GROUPS_KEY

public static final String GROUPS_KEY
The default key used to store the user authorization groups in the session.

See Also:
Constant Field Values

LOCALE_KEY

public static final String LOCALE_KEY
The default key used to store the user locale in the session.

See Also:
Constant Field Values
Constructor Detail

BaseLoginAction

public BaseLoginAction()
Method Detail

setUserSession

public void setUserSession(Object value)
Place an user object in the session. Note that this can be any object.

Attention:The session context is reset when you call this method.

Overrides:
setUserSession in class BaseAction
Parameters:
value - The user object to place in the session.

setSessionObj

public void setSessionObj(Object value)
Overrides:
setSessionObj in class BaseAction

replaceUserSession

public void replaceUserSession(Object newUser)
Replace the user object from the session for this new one WITHOUT reseting the session.

Overrides:
replaceUserSession in class BaseAction
Parameters:
newUser -
Since:
1.14

replaceSessionObj

public void replaceSessionObj(Object value)
Overrides:
replaceSessionObj in class BaseAction

setUserSession

public static void setUserSession(Object value,
                                  Context session)
Place an user object in the session. Note that this can be any object.

Attention:The session context is reset when you call this method. ]

Parameters:
value - The user object to place in the session.
session - The session where to put the user.
Since:
1.1.1

setSessionObj

public static void setSessionObj(Object value,
                                 Context session)

replaceUserSession

public static void replaceUserSession(Object newUser,
                                      Context session)
Replace the user object from the session for this new one WITHOUT reseting the session.

Parameters:
newUser -
session -
Since:
1.14

replaceSessionObj

public static void replaceSessionObj(Object value,
                                     Context session)

replaceUserSession

public static void replaceUserSession(Object newUser,
                                      Map<String,Object> session)
Replace the user object from the session for this new one WITHOUT reseting the session.

Parameters:
newUser -
session -
Since:
1.14

replaceSessionObj

public static void replaceSessionObj(Object value,
                                     Map<String,Object> session)

setUserSession

public static void setUserSession(Object value,
                                  Map<String,Object> session)

setSessionObj

public static void setSessionObj(Object value,
                                 Map<String,Object> session)

setUserLocale

public void setUserLocale(Locale loc)
Place the user locale in the session. If you call this method, the web application will follow this locale and not the one sent by the browser.

Parameters:
loc - The user locale to place in the session.

setSessionLocale

public void setSessionLocale(Locale loc)
Overrides:
setSessionLocale in class BaseAction

setSessionLocale

public static void setSessionLocale(Locale loc,
                                    Context session)

setSessionLocale

public void setSessionLocale(String loc)
Overrides:
setSessionLocale in class BaseAction

setUserLocale

public static void setUserLocale(Locale loc,
                                 Context session)
Place the user locale in the session. If you call this method, the web application will follow this locale and not the one sent by the browser.

Parameters:
loc - The user locale to place in the session.
session - The session where to put the user locale.
Since:
1.1.1

setUserLocale

public static void setUserLocale(String loc,
                                 Context session)

setUserLocale

public void setUserLocale(String loc)

setUserGroups

public void setUserGroups(List groups)
Place the user authorization groups in the session.

Parameters:
groups - The user authorization groups to place in the session.

setSessionGroup

public void setSessionGroup(String group)
Overrides:
setSessionGroup in class BaseAction

setUserGroups

public static void setUserGroups(List groups,
                                 Context session)
Place the user authorization groups in the session.

Parameters:
groups - The user authorization groups to place in the session.
session - The session where to put the authorization groups.
Since:
1.1.1

setUserGroup

public void setUserGroup(String group)

setUserGroup

public static void setUserGroup(String group,
                                Context session)

bypassAuthentication

public boolean bypassAuthentication(String innerAction)
Specified by:
bypassAuthentication in interface AuthenticationFree

setUserGroup

public void setUserGroup(Group group)

setUserGroup

public static void setUserGroup(Group group,
                                Context session)

setUserGroup

public static void setUserGroup(int groupId,
                                Context session)

setUserGroups

public void setUserGroups(String groups)
Deprecated. 

Place the user authorization groups in the session.

Parameters:
groups - The user authorization groups to place in the session.

setUserGroups

public static void setUserGroups(String groups,
                                 Context session)
Deprecated. 

Place the user authorization groups in the session.

Parameters:
groups - The user authorization groups to place in the session.
session - The session where to put the authorization groups.
Since:
1.1.1

setUserGroups

public void setUserGroups(String... groups)
Parameters:
groups -
Since:
1.11

setUserGroups

public static void setUserGroups(Context session,
                                 String... groups)
Parameters:
session -
groups -
Since:
1.11

setUserGroups

public void setUserGroups(Group... groups)
Parameters:
groups -
Since:
1.12

setUserGroups

public static void setUserGroups(Context session,
                                 Group... groups)
Parameters:
session -
groups -
Since:
1.12

isLogged

public boolean isLogged()
Check if the user is logged.

Overrides:
isLogged in class BaseAction
Returns:
true if the user is logged.

getUserSession

public Object getUserSession()
Return the user session object.

Overrides:
getUserSession in class BaseAction
Returns:
The user session or null if the user is not logged.

getUserLocale

public Locale getUserLocale()
Return the user locale.

Overrides:
getUserLocale in class BaseAction
Returns:
The user locale or null if the user is not logged.

getUserGroups

public List<Object> getUserGroups()
Return the user authorization groups.

Returns:
The user authorization groups or null if the user is not logged or user has no authorization groups.

isLogged

public static boolean isLogged(Context session)
Check if the user is logged.

Parameters:
session - The session context where to check for the user object.
Returns:
true if the user is logged.

isLogged

public static boolean isLogged(javax.servlet.http.HttpSession session)
Check if the user is logged.

Parameters:
session - The http session where to check for the user object.
Returns:
true if the user is logged.

getUserSession

public static Object getUserSession(Context session)
Return the user session object.

Parameters:
session - The session context where to check for the user object.
Returns:
The user session or null if the user is not logged.

getSessionObj

public static Object getSessionObj(Context session)

getSessionObj

public static Object getSessionObj(javax.servlet.http.HttpSession session)

getSessionObj

public Object getSessionObj()
Overrides:
getSessionObj in class BaseAction

getUserSession

public static Object getUserSession(Map<String,Object> session)

getUserSession

public static Object getUserSession(javax.servlet.http.HttpSession session)
Return the user session object.

Parameters:
session - The session context where to check for the user object.
Returns:
The user session or null if the user is not logged.

getUserLocale

public static Locale getUserLocale(Context session)
Return the user locale.

Parameters:
session - The session context where to check for the user locale.
Returns:
The user locale or null if the user is not logged.

getUserLocale

public static Locale getUserLocale(javax.servlet.http.HttpSession session)
Return the user locale.

Parameters:
session - The session context where to check for the user locale.
Returns:
The user locale or null if the user is not logged.

getUserGroups

public static List<Object> getUserGroups(Context session)
Return the user authorization groups.

Parameters:
session - The session context where to check for the user authorization groups.
Returns:
The user authorization groups or null if the user is not logged or the user has no authorization groups.

getUserGroups

public static List<Object> getUserGroups(javax.servlet.http.HttpSession session)
Return the user authorization groups.

Parameters:
session - The http session where to check for the user authorization groups.
Returns:
The user authorization groups or null if the user is not logged or the user has no authorization groups.


Copyright © 2013. All Rights Reserved.