1 6 7 package com.quikj.application.communicator.admin.controller; 8 9 import javax.servlet.http.HttpServletRequest ; 10 import org.apache.struts.action.*; 11 15 public class ChangePasswordForm extends ActionForm 16 { 17 18 19 private String oldPassword; 20 21 22 private String newPassword; 23 24 25 private String newPasswordAgain; 26 27 28 public ChangePasswordForm() 29 { 30 } 31 32 36 public String getOldPassword() 37 { 38 return this.oldPassword; 39 } 40 41 45 public void setOldPassword(String oldPassword) 46 { 47 this.oldPassword = oldPassword.trim(); 48 } 49 50 54 public String getNewPassword() 55 { 56 return this.newPassword; 57 } 58 59 63 public void setNewPassword(String newPassword) 64 { 65 this.newPassword = newPassword; 66 } 67 68 public ActionErrors validate(ActionMapping mapping, 69 HttpServletRequest request) 70 { 71 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 121 public String getNewPasswordAgain() 122 { 123 return this.newPasswordAgain; 124 } 125 126 130 public void setNewPasswordAgain(String newPasswordAgain) 131 { 132 this.newPasswordAgain = newPasswordAgain; 133 } 134 } 135 | Popular Tags |