类型: 安全缺陷

    程序中采用硬编码方式处理身份证号码,一方面会降低系统安全性,另一方面不易于程序维护。

    1. public class EmployeeDAO {
    2. private static Map<Integer, Employee> emps = new LinkedHashMap<Integer, Employee>();
    3. //...
    4. static {
    5. emps.put(1001, new Employee("330781198509075478", "韩信", 39, "18345322345", "6228482410842133810"));
    6. emps.put(1002, new Employee("330781198509075419", "张良", 40, "18987844774", "6221386102180111738"));
    7. emps.put(1003, new Employee("33078119850907853X", "萧何", 55, "13944837458", "6222801842821035763"));
    8. // ...
    9. }
    10. // 雇员信息的增删改查方法
    11. // ...
    12. }
    13. public class Employee {
    14. private String id; // 记录雇员的身份证号码
    15. private String name;
    16. private int age;
    17. private String tel; // 记录雇员的电话号码
    18. private String bankId; // 记录雇员的银行卡卡号
    19. public Employee() {}
    20. public Employee(String id, String name, int age, String tel, String bankId) {
    21. this.id = id;
    22. this.name = name;
    23. this.age = age;
    24. this.tel = tel;
    25. this.bankId = bankId;
    26. }
    27. // Getter and Setter
    28. // ...
    29. }