Class LoginAction
java.lang.Object
org.apache.struts2.ActionSupport
org.conical.common.bbl.web.struts.actions.BaseAction
org.conical.common.bbl.web.struts.actions.LoginAction
- All Implemented Interfaces:
Serializable, org.apache.struts2.action.Action, org.apache.struts2.action.ServletRequestAware, org.apache.struts2.action.ServletResponseAware, org.apache.struts2.interceptor.ValidationAware, org.apache.struts2.locale.LocaleProvider, org.apache.struts2.text.TextProvider, org.apache.struts2.Validateable
Attempts to log user into the application using the authentication settings in
authentication.properties. A form submitting to this action should contain
the following parameters:
username: username
password: password for user
requestUrl: URL to return to after successful authentication
- Author:
- rdoherty
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class BaseAction
BaseAction.DeveloperModifier and TypeClassDescriptionclassEncapsulates information about the contact developer for this application -
Field Summary
Fields inherited from class BaseAction
PERMISSION_DENIEDModifier and TypeFieldDescriptionprotected static final StringShould be returned when permission to view a page or perform an action is deniedFields inherited from class org.apache.struts2.ActionSupport
containerFields inherited from interface org.apache.struts2.action.Action
ERROR, INPUT, LOGIN, NONE, SUCCESS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanIt is assumed that if user needs to log in, user is not logged in; returns false.doWork()Attempts to log user into the application using the authentication settings in authentication.properties.protected List<jakarta.servlet.http.Cookie> Returns any additional cookies child action wishes to set.If authentication fails, this message will tell the user what happenedReturns password originally passed inOverrides BaseAction.getRequestUrl() to return the page originally requested.Returns user name originally passed instatic voidsetCurrentUser(User user) voidsetPassword(String password) Sets password sent from formvoidsetRequestUrl(String requestUrl) Allows pages to set the "original" request URL when they go to a login page.voidsetUsername(String username) Sets user name sent from formMethods inherited from class BaseAction
addCookie, doAutoLogin, execute, getApplicationName, getApplicationProperties, getCookies, getCurrentUser, getDeveloper, getEthnicities, getHandednesses, getNameSuffixes, getRaces, getReligions, getRequiredAccessRoles, getSession, getSexes, getSexualOrientations, getStates, withServletRequest, withServletResponseModifier and TypeMethodDescriptionvoidaddCookie(jakarta.servlet.http.Cookie cookie) Adds the passed cookie to the HTTP responseprotected voidTry to log in user automatically using cookies or some other mechanism (implementation dependent).final Stringexecute()Method called by Struts to initiate action logic.Returns the name of this applicationReturns a map of application properties read from the application.properties file.List<jakarta.servlet.http.Cookie> final UserReturns the user currently logged into this application, or null if no one is logged in, if the user is no longer valid, or if an error occurs (the error having been logged).Returns the developer who should be contacted regarding this applicationgetRaces()Returns the set of access roles required to execute this action (and access the associated page).Exposes session to child classes.getSexes()voidwithServletRequest(jakarta.servlet.http.HttpServletRequest request) voidwithServletResponse(jakarta.servlet.http.HttpServletResponse response) Methods inherited from class org.apache.struts2.ActionSupport
addActionError, addActionMessage, addFieldError, clearActionErrors, clearErrors, clearErrorsAndMessages, clearFieldErrors, clearMessages, clone, getActionErrors, getActionMessages, getContainer, getFieldErrors, getFormatted, getLocale, getLocaleProvider, getText, getText, getText, getText, getText, getText, getText, getText, getText, getTextProvider, getTexts, getTexts, hasActionErrors, hasActionMessages, hasErrors, hasFieldErrors, hasKey, input, isValidLocale, isValidLocaleString, pause, setActionErrors, setActionMessages, setContainer, setFieldErrors, toLocale, validate
-
Constructor Details
-
LoginAction
public LoginAction()
-
-
Method Details
-
actionRequiresLogin
protected boolean actionRequiresLogin()It is assumed that if user needs to log in, user is not logged in; returns false.- Specified by:
actionRequiresLoginin classBaseAction- Returns:
- false
-
doWork
Attempts to log user into the application using the authentication settings in authentication.properties.- Specified by:
doWorkin classBaseAction- Returns:
- success if able to log user in, else input
- Throws:
Exception- if something goes wrong
-
setCurrentUser
-
getAdditionalCookies
Returns any additional cookies child action wishes to set. Default behavior is to return an empty list.- Returns:
- list of cookies to set upon successful login
-
getMessage
If authentication fails, this message will tell the user what happened- Returns:
- user message
-
setUsername
-
getUsername
-
setPassword
-
getPassword
-
setRequestUrl
Allows pages to set the "original" request URL when they go to a login page. By submitting this value with the login form values, they can redirect to the original page once user is logged in. Note that if user originally goes to the login page, a nasty loop occurs; also, POST requests are not supported, so parameters will be lost and a GET to the original page will be performed, which may produce errors depending on your implementation.- Parameters:
requestUrl- original request URL
-
getRequestUrl
Overrides BaseAction.getRequestUrl() to return the page originally requested. SeesetRequestUrl()for limitations.- Overrides:
getRequestUrlin classBaseAction- Returns:
- original request URL, or, if not set, the URL of this request
-