[Schmitzm-commits] r1972 - trunk/schmitzm-core/src/main/java/de/schmitzm/lang

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu Apr 26 17:25:09 CEST 2012


Author: mojays
Date: 2012-04-26 17:25:09 +0200 (Thu, 26 Apr 2012)
New Revision: 1972

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java
Log:
ApplicationProps: avoid exceptions during value decryption (just log error)

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java	2012-04-26 10:08:15 UTC (rev 1971)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/ApplicationProps.java	2012-04-26 15:25:09 UTC (rev 1972)
@@ -282,9 +282,15 @@
     String encryptedValue = getString(key);
     if ( encryptedValue == null )
       return defaultValueDecrypted.length > 0 ? defaultValueDecrypted[0] : null;
-    byte[] encryptedBytes = CryptUtil.convertWritableStringToEncryptedBytes(encryptedValue);
-    String decryptedValue = CryptUtil.decryptString(encryptedBytes, getDecrytionCipher());
-    return decryptedValue;
+    try {
+      byte[] encryptedBytes = CryptUtil.convertWritableStringToEncryptedBytes(encryptedValue);
+      String decryptedValue = CryptUtil.decryptString(encryptedBytes, getDecrytionCipher());
+      return decryptedValue;
+    } catch (Exception err) {
+      LOGGER.error("Error decrypting value '"+encryptedValue+"' for key '"+key+"' (NULL value returned): "+err.getMessage());
+      LOGGER.debug(err.getMessage(),err);
+      return null;
+    }
   }
 
   public Character getChar(KEYS key, Character... defaultValue) {



More information about the Schmitzm-commits mailing list