类型: 安全缺陷
程序中采用硬编码方式处理身份证号码,一方面会降低系统安全性,另一方面不易于程序维护。
public class EmployeeDAO {private static Map<Integer, Employee> emps = new LinkedHashMap<Integer, Employee>();//...static {emps.put(1001, new Employee("330781198509075478", "韩信", 39, "18345322345", "6228482410842133810"));emps.put(1002, new Employee("330781198509075419", "张良", 40, "18987844774", "6221386102180111738"));emps.put(1003, new Employee("33078119850907853X", "萧何", 55, "13944837458", "6222801842821035763"));// ...}// 雇员信息的增删改查方法// ...}public class Employee {private String id; // 记录雇员的身份证号码private String name;private int age;private String tel; // 记录雇员的电话号码private String bankId; // 记录雇员的银行卡卡号public Employee() {}public Employee(String id, String name, int age, String tel, String bankId) {this.id = id;this.name = name;this.age = age;this.tel = tel;this.bankId = bankId;}// Getter and Setter// ...}
