Jboss7.x 使用mysql5.5的jboss7.1/jbpm身份验证用户
我是jboss和jbpm的新手;我需要有关jboss7身份验证的帮助。我们面临“密码不正确/需要密码”错误 以下是jboss标准配置文件。*.xml的一部分Jboss7.x 使用mysql5.5的jboss7.1/jbpm身份验证用户,jboss7.x,jbpm,Jboss7.x,Jbpm,我是jboss和jbpm的新手;我需要有关jboss7身份验证的帮助。我们面临“密码不正确/需要密码”错误 以下是jboss标准配置文件。*.xml的一部分 <security-domain name="other" cache-type="default"> <authentication> <login-module code="org.jboss.security.auth.spi.DatabaseServerLogin
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/jbpmDS"/>
<module-option name="principalsQuery" value="select passwd from users where username=?"/>
<module-option name="rolesQuery" value="select userRoles 'Roles' from userroles where username=?"/>
<module-option name="hashAlgorithm" value="pbkdf2_sha256"/>
</login-module>
</authentication>
</security-domain>
我们有pbkdf2_sha256 encrypt的密码,但不知道如何在standalone*.xml中配置“pbkdf2_sha256”参数
我们使用django(v1.4 pbkdf2_sha256 encrypt)框架来管理用户
有人能帮我吗?根据来自的信息,这里是应该使用Django pbkdf2_sha256的实现(您需要使用JBoss注册此类,而不是原始的DatabaseServerLoginModule)。请记住,我没有测试它
public class PBKDF2WithSha256DatabaseServerLoginModule extends DatabaseServerLoginModule {
protected boolean validatePassword(String inputPassword, String expectedPassword) {
if(inputPassword == null || expectedPassword == null) {
return false;
}
String[] encodedPassword = expectedPassword.split("\\$");
int encodedIterations = Integer.parseInt(encodedPassword[1]);
byte[] encodedSalt = encodedPassword[2].getBytes(Charset.forName("UTF-8"));
String encodedHash = encodedPassword[3];
SecretKeyFactory f = null;
try {
f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Need a Java implementation with cryptography.");
}
KeySpec ks = new PBEKeySpec(inputPassword.toCharArray(), encodedSalt, encodedIterations, 256);
SecretKey s = null;
try {
s = f.generateSecret(ks);
} catch (InvalidKeySpecException e) {
// Encoded password is corrupt
return false;
}
if (encodedHash.equals(Base64.getEncoder().encodeToString(s.getEncoded()))) {
return true;
} else {
return false;
}
}
}
您可以发布详细的堆栈跟踪吗?据我所知,PASSWORD()函数是不可逆的(单向),DatabaseServerLoginModule希望密码以某种方式返回到原始格式。由于DatabaseServerLoginModule在将密码存储到数据库中时已经使用了哈希算法,您能否解释一下如何使用此数据库函数?谢谢!我认为这样做的基本原因是我不知道有关身份验证的程序。问题已更新,我希望得到您的建议。谢谢..也可能是的副本,请检查您的角色查询,我认为您在这里缺少一个逗号:“选择userRoles,'Roles'from userRoles where username=?”谢谢您。也许我知道我该怎么做。