user2549122
user2549122

Reputation: 203

how to encrypt the data source password or data source in tomee

I want to store password in encrypted format so it is not readable for other user. my tomee.xml file contains

<Resource id="jdbc/myrootdb" type="DataSource">
         JdbcDriver com.mysql.jdbc.Driver    
         JdbcUrl jdbc:mysql://localhost:3306/test
         UserName root
         Password root    
         JtaManaged false   
          InitialSize 50 
         MaxActive 10
         MaxIdle 3 
</Resource>

I am using apache-tomee-jaxrs-1.5.2.

Upvotes: 4

Views: 1988

Answers (2)

user2822468
user2822468

Reputation: 11

  1. Download standalone version of OpenEJB
  2. Go to <OpenEJB install path>/bin and execute the command
    openejb cipher root
  3. Copy the generated encrypted password to your datasource resource definition
  4. Add the property DataSourceCreator to your datasource resource definition:
    DataSourceCreator dbcp
  5. Add the property PasswordCipher to your datasource resource definition:
    PasswordCipher Static3DES

For more information see: http://openejb.apache.org/datasource-password-encryption.html

Upvotes: 1

Santosh
Santosh

Reputation: 17903

The <Resource> in Tomcat has an attribute called factory. Here you specify a datasource factory. For encrypted password you need a custom datasource factory which reads the encrypted password. Here is what you need

  1. An encryption/decryption algorithm for password.
  2. Custom datasource factory

For more details, please check out this very detailed step by step example for achieving the same.

Upvotes: 2

Related Questions