我有两个类“用户配置文件”和“指纹配置文件”,它们扩展了一个抽象类“配置文件”。
轮廓:
/**
* Template for User profiles or Fingerprint profiles
*/
public abstract class Profile {
/**
* Profile Name
*/
private String name;
/**
* Profile id
*/
private int id;
/**
* Set the name of this profile
* @param name
*/
public void setProfileName(String name) {
this.name = name;
}
/**
* Set the id of this profile
* @param name
*/
public void setIdNumber(int id) {
this.id = id;
}
/**
* Get the name of this profile
*/
public String getProfileName() {
return name;
}
/**
* Get the id of this profile
*/
public int getIdNumber() {
return id;
}
}
我的下一个类是 UserProfile
public class UserProfile extends Profile {
/**
* Users password
*/
private char[] password;
/**
* Set User password
* @param password
*/
public void setPassword(char[] password){
this.password = password;
}
/**
* Get User password
*/
public char[] getPassword(){
return password;
}
}
仅仅看这个类似乎很狡猾,能够像这样检索密码似乎是完全错误的(即使 get 方法是 private )。
在制作我的 FingerPrintProfile 类以及包含本质上也需要安全的“FingerprintData”对象时,似乎我将面临同样的问题。
有没有人知道一种安全的方法,或者最好是人们用来解决这种情况的模式?
谢谢 !
奖金问题
我创建了抽象类来为两种类型的配置文件提供模板,指纹数据和文本密码之间似乎有一个共同点。但是,不可能创建一个抽象字段“密码”,它可能是一个字符数组或一个 FingerprintData 对象。有任何想法吗??
最佳答案
关于java - 在类中保存密码的最理想方式 - Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13955515/