org.jasypt.exceptions.EncryptionOperationNotPossibleException [英] org.jasypt.exceptions.EncryptionOperationNotPossibleException
问题描述
我使用 Jasypt-1.9.0 和 Spring 3.1 和 Hibernate 4.0.1 。我在我的应用程序中要求连接到密码(root)以加密形式存储在应用程序中的属性文件中的数据库。
我在网上查找并找到以下链接的方式:
我已经为我的要求完成了以下步骤和配置:
- 在构建路径中添加了 jasypt-1.9.0 和 jasypt-hibernate4 -1.9.0。
- 在我的 dispatcher-servlet 文件中添加了以下内容:
- 在我的 dispatcher-servlet 文件中添加了以下内容:
< bean id =propertyConfigurer
class =org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer>< constructor-arg ref =configurationEncryptor/>
< property name =locations>
<列表>
<值GT;类路径:database.properties< /值GT;
< /列表>
< /性>
< /豆腐>
< bean id =configurationEncryptor
class =org.jasypt.encryption.pbe.StandardPBEStringEncryptor>
< property name =configref =environmentVariablesConfiguration/>
< /豆腐>
< bean id =environmentVariablesConfiguration
class =org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig>
< property name =algorithmvalue =PBEWithMD5AndDES/>
< property name =passwordEnvNamevalue =APP_ENCRYPTION_PASSWORD/>
< / bean>
- 使用 CLI工具的Jasypt 1.9.0,我已经在下面生成了密码
(CLI的快照)
< img src =https://i.stack.imgur.com/RWahL.pngalt =在这里输入图片描述>
- 添加一个新的环境变量作为 APP_ENCRYPTION_PASSWORD 作为根
- 在 database.properties文件中添加了加密密码
db.driverClassName = com.mysql.jdbc.Driver
db.url = jdbc:mysql:// localhost:3306 / db1
db.username = root
db.password = ENC(bmfeQmgP / hJrh + mj6NANKA ==)
$ b现在如果我运行我的应用程序,出现以下异常:org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt( StandardPBEByteEncryptor.java:981)
在org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
解决方案这个问题很可能过时了,未来的寻求者......
EncryptionOperationNotPossibleException是jasypt引发的一般异常,用于掩盖其他可能的异常。在以下情况下可能会发生此异常:
- 您的jdk没有安装JCE unlimited capabilities(最常见的情况)
- 在数据库中使用其他密码加密过的数据
- 在数据库中有一些数据未加密之前,您已将某些数据加密到某个字段
- jasypt由于数据奇怪的损坏而无法解密来自数据库的加密值
- 许多其他人,只需要进行调试以找出真正的原因..
I am using Jasypt-1.9.0 with Spring 3.1 and Hibernate 4.0.1. I have a requirement in my application to connect to database whose password(root) is stored in the encrypted form in the property file within the application.
I looked online and found the way with following links:
I have done following steps and configuration for my requirement:
- Added jasypt-1.9.0 and jasypt-hibernate4-1.9.0 in build path.
- Added following in my dispatcher-servlet file:
< bean id="propertyConfigurer" class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
< constructor-arg ref="configurationEncryptor" /> < property name="locations"> < list> < value>classpath:database.properties< /value> < /list> < /property> < /bean> < bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"> < property name="config" ref="environmentVariablesConfiguration" /> < /bean> < bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"> < property name="algorithm" value="PBEWithMD5AndDES" /> < property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" /> </bean>
- Using CLI tool of Jasypt 1.9.0, i have generated the password below(attached snapshot of CLI)
- Added a new Environment Varibale as APP_ENCRYPTION_PASSWORD with value as root
- Added the encrypted password in database.properties file
db.driverClassName=com.mysql.jdbc.Driver db.url=jdbc:mysql://localhost:3306/db1 db.username=root db.password=ENC(bmfeQmgP/hJrh+mj6NANKA==)
Now if i run my application, following exception appears:
org.jasypt.exceptions.EncryptionOperationNotPossibleException at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981) at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725) at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
解决方案The question is most probably out of date, but for future seekers... EncryptionOperationNotPossibleException is a general exception thrown by jasypt to mask other possible exceptions. This exception can occur when:
- your jdk does not have the JCE unlimited strenght installed (most common case)
- you had some data in the database that was encrypted before with other password
- you had some data in database that were not encrypted before and you added encryption to some field
- jasypt failed to decrypt the encrypted value from db because of some strange corruption of data
- many many others, you just need to debug to find out the real cause..
这篇关于org.jasypt.exceptions.EncryptionOperationNotPossibleException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!