ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
package com.vci.client.framework.systemConfig.stafforgmanage;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;
 
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
 
import com.vci.client.LogonApplication;
import com.vci.client.framework.systemConfig.object.PasswordStrategyObject;
import com.vci.client.logon.base.BaseJDialog;
import com.vci.client.ui.image.BundleImage;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.KJButton;
import com.vci.client.ui.swing.KTextField;
import com.vci.client.ui.swing.components.VCIJPanel;
 
public class PasswordSrategyDialog extends BaseJDialog {
 
    private static final long serialVersionUID = 1L;
    private PasswordStrategyTablePanel pwdStgTablePanel;
    private PasswordStrategyObject pwdStgObj;
    private String optType;
    private Map<String, String> map = new HashMap<String, String>();
    private JLabel lblName = new JLabel("策略名称:");
    private JLabel passwordLabel = new JLabel("密码最小长度:");
    private JLabel passwordMaxLabel = new JLabel("密码最大长度:");
    private JLabel compentLabel = new JLabel("组合方式种类");
    private JLabel requiredTypeLabel = new JLabel("必填种类");
    private JLabel expiredLabel = new JLabel("过期时间:");
    private JLabel remideLabel = new JLabel("提醒时间:");
    private JLabel lockLabel = new JLabel("重试次数:");
    private JLabel lockTimeLabel = new JLabel("锁定时间:");
    private JLabel defaultPolicyLable = new JLabel("设置为默认策略");
    private JLabel descLabel = new JLabel("描述:");
 
    private JLabel unitMinuteLabel = new JLabel("(单位:分钟)");
    private JLabel unitDayLabel = new JLabel("(单位:天)");
    private JLabel unitExpireDayLabel = new JLabel("(单位:天)");
    private JLabel unitLockTimeLabel = new JLabel("(单位:次)");
 
    private KTextField txtName = new KTextField();
    private KTextField passwordLenText = new KTextField();
    private KTextField passwordLenMaxText = new KTextField();
    private JComboBox requiredTypeCbx = new JComboBox();
    private JCheckBox[] chkBoxes = null;
    private KTextField expiredText = new KTextField();
    private KTextField remideText = new KTextField();
    private KTextField lockText = new KTextField();
    private KTextField lockTimeText = new KTextField();
    private JTextField jTextField2 = new JTextField();
    private JTextField jTextField1 = new JTextField();
    private JCheckBox defaultBox = new JCheckBox();
    private JTextArea descriptionArea = new JTextArea();
 
    private KJButton conformButton = new KJButton(
            LocaleDisplay.getI18nString("rmip.framework.button.confirm", "RMIPFramework", getLocale()),
            "bullet_blue.png");
    private KJButton cancelButton = new KJButton(
            LocaleDisplay.getI18nString("rmip.framework.button.cancel", "RMIPFramework", getLocale()),
            "bullet_delete.png");
 
    public PasswordSrategyDialog(PasswordStrategyTablePanel pwdStgTablePanel, String optType) {
        super(LogonApplication.frame);
        this.setModal(true);
        this.pwdStgTablePanel = pwdStgTablePanel;
        this.optType = optType;
        init();
    }
 
    public PasswordSrategyDialog(PasswordStrategyTablePanel pwdStgTablePanel, PasswordStrategyObject pwdStgObj,
            String optType) {
        super(LogonApplication.frame);
        this.setModal(true);
        this.pwdStgTablePanel = pwdStgTablePanel;
        this.pwdStgObj = pwdStgObj;
        this.optType = optType;
        init();
    }
 
    /**
     * 初始化界面
     */
    public void init() {
        this.setTitle("密码策略");
 
        ImageIcon icon = new BundleImage().createImageIcon("folder_wrench.png");
 
        this.setIconImage(icon.getImage());
//         JLabel titleLabel = new JLabel();
//         titleLabel.setText("");
//         titleLabel.setIcon(new BundleImage().createImageIcon ("folder_wrench.png"));
 
        JPanel bottomPanel = new JPanel();
        bottomPanel.add(conformButton);
        bottomPanel.add(cancelButton);
 
        JPanel contentPanel = initCenterContentPanel();
 
        JPanel midPanel = new JPanel();
        midPanel.setLayout(new BorderLayout());
        JTextField jTextField1 = new JTextField();// instead of up line
        JTextField jTextField2 = new JTextField();// instead of down line
        jTextField1.setPreferredSize(new Dimension(63, 2));
        jTextField2.setPreferredSize(new Dimension(63, 2));
        midPanel.add(jTextField1, BorderLayout.NORTH);
        midPanel.add(jTextField2, BorderLayout.SOUTH);
        midPanel.add(contentPanel, BorderLayout.CENTER);
 
//         this.setLayout(new BorderLayout());
//         this.add(titleLabel, BorderLayout.NORTH);
//         this.add(midPanel, BorderLayout.CENTER);
//         this.add(bottomPanel, BorderLayout.SOUTH); 
 
        VCIJPanel pal = new VCIJPanel(new BorderLayout());
        // pal.add(titleLabel, BorderLayout.NORTH);
        pal.add(midPanel, BorderLayout.CENTER);
//         pal.add(bottomPanel, BorderLayout.SOUTH); 
        pal.setPreferredSize(new Dimension(450, 570));
 
        JScrollPane scroPal = new JScrollPane();
        scroPal.setPreferredSize(new Dimension(450, 580));
        scroPal.getViewport().add(pal);
        this.setLayout(new BorderLayout());
        this.add(scroPal, BorderLayout.CENTER);
        this.add(bottomPanel, BorderLayout.SOUTH);
        initDialogSize(480, 640);
        this.setResizable(true);
    }
 
    private JPanel initCenterContentPanel() {
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(null);
        JScrollPane jsDescription = new JScrollPane();
        lblName.setBounds(new Rectangle(62, 10, 150, 25));
        txtName.setBounds(new Rectangle(150, 10, 270, 25));
 
        passwordLabel.setBounds(new Rectangle(62, 40, 150, 25));
        passwordLenText.setBounds(new Rectangle(150, 40, 270, 25));
 
        passwordMaxLabel.setBounds(new Rectangle(62, 70, 150, 25));
        passwordLenMaxText.setBounds(new Rectangle(150, 70, 270, 25));
 
        compentLabel.setBounds(new Rectangle(62, 100, 150, 25));
        // JScrollPane scrollPanel = new JScrollPane(this.createCbxPanel());
        // scrollPanel.setBounds(40, 120, 380, 70);
        JPanel scrollPanel = new JPanel();
        scrollPanel.setLayout(null);
        scrollPanel.setBorder(new TitledBorder("组合方式种类"));
        scrollPanel.setBounds(40, 100, 380, 90);
        this.createCbxPanel(scrollPanel);
 
        requiredTypeLabel.setBounds(new Rectangle(62, 200, 380, 25));
        requiredTypeCbx.setBounds(new Rectangle(150, 200, 270, 25));
 
        JPanel expirationSetPal = new JPanel();
        expirationSetPal.setLayout(null);
        expirationSetPal.setBorder(new TitledBorder("过期时间设置"));
        expirationSetPal.setBounds(40, 240, 380, 90);
        expiredLabel.setBounds(new Rectangle(25, 25, 150, 25));
        remideLabel.setBounds(new Rectangle(25, 50, 150, 25));
        expiredText.setBounds(new Rectangle(110, 25, 200, 25));
        unitExpireDayLabel.setBounds(new Rectangle(310, 25, 200, 25));
        remideText.setBounds(new Rectangle(110, 50, 200, 25));
        unitDayLabel.setBounds(new Rectangle(310, 50, 200, 25));
 
        expirationSetPal.add(expiredLabel);
        expirationSetPal.add(expiredText);
        expirationSetPal.add(remideLabel);
        expirationSetPal.add(unitExpireDayLabel);
        expirationSetPal.add(remideText);
        expirationSetPal.add(unitDayLabel);
 
        JPanel lockTimeSetPal = new JPanel();
        lockTimeSetPal.setLayout(null);
        lockTimeSetPal.setBorder(new TitledBorder("重试次数设置"));
        lockTimeSetPal.setBounds(40, 340, 380, 90);
        lockLabel.setBounds(new Rectangle(25, 25, 150, 25));
        lockTimeLabel.setBounds(new Rectangle(25, 50, 150, 25));
        lockText.setBounds(new Rectangle(110, 25, 200, 25));
        unitLockTimeLabel.setBounds(new Rectangle(310, 25, 200, 25));
        lockTimeText.setBounds(new Rectangle(110, 50, 200, 25));
        unitMinuteLabel.setBounds(new Rectangle(310, 50, 200, 25));
        lockTimeSetPal.add(lockLabel);
        lockTimeSetPal.add(lockTimeLabel);
        lockTimeSetPal.add(lockText);
        lockTimeSetPal.add(unitLockTimeLabel);
        lockTimeSetPal.add(lockTimeText);
        lockTimeSetPal.add(unitMinuteLabel);
 
        descLabel.setBounds(new Rectangle(62, 440, 150, 25));
        jsDescription.setBounds(new Rectangle(150, 440, 270, 75));
        descriptionArea.setLineWrap(true);
        jsDescription.getViewport().add(descriptionArea);
        jTextField1.setPreferredSize(new Dimension(63, 2));
        jTextField2.setPreferredSize(new Dimension(63, 2));
 
        defaultBox.setBounds(new Rectangle(62, 520, 20, 25));
        defaultPolicyLable.setBounds(new Rectangle(82, 520, 200, 25));
 
        contentPanel.setLayout(null);
 
        contentPanel.add(lblName);
        contentPanel.add(txtName);
 
        contentPanel.add(passwordLabel);
        contentPanel.add(passwordLenText);
 
        contentPanel.add(passwordMaxLabel);
        contentPanel.add(passwordLenMaxText);
 
        // contentPanel.add(compentLabel);
        contentPanel.add(scrollPanel);
 
        contentPanel.add(requiredTypeLabel);
        contentPanel.add(requiredTypeCbx);
 
        contentPanel.add(expirationSetPal);
        contentPanel.add(lockTimeSetPal);
 
        contentPanel.add(descLabel);
        contentPanel.add(jsDescription);
 
        contentPanel.add(defaultBox);
        contentPanel.add(defaultPolicyLable);
 
        conformButton.addActionListener(new CommenListener(this, pwdStgTablePanel, optType, pwdStgObj));
 
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                cancelButton_ActionPerformed(e);
            }
        });
        initContent();
        return contentPanel;
    }
 
//    private JPanel createCbxPanel(){
//        JPanel pal = new VCIJPanel();
//        
//        try {
//            pal.removeAll();
//            CombinationObject[] combObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchAllCombinations();
//            int length = combObjs.length;
//            //bug2231  by liujw
//            
//            pal.setLayout(null);
//            chkBoxes = new JCheckBox[length];
//            int x = 0, y= 0, width = 80, height = 25;
//            for(int i = 0 ; i < length ; i ++){
//                map.put(combObjs[i].getName(),combObjs[i].getId());
//                chkBoxes[i] = new JCheckBox(combObjs[i].getName());
//                chkBoxes[i].setName(combObjs[i].getName());
//                if (i%2 == 1){
//                    x = 180; y = chkBoxes[i-1].getBounds().y;
//                    
//                }else {
//                    if (i == 0){
//                        x = 30 ; y = 0;
//                    }else{
//                        x = 30 ; y = chkBoxes[i-1].getBounds().y +30;
//                    }
//                    
//                }
//                chkBoxes[i].setBounds(x, y, width, height);
//                pal.add(chkBoxes[i]);
//                pal.updateUI();
//                requiredTypeCbx.addItem(i+1);
//            }
//            pal.setPreferredSize(new Dimension(360,y+20));
//        } catch (VCIException e1) {
//            e1.printStackTrace();
//        }
//        return pal;
//    }
 
    private void createCbxPanel(JPanel panel) {
        // JPanel pal = new VCIJPanel();
 
        int length = 4;
        String[] labels = new String[] { "数字", "小写字母", "大写字母", "符号" };
        String[] names = new String[] { "number", "lower", "upper", "symbol" };
        chkBoxes = new JCheckBox[length];
        int x = 0, y = 0, width = 80, height = 25;
        for (int i = 0; i < length; i++) {
            // map.put(names[i],labels[i]);
            chkBoxes[i] = new JCheckBox();
            chkBoxes[i].setName(names[i]);
            chkBoxes[i].setText(labels[i]);
            // chkBoxes[i].setName(combObjs[i].getName());
            if (i % 2 == 1) {
                x = 180;
                y = chkBoxes[i - 1].getBounds().y;
 
            } else {
                if (i == 0) {
                    x = 30;
                    y = 25;
                } else {
                    x = 30;
                    y = chkBoxes[i - 1].getBounds().y + 30;
                }
 
            }
            chkBoxes[i].setBounds(x, y, width, height);
            panel.add(chkBoxes[i]);
            // panel.updateUI();
            requiredTypeCbx.addItem(i + 1);
        }
        // pal.setPreferredSize(new Dimension(360,y+20));
    }
 
    private void initContent() {
        if (pwdStgObj != null) {
            txtName.setText(pwdStgObj.getName());
            passwordLenText.setText(String.valueOf(pwdStgObj.getPasswordLen()));
            passwordLenMaxText.setText(String.valueOf(pwdStgObj.getPasswordMaxLen()));
            requiredTypeCbx.setSelectedItem(pwdStgObj.getRequiredType());
            expiredText.setText(String.valueOf(pwdStgObj.getOverdueDay()));
            remideText.setText(String.valueOf(pwdStgObj.getRemideDay()));
            lockText.setText(String.valueOf(pwdStgObj.getRetryTime()));
            lockTimeText.setText(String.valueOf(pwdStgObj.getLockTime()));
            descriptionArea.setText(pwdStgObj.getDesc());
            // CombinationObject[] combinationObjs = null;
 
            int containsTypes = pwdStgObj.getCharTypes();
            for (int i = 0; i < 4; i++) {
                int type = (int) Math.pow(2, i);
                if ((containsTypes & type) == type) {
                    chkBoxes[i].setSelected(true);
                }
            }
 
            if (pwdStgObj.getIsDefault()) {
                defaultBox.setSelected(true);
            } else {
                defaultBox.setSelected(false);
            }
        }
    }
 
    /**
     * 取消按钮事件
     * 
     * @param e
     */
    private void cancelButton_ActionPerformed(ActionEvent e) {
        this.dispose();
    }
 
    public String getName() {
        return txtName.getText();
    }
 
    public String getDescriptionArea() {
        return descriptionArea.getText().trim();
    }
 
    public String getPasswordLen() {
        return passwordLenText.getText();
    }
 
    public String getPasswordMaxLen() {
        return this.passwordLenMaxText.getText();
    }
 
    public short getRequiredType() {
        short requiredType = 0;
        if (!"".equals(this.requiredTypeCbx.getSelectedItem())) {
            requiredType = Short.valueOf(this.requiredTypeCbx.getSelectedItem().toString());
        }
        return requiredType;
    }
 
    public short getContainsTypes() {
        short containsTypes = 0;
        for (int i = 0; i < chkBoxes.length; i++) {
            if (chkBoxes[i].isSelected()) {
                containsTypes = (short) (containsTypes | (short) Math.pow(2, i));
            }
        }
        return containsTypes;
    }
 
//    public String[] getCombinationId(){
//        List<String> list = new ArrayList<String>();
//        for (int i = 0 ; i < chkBoxes.length ; i ++){
//            if (chkBoxes[i].isSelected()){
//                String combinationName = chkBoxes[i].getName();
//                //String combinationOid = map.get(combinationName);
//                list.add(combinationName);
//            }
//        }
//        return list.toArray(new String[]{});
//    }
    public String getLockTime() {
        return lockTimeText.getText();
    }
 
    public String getOverDay() {
        return expiredText.getText();
    }
 
    public String getRemideDay() {
        return remideText.getText();
    }
 
    public String getLockCount() {
        return lockText.getText();
    }
 
    public boolean getIsDefault() {
        boolean isDefault = false;
        if (defaultBox.isSelected()) {
            isDefault = true;
        } else {
            isDefault = false;
        }
        return isDefault;
    }
 
}