svn commit: r1334215 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java

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

svn commit: r1334215 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java

doogie-3
Author: doogie
Date: Fri May  4 21:58:37 2012
New Revision: 1334215

URL: http://svn.apache.org/viewvc?rev=1334215&view=rev
Log:
FIX: When decrypting a value from the database, throw a useful exception
if the key couldn't be found; previously, an NPE would be thrown.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java?rev=1334215&r1=1334214&r2=1334215&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java Fri May  4 21:58:37 2012
@@ -108,6 +108,9 @@ public class EntityCrypto {
 
     protected Object doDecrypt(String keyName, byte[] encryptedBytes, boolean useOldFunnyKeyHash) throws GeneralException {
         SecretKey key = this.findKey(keyName, false);
+        if (key == null) {
+            throw new EntityCryptoException("key(" + keyName + ") not found in database");
+        }
         byte[] decryptedBytes = DesCrypt.decrypt(key, encryptedBytes);
         return UtilObject.getObject(decryptedBytes);
     }