changepasswordform.java
来自「开源项目CRM之OpenCustomer」· Java 代码 · 共 169 行
JAVA
169 行
/*******************************************************************************
* ***** BEGIN LICENSE BLOCK Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is the OpenCustomer CRM.
*
* The Initial Developer of the Original Code is Thomas Bader (Bader & Jene
* Software-Ingenieurb黵o). Portions created by the Initial Developer are
* Copyright (C) 2005 the Initial Developer. All Rights Reserved.
*
* Contributor(s): Thomas Bader <thomas.bader@bader-jene.de>
*
* ***** END LICENSE BLOCK *****
*/
package org.opencustomer.application.web.module.system.user.profile;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.opencustomer.application.db.vo.system.UserVO;
import org.opencustomer.application.web.Globals;
import org.opencustomer.util.SignatureUtility;
import org.opencustomer.web.util.FormUtility;
import org.opencustomer.web.util.MessageUtil;
/**
*
* @author thbader
*/
public final class ChangePasswordForm extends org.opencustomer.application.web.struts.ActionForm
{
private static final long serialVersionUID = 3258126955676514609L;
private String oldPassword;
private String newPassword1;
private String newPassword2;
private String doChange;
private String doCancel;
public void validate(ActionMapping mapping, ActionMessages errors, HttpServletRequest request)
{
if (doChange != null)
{
oldPassword = FormUtility.adjustParameter(oldPassword, 20);
newPassword1 = FormUtility.adjustParameter(newPassword1, 20);
newPassword2 = FormUtility.adjustParameter(newPassword2, 20);
if (oldPassword == null)
errors.add("oldPassword", new ActionMessage("default.error.missingInput", MessageUtil.message(request, "domain.system.user.profile.changePassword.oldPassword")));
else
{
UserVO user = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
if (!SignatureUtility.getInstance().isSignatureValid(user.getPassword(), oldPassword))
errors.add("oldPassword", new ActionMessage("domain.system.user.profile.changePassword.error.invalidPassword", MessageUtil.message(request, "domain.system.user.profile.changePassword.oldPassword")));
}
if (newPassword1 == null)
errors.add("newPassword1", new ActionMessage("default.error.missingInput", MessageUtil.message(request, "domain.system.user.profile.changePassword.newPassword1")));
if (newPassword2 == null)
errors.add("newPassword2", new ActionMessage("default.error.missingInput", MessageUtil.message(request, "domain.system.user.profile.changePassword.newPassword2")));
if (newPassword1 != null && newPassword2 != null && !newPassword1.equals(newPassword2))
errors.add("newPassword2", new ActionMessage("domain.system.user.profile.changePassword.error.invalidPassword2", MessageUtil.message(request, "domain.system.user.profile.changePassword.newPassword2"), MessageUtil.message(request, "domain.system.user.profile.changePassword.newPassword1")));
}
else if (doCancel != null)
{
oldPassword = null;
newPassword1 = null;
newPassword2 = null;
}
}
/**
* @return Returns the newPassword1.
*/
public String getNewPassword1()
{
return newPassword1;
}
/**
* @param newPassword1 The newPassword1 to set.
*/
public void setNewPassword1(String newPassword1)
{
this.newPassword1 = newPassword1;
}
/**
* @return Returns the newPassword2.
*/
public String getNewPassword2()
{
return newPassword2;
}
/**
* @param newPassword2 The newPassword2 to set.
*/
public void setNewPassword2(String newPassword2)
{
this.newPassword2 = newPassword2;
}
/**
* @return Returns the oldPassword.
*/
public String getOldPassword()
{
return oldPassword;
}
/**
* @param oldPassword The oldPassword to set.
*/
public void setOldPassword(String oldPassword)
{
this.oldPassword = oldPassword;
}
/**
* @return Returns the doCancel.
*/
public final String getDoCancel()
{
return doCancel;
}
/**
* @param doCancel The doCancel to set.
*/
public final void setDoCancel(String doCancel)
{
this.doCancel = doCancel;
}
/**
* @return Returns the doChange.
*/
public final String getDoChange()
{
return doChange;
}
/**
* @param doChange The doChange to set.
*/
public final void setDoChange(String doChange)
{
this.doChange = doChange;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?