From 050bbde29a72e2aabcfdb43abe68a3dbe6e2b689 Mon Sep 17 00:00:00 2001 From: "David E. Jones" Date: Thu, 15 May 2008 06:10:50 +0000 Subject: [PATCH] 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 --- .../base/src/base/org/ofbiz/base/crypto/HashCrypt.java | 2 +- .../common/src/org/ofbiz/common/login/LoginServices.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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);