wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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;
 
/**
 * <p>Title:ChangePassworActionListener</p>
 * <p>Description:修改密码注册监听事件</p>
 * <p>Copyright: Copyright (C) 2011 </p>
 * <p>Company: VCI </p>
 *  
 *  @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();
         }
}