KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > admin > controller > ChangePasswordForm


1 /*
2  * ChangePasswordForm.java
3  *
4  * Created on May 9, 2003, 3:15 PM
5  */

6
7 package com.quikj.application.communicator.admin.controller;
8
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import org.apache.struts.action.*;
11 /**
12  *
13  * @author bhm
14  */

15 public class ChangePasswordForm extends ActionForm
16 {
17     
18     /** Holds value of property oldPassword. */
19     private String JavaDoc oldPassword;
20     
21     /** Holds value of property newPassword. */
22     private String JavaDoc newPassword;
23     
24     /** Holds value of property newPasswordAgain. */
25     private String JavaDoc newPasswordAgain;
26     
27     /** Creates a new instance of ChangePasswordForm */
28     public ChangePasswordForm()
29     {
30     }
31     
32     /** Getter for property oldPassword.
33      * @return Value of property oldPassword.
34      *
35      */

36     public String JavaDoc getOldPassword()
37     {
38         return this.oldPassword;
39     }
40     
41     /** Setter for property oldPassword.
42      * @param oldPassword New value of property oldPassword.
43      *
44      */

45     public void setOldPassword(String JavaDoc oldPassword)
46     {
47         this.oldPassword = oldPassword.trim();
48     }
49     
50     /** Getter for property newPassword.
51      * @return Value of property newPassword.
52      *
53      */

54     public String JavaDoc getNewPassword()
55     {
56         return this.newPassword;
57     }
58     
59     /** Setter for property newPassword.
60      * @param newPassword New value of property newPassword.
61      *
62      */

63     public void setNewPassword(String JavaDoc newPassword)
64     {
65         this.newPassword = newPassword;
66     }
67     
68     public ActionErrors validate(ActionMapping mapping,
69     HttpServletRequest JavaDoc request)
70     {
71         // Check for mandatory data
72
ActionErrors errors = new ActionErrors();
73         
74         if (oldPassword == null)
75         {
76            errors.add("oldPassword", new ActionError("error.password.old.empty"));
77         }
78         else if (oldPassword.length() == 0)
79         {
80            errors.add("oldPassword", new ActionError("error.password.old.empty"));
81         }
82         
83         if (newPassword == null)
84         {
85            errors.add("newPassword", new ActionError("error.password.new.empty"));
86         }
87         else if (newPassword.length() == 0)
88         {
89            errors.add("newPassword", new ActionError("error.password.new.empty"));
90         }
91         else
92         {
93             AccountManagementForm.validatePassword(newPassword, errors, "newPassword");
94         }
95         
96         if (newPasswordAgain == null)
97         {
98             errors.add("newPasswordAgain", new ActionError("error.password.verify.empty"));
99         }
100         else if (newPasswordAgain.length() == 0)
101         {
102             errors.add("newPasswordAgain", new ActionError("error.password.verify.empty"));
103         }
104         
105         
106         if ((newPassword != null) && (newPasswordAgain != null))
107         {
108             if (newPassword.equals(newPasswordAgain) == false)
109             {
110                 errors.add("newPassword", new ActionError("error.password.mismatch"));
111             }
112         }
113         
114         return errors;
115     }
116     
117     /** Getter for property newPasswordAgain.
118      * @return Value of property newPasswordAgain.
119      *
120      */

121     public String JavaDoc getNewPasswordAgain()
122     {
123         return this.newPasswordAgain;
124     }
125     
126     /** Setter for property newPasswordAgain.
127      * @param newPasswordAgain New value of property newPasswordAgain.
128      *
129      */

130     public void setNewPasswordAgain(String JavaDoc newPasswordAgain)
131     {
132         this.newPasswordAgain = newPasswordAgain;
133     }
134 }
135
Popular Tags