类型: 安全缺陷

    程序中采用了硬编码方式处理邮箱地址,一方面会降低系统安全性,另一方面不易于程序维护。

    1. public class UserDAO {
    2. private static Map<Integer, User> users = new LinkedHashMap<Integer, User>();
    3. static {
    4. users.put(1001, new User(1001, "韩信", 30, "18984758285", "hanxin@126.com"));
    5. users.put(1002, new User(1002, "张良", 30, "18366666678", "zhangliang@163.com"));
    6. users.put(1003, new User(1003, "萧何", 47, "18922220007", "xiaohe@s163.com"));
    7. // ...
    8. }
    9. // 用户信息的增删改查方法
    10. // ...
    11. }
    12. public class User {
    13. private int id;
    14. private String name;
    15. private int age;
    16. private String tel;
    17. private String email;
    18. public User() {}
    19. public User(int id, String name, int age, String tel, String email) {
    20. this.id = id;
    21. this.name = name;
    22. this.age = age;
    23. this.tel = tel;
    24. this.email = email;
    25. }
    26. // Getter and Setter
    27. // ...
    28. }