tags:

views:

328

answers:

0

I am trying to use Jasypt to decrypt the password in my JDBC configuration file. I am using Java 6 with Spring 2.5.6. I am using the Spring examples here to guide me: http://www.jasypt.org/encrypting-configuration.html. I can't get this tool to decrypt the password. What am I doing wrong?

Here is what I executed to encrypt the password:

encrypt.bat input=P@$$w0rd password=abc algorithm=PBEWithMD5AndDES

Here the output from the command line tool provided with Jasypt:

----ENVIRONMENT-----------------

Runtime: Sun Microsystems Inc. Java HotSpot(TM) Client VM 14.0-b16



----ARGUMENTS-------------------

algorithm: PBEWithMD5AndDES
input: P@$$w0rd
password: abc



----OUTPUT----------------------

0dDsb6IWCPr5p5iC08gKUbyg5wPVKTSv

Here is my jdbc.properties file:

jdbc.url=jdbc:oracle:thin:@localhost:1521:db1
jdbc.username=dbuser
jdbc.password.grace.period=10
jdbc.password=ENC(0dDsb6IWCPr5p5iC08gKUbyg5wPVKTSv)

Here is my Spring configuration. I replaced the EnvironmentStringPBEConfig with the SimpleStringPBEConfig.

<bean id="pbeConfig" class="org.jasypt.encryption.pbe.config.SimpleStringPBEConfig">
  <property name="algorithm" value="PBEWithMD5AndDES" />
  <property name="password" value="abc" />
</bean>
                                                                   -->
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
  <property name="config" ref="pbeConfig" />
</bean>
                                                                 -->
<bean id="propertyConfigurer" class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
  <constructor-arg ref="configurationEncryptor" />
  <property name="locations">
    <list>
      <value>classpath:jdbc.properties</value>
      <value>classpath:webapp.properties</value>
    </list>
  </property>     
</bean>