diff --git a/framework/base/src/base/org/ofbiz/base/crypto/HashCrypt.java b/framework/base/src/base/org/ofbiz/base/crypto/HashCrypt.java index 8b19b1db76..c2518d64b7 100644 --- a/framework/base/src/base/org/ofbiz/base/crypto/HashCrypt.java +++ b/framework/base/src/base/org/ofbiz/base/crypto/HashCrypt.java @@ -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; } diff --git a/framework/common/src/org/ofbiz/common/login/LoginServices.java b/framework/common/src/org/ofbiz/common/login/LoginServices.java index 6eef28c23d..d35f035594 100644 --- a/framework/common/src/org/ofbiz/common/login/LoginServices.java +++ b/framework/common/src/org/ofbiz/common/login/LoginServices.java @@ -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);