获取错误org.jasypt.exceptions.EncryptionOperationNotPossibleException

时间:2012-05-18 16:28:32

标签: hibernate struts

我正在使用jasypt 1.9.0用于db密码加密

jdbc.properties

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:XE
jdbc.username=aosmaster
jdbc.password=ENC(aiQkX+5+EicZU3x0/ZWeW9ExV+OW/yc+)

的applicationContext.xml

<bean class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
        <constructor-arg>
            <bean class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
                <property name="config">
                    <bean class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
                        <property name="algorithm" value="PBEWithMD5AndDES" />
                        <property name="passwordSysPropertyName" value="APP_ENCRYPTION_PASSWORD" />
                    </bean>
                </property>
            </bean>
        </constructor-arg>
        <property name="locations">
            <list>
                <value>classpath:/META-INF/props/db/jdbc.properties</value>
            </list>
        </property>
    </bean>

我添加到JBOSS run.bat

rem JVM memory allocation pool parameters. Modify as appropriate.
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -DAPP_ENCRYPTION_PASSWORD=aiQkX+5+EicZU3x0/ZWeW9ExV+OW/yc+

我收到错误。我无法找到最近3天的解决方案请帮帮我

org.jasypt.exceptions.EncryptionOperationNotPossibleException
2012-05-19 09:49:01,562 ERROR [STDERR]  at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)

最后我解决了这个问题:

首先,我们需要决定加密算法和密码。然后我们将使用Jasypt附带的命令行工具加密我们的数据库密码: c:\ jasypt 9.0.1 \ bin input =“mypassword”algorithm = PBEWithMD5AndDES password = MY_APPS_PWD

kh1AU2abA4JpwlW1eqixhUzI0PerdI0Z

粘贴到jdbc属性ENC(kh1AU2abA4JpwlW1eqixhUzI0PerdI0Z)

从上面拿走的重要一点是配置。属性passwordSysPropertyName告诉Jasypt它应该从名为APP_ENCRYPTION_PASSWORD的系统属性加载加密密码。 现在,如上所述,我将一个运行时属性添加到我的容器中,以便将此密码作为系统属性注入运行时环境:

我将run.bat添加到jboss

设置JAVA_OPTS =%JAVA_OPTS%-DAPP_ENCRYPTION_PASSWORD = MY_APPS_PWD

run.bat文件。

干杯!

0 个答案:

没有答案