1 package org.sourceforge.vlibrary.security.forms;
2
3 import org.apache.struts.action.ActionForm;
4 import javax.servlet.http.HttpServletRequest;
5 import org.apache.struts.action.ActionMessage;
6 import org.apache.struts.action.ActionErrors;
7 import org.apache.struts.action.ActionMapping;
8
9
10
11
12
13
14 public class PasswordResetForm extends ActionForm {
15 private static final long serialVersionUID = 0;
16
17 private String pwd = null;
18 private String confirmPwd = null;
19
20 public String getConfirmPwd() {
21 return confirmPwd;
22 }
23
24 public void setConfirmPwd(String confirmPwd) {
25 this.confirmPwd = confirmPwd;
26 }
27
28 public String getPwd() {
29 return pwd;
30 }
31
32 public void setPwd(String pwd) {
33 this.pwd = pwd;
34 }
35
36 public void reset(ActionMapping mapping, HttpServletRequest request) {
37 this.pwd = null;
38 this.confirmPwd=null;
39 }
40
41
42
43
44
45
46
47
48
49
50
51 public ActionErrors validate(ActionMapping mapping,
52 HttpServletRequest request) {
53 ActionErrors errors = new ActionErrors();
54
55 if ((pwd == null) || (pwd.length() < 1))
56 errors.add("pwd",
57 new ActionMessage("error.reader.password.required"));
58
59 if ((confirmPwd == null) || (confirmPwd.length() < 1))
60 errors.add("confirmPwd",
61 new ActionMessage
62 ("error.reader.password.confirmation.required"));
63
64
65 if (!(pwd.equals(confirmPwd)))
66 errors.add("password",
67 new ActionMessage("error.reader.confirmPwdFailed"));
68
69 return errors;
70 }
71 }