1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.apps.mailreader.actions;
19
20 import org.apache.struts.action.ActionForm;
21 import org.apache.struts.action.ActionForward;
22 import org.apache.struts.action.ActionMapping;
23 import org.apache.struts.action.ActionMessages;
24 import org.apache.struts.apps.mailreader.dao.User;
25
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 /***
30 * <p>
31 * Validate a user logon.
32 * </p>
33 *
34 * @version $Rev: 360442 $ $Date: 2005-12-31 13:10:04 -0700 (Sat, 31 Dec 2005) $
35 */
36 public final class LogonAction extends BaseAction {
37
38 /***
39 * <p>
40 * Use "username" and "password" fields from ActionForm to retrieve a User
41 * object from the database. If credentials are not valid, or database
42 * has disappeared, post error messages and forward to input.
43 * </p>
44 *
45 * @param mapping The ActionMapping used to select this instance
46 * @param form The optional ActionForm bean for this request (if any)
47 * @param request The HTTP request we are processing
48 * @param response The HTTP response we are creating
49 * @throws Exception if the application business logic throws
50 * an exception
51 */
52 public ActionForward execute(
53 ActionMapping mapping,
54 ActionForm form,
55 HttpServletRequest request,
56 HttpServletResponse response)
57 throws Exception {
58
59
60 String username = doGet(form, USERNAME);
61 String password = doGet(form, PASSWORD);
62 ActionMessages errors = new ActionMessages();
63 User user = doGetUser(username, password, errors);
64
65
66 if (!errors.isEmpty()) {
67 this.saveErrors(request, errors);
68 return (mapping.getInputForward());
69 }
70
71
72 doCacheUser(request, user);
73
74
75 return doFindSuccess(mapping);
76
77 }
78
79 }