org.apache.struts.webapp.example
Class LogonAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.apache.struts.webapp.example.BaseAction
          extended byorg.apache.struts.webapp.example.LogonAction

public final class LogonAction
extends BaseAction

Validate a user logon.

Version:
$Revision: 187140 $ $Date: 2004-07-30 00:23:04 +0200 (Fri, 30 Jul 2004) $

Field Summary
(package private) static String PASSWORD
          Name of password field ["password"].
(package private) static String USERNAME
          Name of username field ["username"].
 
Fields inherited from class org.apache.struts.webapp.example.BaseAction
log
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
LogonAction()
           
 
Method Summary
 org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Use "username" and "password" fields from ActionForm to retrieve a User object from the database.
(package private)  User getUser(UserDatabase database, String username, String password, org.apache.struts.action.ActionMessages errors)
          Confirm user credentials.
(package private)  void SaveUser(javax.servlet.http.HttpServletRequest request, User user)
          Store User object in client session.
 
Methods inherited from class org.apache.struts.webapp.example.BaseAction
findFailure, findSuccess, getUserDatabase
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERNAME

static String USERNAME
Name of username field ["username"].


PASSWORD

static String PASSWORD
Name of password field ["password"].

Constructor Detail

LogonAction

public LogonAction()
Method Detail

getUser

User getUser(UserDatabase database,
             String username,
             String password,
             org.apache.struts.action.ActionMessages errors)
       throws ExpiredPasswordException

Confirm user credentials. Post any errors and return User object (or null).

Parameters:
database - Database in which to look up the user
username - Username specified on the logon form
password - Password specified on the logon form
errors - ActionMessages queue to passback errors
Returns:
Validated User object or null
Throws:
ExpiredPasswordException - to be handled by Struts exception processor via the action-mapping

SaveUser

void SaveUser(javax.servlet.http.HttpServletRequest request,
              User user)

Store User object in client session. If user object is null, any existing user object is removed.

Parameters:
request - The request we are processing
user - The user object returned from the database

execute

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
                                                      org.apache.struts.action.ActionForm form,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws Exception
Use "username" and "password" fields from ActionForm to retrieve a User object from the database. If credentials are not valid, or database has disappeared, post error messages and forward to input.

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - The HTTP request we are processing
response - The HTTP response we are creating
Throws:
Exception - if the application business logic throws an exception


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.