Author: doogie
Date: Fri May 4 21:58:37 2012
New Revision: 1334215
URL:
http://svn.apache.org/viewvc?rev=1334215&view=revLog:
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);
}