1

I am trying to encrypt all the plain text keys and passwords in my J2EE application. I am trying to find out the best way to do so.

I understand that JASYPT has a very good library and utility for encrypting properties file,but doesn't seem to work in case of persistence.xml, which has all db usernames and passwords.

Following is the development stack:

  1. Spring MVC
  2. Spring
  3. Spring DATA JPA
  4. Hibernate
  5. MYSQL and POSTGRESS DB
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
Abhishek Ranjan
  • 911
  • 1
  • 14
  • 29

1 Answers1

2

Jasypt itself has a good solution for the above problem.

By using an org.jasypt.properties.EncryptableProperties object, an application would be able to correctly read and use a .properties file like this:

 datasource.driver=com.mysql.jdbc.Driver
 datasource.url=jdbc:mysql://localhost/reportsdb
 datasource.username=reportsUser
 datasource.password=ENC(G6N718UuyPE5bHyWKyuLQSm02auQPUtm)

Note that the database password is encrypted (in fact, any other property could also be encrypted, be it related with database configuration or not).

More information :

http://www.jasypt.org/encrypting-configuration.html

http://appfuse.org/display/APF/Database+Encryption+with+Jasypt-Hibernate

Abhishek Ranjan
  • 911
  • 1
  • 14
  • 29