Reverted fix from Hans that effectively disabled the method to remove the hash type prefix, and fixed the userLogin service code to and fixed the userLogin service code to remove the prefix from the db currentPassword value, which was missing and was causing the problem

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@656515 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David E. Jones
2008-05-15 06:10:50 +00:00
parent b2dd364e62
commit 050bbde29a
2 changed files with 5 additions and 4 deletions
@@ -81,7 +81,7 @@ public class HashCrypt {
}
public static String removeHashTypePrefix(String hashString) {
if (UtilValidate.isNotEmpty(hashString) || hashString.charAt(0) != '{') {
if (UtilValidate.isEmpty(hashString) || hashString.charAt(0) != '{') {
return hashString;
}
@@ -115,6 +115,7 @@ public class LoginServices {
String currentPassword = userLogin.getString("currentPassword");
if (useEncryption && currentPassword != null && currentPassword.startsWith("{")) {
// get encode according to the type in the database
String dbHashType = HashCrypt.getHashTypeFromPrefix(currentPassword);
if (dbHashType != null) {
encodedPasswordUsingDbHashType = HashCrypt.getDigestHash(password, dbHashType);
@@ -162,9 +163,9 @@ public class LoginServices {
// if the password.accept.encrypted.and.plain property in security is set to true allow plain or encrypted passwords
// if this is a system account don't bother checking the passwords
if ((userLogin.get("currentPassword") != null &&
(HashCrypt.removeHashTypePrefix(encodedPassword).equals(userLogin.getString("currentPassword")) ||
HashCrypt.removeHashTypePrefix(encodedPasswordOldFunnyHexEncode).equals(userLogin.getString("currentPassword")) ||
HashCrypt.removeHashTypePrefix(encodedPasswordUsingDbHashType).equals(userLogin.getString("currentPassword")) ||
(HashCrypt.removeHashTypePrefix(encodedPassword).equals(HashCrypt.removeHashTypePrefix(currentPassword)) ||
HashCrypt.removeHashTypePrefix(encodedPasswordOldFunnyHexEncode).equals(HashCrypt.removeHashTypePrefix(currentPassword)) ||
HashCrypt.removeHashTypePrefix(encodedPasswordUsingDbHashType).equals(HashCrypt.removeHashTypePrefix(currentPassword)) ||
("true".equals(UtilProperties.getPropertyValue("security.properties", "password.accept.encrypted.and.plain")) && password.equals(userLogin.getString("currentPassword")))))) {
Debug.logVerbose("[LoginServices.userLogin] : Password Matched", module);