1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.web.forms;
20
21 import org.apache.struts.action.ActionErrors;
22 import org.apache.struts.action.ActionMapping;
23 import org.apache.struts.validator.ValidatorForm;
24
25 import javax.servlet.http.HttpServletRequest;
26
27
28
29
30
31
32 public class LoginForm extends ValidatorForm {
33
34
35
36 private static final long serialVersionUID = 1L;
37 private String login = null;
38 private String password = null;
39 private boolean saveLogin;
40
41 public String getLogin() {
42 return login;
43 }
44
45 public void setLogin(String login) {
46 this.login = login;
47 }
48
49 public String getPassword() {
50 return password;
51 }
52
53 public void setPassword(String password) {
54 this.password = password;
55 }
56
57
58 public boolean isSaveLogin() {
59 return saveLogin;
60 }
61
62 public void setSaveLogin(boolean saveLogin) {
63 this.saveLogin = saveLogin;
64 }
65
66 public void reset(ActionMapping mapping, HttpServletRequest request) {
67 login = null;
68 password = null;
69
70 }
71
72 public ActionErrors validate(ActionMapping mapping,
73 HttpServletRequest request) {
74 Boolean skipLogin = (Boolean) request.getSession().getAttribute(
75 "loginForwarded");
76 if (null == skipLogin) {
77 skipLogin = false;
78 }
79 skipLogin |= (null == getLogin() && null == getPassword());
80
81 ActionErrors errors;
82
83
84
85 if (skipLogin == null || !skipLogin.booleanValue()) {
86
87 errors = super.validate(mapping, request);
88 } else {
89 request.getSession().removeAttribute("loginForwarded");
90 return new ActionErrors();
91 }
92 return errors;
93 }
94
95 }