Class LoginAction

java.lang.Object
com.opensymphony.xwork2.ActionSupport
org.conical.common.bbl.web.struts.actions.BaseAction
org.conical.common.bbl.web.struts.actions.LoginAction
All Implemented Interfaces:
com.opensymphony.xwork2.Action, com.opensymphony.xwork2.interceptor.ValidationAware, com.opensymphony.xwork2.LocaleProvider, com.opensymphony.xwork2.TextProvider, com.opensymphony.xwork2.Validateable, Serializable, org.apache.struts2.interceptor.ServletRequestAware, org.apache.struts2.interceptor.ServletResponseAware

public class LoginAction extends BaseAction
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:
  • 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:
      actionRequiresLogin in class BaseAction
      Returns:
      false
    • doWork

      public String doWork() throws Exception
      Attempts to log user into the application using the authentication settings in authentication.properties.
      Specified by:
      doWork in class BaseAction
      Returns:
      success if able to log user in, else input
      Throws:
      Exception - if something goes wrong
    • setCurrentUser

      public static void setCurrentUser(User user)
    • getAdditionalCookies

      protected List<javax.servlet.http.Cookie> 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

      public String getMessage()
      If authentication fails, this message will tell the user what happened
      Returns:
      user message
    • setUsername

      public void setUsername(String username)
      Sets user name sent from form
      Parameters:
      username -
    • getUsername

      public String getUsername()
      Returns user name originally passed in
      Returns:
      original user name
    • setPassword

      public void setPassword(String password)
      Sets password sent from form
      Parameters:
      password -
    • getPassword

      public String getPassword()
      Returns password originally passed in
      Returns:
      original password
    • setRequestUrl

      public void setRequestUrl(String requestUrl)
      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

      public String getRequestUrl()
      Overrides BaseAction.getRequestUrl() to return the page originally requested. See setRequestUrl() for limitations.
      Overrides:
      getRequestUrl in class BaseAction
      Returns:
      original request URL, or, if not set, the URL of this request