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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
package com.vci.client.framework.systemConfig.stafforgmanage;
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import javax.swing.JPanel;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.objects.DeptObject;
import com.vci.client.common.objects.RoleObject;
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.PasswordStrategyObject;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.common.utility.ObjectUtility;
 
public class CommenListener extends JPanel implements ActionListener {
 
    private static final long serialVersionUID = 1L;
    private CombinationTablePanel combinationPanel;
    private CombinationDialog combinationDialog;
    private CombinationObject combinationObj;
    private RoleDialog roleDialog;
    private RoleTablePanel rolePanel;
    private DeptDialog deptDialog;
    private DeptObject parentDeptObj;
    private DeptObject deptObj;
    private DeptTablePanel deptPanel;
    private RoleObject roleObj;
    private PasswordSrategyDialog pwdStgDialog;
    private PasswordStrategyTablePanel pwdStgPanel;
    private PasswordStrategyObject pwdStgObj;
    private String optType;
    private UserObject logonUser = LogonApplication.getUserObject();
    private String userName = LogonApplication.getUserEntityObject().getUserName();
 
    public CommenListener(CombinationDialog combinationDialog, CombinationTablePanel combinationPanel, String optType,
            CombinationObject combinationObj) {
        this.combinationDialog = combinationDialog;
        this.combinationPanel = combinationPanel;
        this.optType = optType;
        this.combinationObj = combinationObj;
    }
 
    public CommenListener(RoleDialog roleDialog, RoleTablePanel rolePanel, String optType, RoleObject roleObj) {
        this.roleDialog = roleDialog;
        this.rolePanel = rolePanel;
        this.optType = optType;
        this.roleObj = roleObj;
    }
 
    public CommenListener(DeptDialog deptDialog, DeptTablePanel deptPanel, String optType, DeptObject parentDeptObj,
            DeptObject deptObj) {
        this.deptDialog = deptDialog;
        this.deptPanel = deptPanel;
        this.optType = optType;
        this.parentDeptObj = parentDeptObj;
        this.deptObj = deptObj;
    }
 
    public CommenListener(PasswordSrategyDialog pwdStgDialog, PasswordStrategyTablePanel pwdStgPanel, String optType,
            PasswordStrategyObject pwdStgObj) {
        this.pwdStgDialog = pwdStgDialog;
        this.pwdStgPanel = pwdStgPanel;
        this.optType = optType;
        this.pwdStgObj = pwdStgObj;
    }
 
    public void actionPerformed(ActionEvent e) {
        if (optType.equals("addDept")) {
            addDept_actionPerformed();
        } else if (optType.equals("addRole")) {
            addRole_actionPerformed();
        } else if (optType.equals("editDept")) {
            editDept_actionPerformed();
        } else if (optType.equals("editRole")) {
            editRole_actionPerformed();
        } else if (optType.equals("addPwdStg")) {
            addPwdStg_actionPerformed();
        } else if (optType.equals("editPwdStg")) {
            editPwdStg_actionPerformed();
        } else if (optType.equals("addCombination")) {
            addCombination_actionPerformed();
        } else if (optType.equals("editCombination")) {
            editCombination_actionPerformed();
        }
    }
 
    /**
     * 添加密码组合方式
     * <p>
     * Description:
     * </p>
     * 
     * @author wangxl
     * @time 2013-1-3
     */
    private void addCombination_actionPerformed() {
        boolean rs = checkCombination();
        if (!rs) {
            return;
        }
        CombinationObject combObj = getCombinationInfo();
        try {
            String id = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
                    .saveCombination(combObj);
            combObj.setId(id);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        combinationDialog.dispose();
        combinationPanel.tablePanel.refreshTableData();
    }
 
    /**
     * 修改密码组合方式
     * <p>
     * Description:
     * </p>
     * 
     * @author wangxl
     * @time 2013-1-3
     */
    private void editCombination_actionPerformed() {
        boolean rs = checkCombination();
        if (!rs) {
            return;
        }
        CombinationObject combObj = getCombinationInfo();
        try {
            new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).updateCombination(combObj);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        combinationDialog.dispose();
        combinationPanel.tablePanel.refreshTableData();
    }
 
    /**
     * 注册部门添加事件
     */
    private void addDept_actionPerformed() {
        boolean rs = checkDept();
        if (!rs) {
            return;
        }
        DeptObject departmentInfo = getDepartmentInfo();
        try {
            String id = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
                    .saveDepartment(departmentInfo);
            departmentInfo.setId(id);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
 
        deptDialog.dispose();
        deptPanel.insertNewDeptObjToTree(departmentInfo);
    }
 
    /**
     * <p>
     * Description: 添加角色
     * </p>
     * 
     * @author wangxl
     * @time 2012-5-11
     */
    private void addRole_actionPerformed() {
        boolean rs = checkRole();
        if (!rs) {
            return;
        }
        RoleObject roleInfo = getRoleInfo();
        try {
            String id = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).saveRole(roleInfo);
            roleInfo.setId(id);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        roleDialog.dispose();
        rolePanel.tablePanel.refreshTableData();
    }
 
    /**
     * 注册编辑部门事件
     */
    private void editDept_actionPerformed() {
        boolean rs = checkDept();
        if (!rs) {
            return;
        }
        DeptObject departmentInfo = getDepartmentInfo();
        try {
            new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).updateDepartment(departmentInfo);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        deptDialog.dispose();
        deptPanel.updateCurrentDeptObjForTree(departmentInfo);
    }
 
    /**
     * <p>
     * Description: 注册角色修改事件
     * </p>
     * 
     * @author wangxl
     * @time 2012-5-11
     */
    private void editRole_actionPerformed() {
        boolean rs = checkRole();
        if (!rs) {
            return;
        }
        RoleObject roleInfo = getRoleInfo();
        try {
            new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).updateRole(roleInfo);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        roleDialog.dispose();
        rolePanel.tablePanel.refreshTableData();
    }
 
    /**
     * 得到部门
     * 
     * @return
     */
    private DeptObject getDepartmentInfo() {
        DeptObject departmentInfo = new DeptObject();
        departmentInfo.setNum(deptDialog.getNumText());
        departmentInfo.setName(deptDialog.getNameText());
        departmentInfo.setCode(deptDialog.getCodeText());
        departmentInfo.setSpecialties(deptDialog.getSpecialtiesText());
        departmentInfo.setDescription(deptDialog.getDescriptionArea());
        String parentId = parentDeptObj.getId();
 
        departmentInfo.setParentId(parentId);
        // 增加,状态为未同步
        if (optType.equalsIgnoreCase("addDept")) {
            departmentInfo.setStatus((short) 0);
        } else {
            if (deptObj.getStatus() == 0) {
                departmentInfo.setStatus((short) 0);
            } else if (deptObj.getStatus() == 1 || deptObj.getStatus() == 2) {
                departmentInfo.setStatus((short) 1);
            }
        }
        departmentInfo.setCreateTime(System.currentTimeMillis());
        departmentInfo.setCreateUser(userName);
        departmentInfo.setUpdateTime(System.currentTimeMillis());
        departmentInfo.setUpdateUser(userName);
        if ("editDept".equalsIgnoreCase(optType)) {
            departmentInfo.setId(deptObj.getId());
            departmentInfo.setGrantor(deptObj.getGrantor());
        }
        return departmentInfo;
    }
 
    private boolean checkDept() {
        String name = deptDialog.getNameText();
        if ("".equals(name)) {
            VCIOptionPane.showMessageDialog(deptDialog, "部门名称不能为空,请填写!");
            return false;
        }
 
        if (name.getBytes().length > 128) {
            VCIOptionPane.showMessageDialog(deptDialog, "名称过长,不能大于128个字节!");
            return false;
        }
 
        String num = deptDialog.getNumText();
        if (!"".equals(num)) {
            if (num.getBytes().length > 64) {
                VCIOptionPane.showMessageDialog(roleDialog, "编号过长,不能大于64个字节!");
                return false;
            }
        }
 
        String specialties = deptDialog.getSpecialtiesText();
        if (!"".equals(specialties)) {
            if (specialties.getBytes().length > 255) {
                VCIOptionPane.showMessageDialog(roleDialog, "编号过长,不能大于255个字节!");
                return false;
            }
        }
        String parentId = parentDeptObj.getId() == null ? "" : parentDeptObj.getId();
        DeptObject[] deptObjs = null;
        try {
            deptObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
                    .fetchDepartmentInfoByParentId(parentId);
            if (deptObjs != null) {
                int size = deptObjs.length;
                for (int i = 0; i < size; i++) {
                    if (name.equals(deptObjs[i].getName())) {
                        if ("editDept".equalsIgnoreCase(optType)) {
                            if (deptObj.getId().equals(deptObjs[i].getId())) {
                                continue;
                            }
                        }
                        VCIOptionPane.showMessageDialog(roleDialog, "同级部门不能存在相同名称的部门,请修改名称!");
                        return false;
                    }
 
                    if (!"".equals(num)) {
                        if (num.equals(deptObjs[i].getNum())) {
                            if ("editDept".equalsIgnoreCase(optType)) {
                                if (deptObj.getId().equals(deptObjs[i].getId())) {
                                    continue;
                                }
                            }
                            VCIOptionPane.showMessageDialog(roleDialog, "部门编号在已经存在,请修改!");
                            return false;
                        }
                    }
                }
            }
 
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return false;
        }
        return true;
    }
 
    /**
     * <p>
     * Description:得到角色
     * </p>
     * 
     * @author wangxl
     * @time 2012-5-11
     * @return
     */
    private RoleObject getRoleInfo() {
        RoleObject roleInfo = new RoleObject();
        roleInfo.setName(roleDialog.getNameText());
        roleInfo.setDescription(roleDialog.getDescriptionArea());
        roleInfo.setType(logonUser.getUserType());
        if ("editRole".equalsIgnoreCase(optType)) {
            roleInfo.setId(roleObj.getId());
        }
        roleInfo.setCreateTime(System.currentTimeMillis());
        roleInfo.setCreateUser(userName);
        roleInfo.setUpdateTime(System.currentTimeMillis());
        roleInfo.setUpdateUser(userName);
        return roleInfo;
    }
 
    private boolean checkRole() {
        String name = roleDialog.getNameText();
        if ("".equalsIgnoreCase(name)) {
            VCIOptionPane.showMessageDialog(roleDialog, "角色名称不能为空,请填写!");
            return false;
        }
 
        if (name.getBytes().length > 128) {
            VCIOptionPane.showMessageDialog(roleDialog, "名称过长,不能大于128个字节!");
            return false;
        }
        if (roleDialog.getDescriptionArea().getBytes().length > 255) {
            VCIOptionPane.showMessageDialog(roleDialog, "描述过长,不能大于255个字节!");
            return false;
        }
 
        RoleObject[] roleObjs = null;
        try {
            roleObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchRoleInfo();
 
            int size = roleObjs.length;
            for (int i = 0; i < size; i++) {
                if (name.equals(roleObjs[i].getName())) {
                    if ("editRole".equalsIgnoreCase(optType)) {
                        if (roleObj.getId().equals(roleObjs[i].getId())) {
                            continue;
                        }
                    }
                    VCIOptionPane.showMessageDialog(roleDialog, "该角色名称已经存在,请修改!");
                    return false;
                }
            }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return false;
        }
        return true;
    }
 
    /**
     * 得到密码组合方式对象
     * <p>
     * Description:
     * </p>
     * 
     * @author wangxl
     * @time 2013-1-3
     * @return
     */
    private CombinationObject getCombinationInfo() {
        CombinationObject combinationInfo = new CombinationObject();
        combinationInfo.setName(combinationDialog.getNameText());
        combinationInfo.setDescription(combinationDialog.getDescriptionArea());
        if ("editCombination".equalsIgnoreCase(optType)) {
            combinationInfo.setId(combinationObj.getId());
        }
        combinationInfo.setCreateTime(System.currentTimeMillis());
        combinationInfo.setCreateUser(userName);
        combinationInfo.setUpdateTime(System.currentTimeMillis());
        combinationInfo.setUpdateUser(userName);
        return combinationInfo;
    }
 
    private boolean checkCombination() {
        String name = combinationDialog.getNameText();
        if ("".equalsIgnoreCase(name)) {
            VCIOptionPane.showMessageDialog(roleDialog, "密码组合方式名称不能为空,请填写!");
            return false;
        }
 
        if (name.getBytes().length > 128) {
            VCIOptionPane.showMessageDialog(roleDialog, "名称过长,不能大于128个字节!");
            return false;
        }
        if (combinationDialog.getDescriptionArea().getBytes().length > 255) {
            VCIOptionPane.showMessageDialog(roleDialog, "描述过长,不能大于255个字节!");
            return false;
        }
 
        CombinationObject[] combinationObjs = null;
        try {
            combinationObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
                    .fetchAllCombinations();
 
            int size = combinationObjs.length;
            for (int i = 0; i < size; i++) {
                if (name.equals(combinationObjs[i].getName())) {
                    if ("editCombination".equalsIgnoreCase(optType)) {
                        if (combinationObj.getId().equals(combinationObjs[i].getId())) {
                            continue;
                        }
                    }
                    VCIOptionPane.showMessageDialog(roleDialog, "该密码组合方式名称已经存在,请修改!");
                    return false;
                }
            }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return false;
        }
        return true;
    }
 
    /**
     * <p>
     * Description:增加密码策略
     * </p>
     * 
     * @author wangxl
     * @time 2012-5-23
     */
    public void addPwdStg_actionPerformed() {
        if (!checkPwdStg()) {
            return;
        }
        PasswordStrategyObject obj = getPasswordStrategyObj();
        if (obj == null) {
            return;
        }
        // String[] combinationIds = pwdStgDialog.getCombinationId();
        try {
            new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).savePasswordStrategy(obj);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        pwdStgDialog.dispose();
        pwdStgPanel.tablePanel.refreshTableData();
    }
 
    /**
     * <p>
     * Description:修改密码策略
     * </p>
     * 
     * @author wangxl
     * @time 2012-5-23
     */
    public void editPwdStg_actionPerformed() {
        if (!checkPwdStg()) {
            return;
        }
        PasswordStrategyObject obj = getPasswordStrategyObj();
        if (obj == null) {
            return;
        }
        // String[] combinationIds = pwdStgDialog.getCombinationId();
        try {
            new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).editPasswordStrategy(obj);
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
            return;
        }
        pwdStgDialog.dispose();
        pwdStgPanel.tablePanel.refreshTableData();
    }
 
    private boolean checkPwdStg() {
        String name = pwdStgDialog.getName();
        String passwordLen = pwdStgDialog.getPasswordLen();
        String passwordMaxLen = pwdStgDialog.getPasswordMaxLen();
        // String[] combinationIds = pwdStgDialog.getCombinationId();
        short containsTypes = pwdStgDialog.getContainsTypes();
        short requiredType = pwdStgDialog.getRequiredType();
        String overDay = pwdStgDialog.getOverDay();
        String remideDay = pwdStgDialog.getRemideDay();
        String lockCount = pwdStgDialog.getLockCount();
        String lockTime = pwdStgDialog.getLockTime();
        boolean isDefault = pwdStgDialog.getIsDefault();
        String desc = pwdStgDialog.getDescriptionArea();
 
        int typeCount = 0;
        for (int i = 0; i < 4; i++) {
            int type = (int) Math.pow(2, i);
            if ((containsTypes & type) == type)
                typeCount++;
        }
 
        if ("".equals(name)) {
            VCIOptionPane.showMessageDialog(this, "名称不能为空!");
            return false;
        }
 
        if (name.length() > 128) {
            VCIOptionPane.showMessageDialog(this, "名称长度不能超过128个字节!");
            return false;
        }
 
        if ("".equals(passwordLen)) {
            VCIOptionPane.showMessageDialog(this, "密码最小长度不能为空!");
            return false;
        }
 
        if (!checkPattern(passwordLen)) {
            VCIOptionPane.showMessageDialog(this, "密码最小长度只能输入(0-9)的数字!");
            return false;
        }
 
        if (Integer.valueOf(passwordLen) == 0) {
            VCIOptionPane.showMessageDialog(this, "密码最小长度不能为0!");
            return false;
        }
        if ("".equals(passwordMaxLen)) {
            VCIOptionPane.showMessageDialog(this, "密码最大长度不能为空!");
            return false;
        }
 
        if (!checkPattern(passwordMaxLen)) {
            VCIOptionPane.showMessageDialog(this, "密码最大长度只能输入(0-9)的数字!");
            return false;
        }
 
        if (Integer.valueOf(passwordMaxLen) == 0) {
            VCIOptionPane.showMessageDialog(this, "密码最大长度不能为0!");
            return false;
        }
 
        if (Integer.valueOf(passwordLen) > Integer.valueOf(passwordMaxLen)) {
            VCIOptionPane.showMessageDialog(this, "密码最小长度不能大于最大长度!");
            return false;
        }
 
        if (containsTypes == 0) {
            VCIOptionPane.showMessageDialog(this, "请选择密码组合方式!");
            return false;
        }
 
        if (requiredType == 0) {
            VCIOptionPane.showMessageDialog(this, "请选择密码必填种类!");
            return false;
        }
 
        if (requiredType > typeCount) {
            VCIOptionPane.showMessageDialog(this, "密码必填种类不能大于所选择的密码组合方式的个数");
            return false;
        }
 
        if ("".equals(overDay)) {
            VCIOptionPane.showMessageDialog(this, "过期时间不能为空!");
            return false;
        }
 
        if (!checkPattern(overDay)) {
            VCIOptionPane.showMessageDialog(this, "过期时间只能输入(0-9)的数字!");
            return false;
        }
 
        if (Integer.valueOf(overDay) == 0) {
            VCIOptionPane.showMessageDialog(this, "过期时间不能为0!");
            return false;
        }
 
        if ("".equals(remideDay)) {
            VCIOptionPane.showMessageDialog(this, "提醒时间不能为空!");
            return false;
        }
 
        if (!checkPattern(remideDay)) {
            VCIOptionPane.showMessageDialog(this, "提醒时间只能输入(0-9)的数字!");
            return false;
        }
 
        if (Integer.valueOf(remideDay) == 0) {
            VCIOptionPane.showMessageDialog(this, "提醒时间不能为0!");
            return false;
        }
 
        if (Integer.parseInt(overDay) < Integer.valueOf(remideDay)) {
            VCIOptionPane.showMessageDialog(this, "过期时间不能小于提醒时间!");
            return false;
        }
 
        if ("".equals(lockCount)) {
            VCIOptionPane.showMessageDialog(this, "锁定次数不能为空!");
            return false;
        }
        if (!checkPattern(lockCount)) {
            VCIOptionPane.showMessageDialog(this, "锁定次数只能输入(0-9)的数字!");
            return false;
        }
 
        if (Integer.valueOf(lockCount) == 0) {
            VCIOptionPane.showMessageDialog(this, "锁定次数不能为0!");
            return false;
        }
 
        if ("".equals(lockTime)) {
            VCIOptionPane.showMessageDialog(this, "锁定时间不能为空!");
            return false;
        }
        if (!checkPattern(lockTime)) {
            VCIOptionPane.showMessageDialog(this, "锁定时间只能输入(0-9)的数字!");
            return false;
        }
 
        if (Integer.valueOf(lockTime) == 0) {
            VCIOptionPane.showMessageDialog(this, "锁定时间不能为0!");
            return false;
        }
 
        if (desc.length() > 255) {
            VCIOptionPane.showMessageDialog(this, "描述长度不能超过255个字节!");
            return false;
        }
        try {
            PasswordStrategyObject[] psdStgObjs = new RightManagementClientDelegate(
                    LogonApplication.getUserEntityObject()).fetchAllPasswordStrategy();
            // 判断名称是否存在
            for (PasswordStrategyObject info : psdStgObjs) {
                if (info.getName().equals(pwdStgDialog.getName())) {
                    if ("editPwdStg".equalsIgnoreCase(optType)) {
                        if (pwdStgObj.getId().equals(info.getId())) {
                            continue;
                        }
                    }
                    VCIOptionPane.showMessageDialog(this, "策略名称已经存在,请进行修改!");
                    return false;
                }
                if (info.getIsDefault() && isDefault) {
                    if ("editPwdStg".equalsIgnoreCase(optType)) {
                        if (pwdStgObj.getId().equals(info.getId())) {
                            continue;
                        }
                    }
                    int ok = VCIOptionPane.showQuestion(LogonApplication.frame, "系统中已经存在了默认密码策略,确定要更改默认密码策略吗?");
                    if (ok == 1) {
                        return false;
                    }
                }
            }
 
        } catch (VCIException re) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", re);
            return false;
        }
        return true;
    }
 
    // 正则表达式校验
    public boolean checkPattern(String input) {
        String str = "^[0-9]*$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(input);
        return m.matches();
    }
 
    private PasswordStrategyObject getPasswordStrategyObj() {
        PasswordStrategyObject obj = new PasswordStrategyObject();
        String name = pwdStgDialog.getName();
        String passwordLen = pwdStgDialog.getPasswordLen();
        String passwordMaxLen = pwdStgDialog.getPasswordMaxLen();
        short containsTypes = pwdStgDialog.getContainsTypes();
        short requiredType = pwdStgDialog.getRequiredType();
//            String charSpeci = pwdStgDialog.getCharspeci();
        String overDay = pwdStgDialog.getOverDay();
        String remideDay = pwdStgDialog.getRemideDay();
        String lockCount = pwdStgDialog.getLockCount();
        String lockTime = pwdStgDialog.getLockTime();
        boolean isDefault = pwdStgDialog.getIsDefault();
        String desc = pwdStgDialog.getDescriptionArea();
        // 当密码长度大于密码策略的时候
        if (Integer.valueOf(passwordLen) >= requiredType) {
            obj.setName(name);
            obj.setPasswordLen(Short.valueOf(passwordLen));
            obj.setPasswordMaxLen(Short.valueOf(passwordMaxLen));
            obj.setCharTypes(containsTypes);
            obj.setRequiredType(requiredType);
            // obj.setCharSpeics(charSpeci);
            obj.setOverdueDay(Short.valueOf(overDay));
            obj.setRemideDay(Short.valueOf(remideDay));
            obj.setRetryTime(Short.valueOf(lockCount));
            obj.setLockTime(Short.valueOf(lockTime));
            obj.setIsDefault(isDefault);
            obj.setDesc(desc);
 
            if ("addPwdStg".equals(optType)) {
                String id = ObjectUtility.getNewObjectID36();
                obj.setId(id);
            } else if ("editPwdStg".equals(optType)) {
                obj.setId(pwdStgObj.getId());
            }
            obj.setCreateTime(System.currentTimeMillis());
            obj.setCreateUser(userName);
            obj.setUpdateTime(System.currentTimeMillis());
            obj.setUpdateUser(userName);
        } else {
            VCIOptionPane.showMessageDialog(this, "密码最小长度不能小于秘密策略的值!");
            return null;
        }
        return obj;
    }
}