Note that there are some explanatory texts on larger screens.

plurals
  1. POorg.jasypt.exceptions.EncryptionOperationNotPossibleException in Tomcat
    primarykey
    data
    text
    <p>I'm using the Jasypt encryption library to encrypt/decrypt some text. This code is embedded in a WAR file and deployed to a server.</p> <p>When running locally, and in unit tests, the encrypt/decrypt cycle works perfectly. I use Jetty to develop the application. The code works perfectly in that server. For some reason, deploying to Tomcat breaks it with the following exception:</p> <p>FYI, I have the strong encryption libraries installed in both my local and server environments and I'm using the latest 1.6 version (patch level 25).</p> <p><strong>org.jasypt.exceptions.EncryptionOperationNotPossibleException</strong></p> <p>The exception has no message.</p> <p>The code is fully symmetric. I pasted it here for examination. Here are the relevant bits:</p> <p>I found one <a href="http://old.nabble.com/At-my-wits-end---EncryptionOperationNotPossibleException-td18470285.html" rel="noreferrer">old Nabble post</a> where a user had a very similar problem. Code worked everywhere except inside Tomcat. No solution was given.</p> <p>Any insights would be most appreciated.</p> <p>**Update: ** Running in Tomcat on my local system, it appears to work. So there's something about my server. On the server, I'm using a 64-bit JVM on Windows Server 2008. I'm using a 32-bit JVM locally (due to my system being a bit older). I wonder if this has something to do with the issue.</p> <pre><code>public void initializeService() { binaryEncryptor = new BasicBinaryEncryptor(); binaryEncryptor.setPassword(keyBase64); } @Override public &lt;T extends Serializable&gt; String simpleEncrypt(T objectToEncrypt) throws EncryptionException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(objectToEncrypt); byte[] bytes = binaryEncryptor.encrypt(bos.toByteArray()); return new String(Base64.encodeBase64(bytes)); } catch (IOException e) { LOGGER.error("failed to encrypt String: " + e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (Exception e) { LOGGER.error("failed to encrypt String: " + e.getMessage()); throw new EncryptionException(e.getMessage(), e); } }; @SuppressWarnings("unchecked") @Override public &lt;T&gt; T simpleDecrypt(String objectToDecrypt) throws EncryptionException { try { byte[] bytes = Base64.decodeBase64(objectToDecrypt); byte[] decryptedBytes = binaryEncryptor.decrypt(bytes); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(decryptedBytes)); T object = (T)ois.readObject(); return object; } catch (IOException e) { LOGGER.error("failed to decrypt String: '" + objectToDecrypt + "', mesage = " + e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (Exception e) { LOGGER.error("failed to decrypt String: '" + objectToDecrypt + "', mesage = " + e.getMessage()); throw new EncryptionException(e.getMessage(), e); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload