package com.vci.client.logon.base; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.JPanel; import com.vci.client.LogonApplication; import com.vci.client.common.objects.UserEntityObject; import com.vci.client.common.objects.UserObject; import com.vci.client.framework.delegate.RightManagementClientDelegate; import com.vci.client.framework.systemConfig.object.CombinationObject; import com.vci.client.framework.systemConfig.object.CombinationValueObject; import com.vci.client.framework.systemConfig.object.PasswordStrategyObject; import com.vci.client.framework.systemConfig.stafforgmanage.CheckPassWordStrategy; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.locale.LocaleDisplay; import com.vci.client.ui.swing.VCIOptionPane; /** *

Title:ChangePassworActionListener

*

Description:修改密码注册监听事件

*

Copyright: Copyright (C) 2011

*

Company: VCI

* * @author wangxl * @time 2011-6-25 * @version 1.0 */ public class ChangePassworActionListener extends JPanel implements ActionListener{ private static final long serialVersionUID = 1L; private ChangePasswordDialog dialog; private String type; private String prePasswordText; private String passwordText; private String confirmText; private UserEntityObject userEntityObj = null; private UserObject userObject = null; // UserObject userObject = LogonApplication.getUserObject(); public ChangePassworActionListener(ChangePasswordDialog dialog,String type,UserEntityObject userEntityObj){ this.dialog=dialog; this.type=type; this.userEntityObj = userEntityObj; this.userObject = getUserObjByIdAndName(); } private UserObject getUserObjByIdAndName() { UserObject userObj; try { userObj = new RightManagementClientDelegate(userEntityObj).fetchUserInfoByName(userEntityObj.getUserName()); return userObj; } catch (VCIException e) { e.printStackTrace(); } return null; } public void actionPerformed(ActionEvent e) { if("cancel".equals(type)){ dialog.dispose(); }else if("save".equals(type)){ modifyPassword(); } } private void modifyPassword(){ boolean rs=check(); if(!rs){ return; } edit_actionPerformed(); } private boolean check(){ prePasswordText=dialog.getPrePasswordText(); passwordText=dialog.getPasswordText(); confirmText=dialog.getConfirmText(); if("".equals(prePasswordText)||"".equals(passwordText)||"".equals(confirmText)){ VCIOptionPane.showMessageDialog(dialog,"填写框不能有空值,请输入!"); return false; } if (!prePasswordText.equals(userObject.getPwd())){ VCIOptionPane.showMessageDialog(dialog,"您输入的密码与登录密码不一致,请重新输入!"); return false; } if(!passwordText.equals(confirmText)){ VCIOptionPane.showMessageDialog(dialog,"确认密码与修改密码不一致,请重新输入!"); return false; } //add by caill start 2016.12.8 将对密码策略的校验的方法抽取为公共通用方法 CheckPassWordStrategy checkPWS = new CheckPassWordStrategy(); boolean pWSCheck = checkPWS.passwordStrategyCheck(userObject.getId(),passwordText,dialog); //对密码策略进行校验 return pWSCheck; //add by caill end } private void edit_actionPerformed() { String id = userObject.getId(); UserObject obj = new UserObject(); obj.setId(id); obj.setUserName(userObject.getUserName()); obj.setPwd(passwordText); obj.setCreateTime(userObject.getCreateTime()); obj.setCreateUser(userObject.getCreateUser()); obj.setEmail(userObject.getEmail()); obj.setTrueName(userObject.getTrueName()); obj.setUpdateTime(userObject.getUpdateTime()); obj.setUpdateUser(userObject.getUpdateUser()); obj.setDesc(userObject.getDesc()); obj.setPwdUpdateTime(System.currentTimeMillis()); obj.setSecretGrade(userObject.getSecretGrade()); obj.setStatus(userObject.getStatus()); obj.setIsDeptLeader(userObject.getIsDeptLeader()); obj.setUserType(userObject.getUserType()); obj.setGrantor(userObject.getGrantor()); try { new RightManagementClientDelegate(userEntityObj).updateUser(obj); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e); return; }VCIOptionPane.showMessageDialog(LogonApplication.frame, LocaleDisplay.getI18nString("rmip.framework.logon.changepwd.success", "RMIPFramework", getLocale())); userObject.setPwd(passwordText); dialog.dispose(); } }