svn commit: r1804880 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto: HashCrypt.java Main.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

svn commit: r1804880 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto: HashCrypt.java Main.java

jleroux-2
Author: jleroux
Date: Sun Aug 13 07:21:01 2017
New Revision: 1804880

URL: http://svn.apache.org/viewvc?rev=1804880&view=rev
Log:
No functional change.

This has been deprecated for 5+ years, time for action!

Uses digestHash() methods instead of getDigestHash(). Easily replaceable...

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/HashCrypt.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/Main.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/HashCrypt.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/HashCrypt.java?rev=1804880&r1=1804879&r2=1804880&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/HashCrypt.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/HashCrypt.java Sun Aug 13 07:21:01 2017
@@ -61,9 +61,9 @@ public class HashCrypt {
     }
 
     public static boolean comparePassword(String crypted, String defaultCrypt, String password) {
-     if (crypted.startsWith("{PBKDF2")) {
+        if (crypted.startsWith("{PBKDF2")) {
             return doComparePbkdf2(crypted, password);
-     } else if (crypted.startsWith("{")) {
+        } else if (crypted.startsWith("{")) {
             // FIXME: should have been getBytes("UTF-8") originally
             return doCompareTypePrefix(crypted, defaultCrypt, password.getBytes());
         } else if (crypted.startsWith("$")) {
@@ -119,7 +119,7 @@ public class HashCrypt {
      */
     @Deprecated
     public static String cryptPassword(String hashType, String salt, String password) {
-     if (hashType.startsWith("PBKDF2")) {
+        if (hashType.startsWith("PBKDF2")) {
             return password != null ? pbkdf2HashCrypt(hashType, salt, password) : null;
         }
         // FIXME: should have been getBytes("UTF-8") originally
@@ -127,14 +127,14 @@ public class HashCrypt {
     }
 
     public static String cryptUTF8(String hashType, String salt, String value) {
-     if (hashType.startsWith("PBKDF2")) {
+        if (hashType.startsWith("PBKDF2")) {
             return value != null ? pbkdf2HashCrypt(hashType, salt, value) : null;
         }
         return value != null ? cryptBytes(hashType, salt, value.getBytes(UtilIO.getUtf8())) : null;
     }
 
     public static String cryptValue(String hashType, String salt, String value) {
-     if (hashType.startsWith("PBKDF2")) {
+        if (hashType.startsWith("PBKDF2")) {
             return value != null ? pbkdf2HashCrypt(hashType, salt, value) : null;
         }
         return value != null ? cryptBytes(hashType, salt, value.getBytes()) : null;
@@ -205,7 +205,7 @@ public class HashCrypt {
     
     public static boolean doComparePbkdf2(String crypted, String password){
         try {
-         int typeEnd = crypted.indexOf("}");
+            int typeEnd = crypted.indexOf("}");
             String hashType = crypted.substring(1, typeEnd);
             String[] parts = crypted.split("\\$");
             int iterations = Integer.parseInt(parts[0].substring(typeEnd+1));
@@ -253,30 +253,6 @@ public class HashCrypt {
         }
     }
     
-    /**
-     * @deprecated use digestHash("SHA", null, str)
-     */
-    @Deprecated
-    public static String getDigestHash(String str) {
-        return digestHash("SHA", null, str);
-    }
-
-    /**
-     * @deprecated use digestHash(hashType, null, str))
-     */
-    @Deprecated
-    public static String getDigestHash(String str, String hashType) {
-        return digestHash(hashType, null, str);
-    }
-
-    /**
-     * @deprecated use digestHash(hashType, code, str);
-     */
-    @Deprecated
-    public static String getDigestHash(String str, String code, String hashType) {
-        return digestHash(hashType, code, str);
-    }
-
     public static String digestHash(String hashType, String code, String str) {
         if (str == null) return null;
         byte[] codeBytes;

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/Main.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/Main.java?rev=1804880&r1=1804879&r2=1804880&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/Main.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/crypto/Main.java Sun Aug 13 07:21:01 2017
@@ -26,8 +26,7 @@ public class Main {
         if (args[0].equals("-crypt")) {
             System.out.println(HashCrypt.cryptUTF8(args[1], null, args[2]));
         } else if (args[0].equals("-digest")) {
-            @SuppressWarnings("deprecation")
-            String digest = HashCrypt.getDigestHash(args[1]);
+            String digest = HashCrypt.digestHash("SHA", null, args[1]);
             System.out.println(digest);
         } else if (args[0].equals("-kek")) {
             AesCipherService cs = new AesCipherService();


Loading...