我正在尝试在 java 中重新定义用于 play 2 的 securesocial 插件的密码验证器和密码散列器,因为我的身份验证过程不起作用..(实际上一切似乎都是正确的,因为我无法使用哈希密码存储在我的数据库中)
我已经将 passwordValidator 扩展为文档解释它(http://securesocial.ws/guide/password-plugins.html)
公共类 BCryptPasswordHasher 扩展 BasePasswordHasher{
public PasswordInfo doHash(String plainPassword){
PasswordInfo pI = new PasswordInfo();
pI.password = BCrypt.hashpw(plainPassword, BCrypt.gensalt());
return pI;
}
public boolean doMatch(PasswordInfo passwordInfo, String suppliedPassword){
return BCrypt.checkpw(suppliedPassword, passwordInfo.password);
}
}
我收到此错误:
tools.BCryptPasswordHasher 不是抽象的,不会覆盖 securesocial.core.java.BasePasswordHasher 中的抽象方法 doMatch(securesocial.core.java.PasswordInfo,java.lang.String)
你知道我怎么能做到这一点吗?
预先感谢您的帮助
PS:BasePasswordHasher
公共抽象类 BasePasswordHasher 实现 PasswordHasher { protected Application application;
public BasePasswordHasher(Application application) {
this.application = application;
}
@Override
public securesocial.core.PasswordInfo hash(String plainPassword) {
return doHash(plainPassword).toScala();
}
@Override
public boolean matches(securesocial.core.PasswordInfo passwordInfo, String suppliedPassword) {
return doMatch(PasswordInfo.fromScala(passwordInfo), suppliedPassword);
}
/**
* Hashes a password
*
* @param plainPassword the password to hash
* @return a PasswordInfo containting the hashed password and optional salt
*/
abstract PasswordInfo doHash(String plainPassword);
/**
* Checks whether a supplied password matches the hashed one
*
* @param passwordInfo the password retrieved from the backing store (by means of UserService)
* @param suppliedPassword the password supplied by the user trying to log in
* @return true if the password matches, false otherwise.
*/
abstract boolean doMatch(PasswordInfo passwordInfo, String suppliedPassword);
}