How to encrypt data source password or data source in tomee

I want to save the password in an encrypted format so that it is not readable to another 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.

+4
source share
2 answers

<Resource> in Tomcat has a factory attribute. Here you specify the factory data source. For an encrypted password, you need a special factory data source that reads the encrypted password. Here is what you need

  • Encryption / decryption algorithm for password.
  • Factory custom data source

For more information, please see this very detailed step-by-step example to achieve the same.

+2
source
  • Download standalone version of OpenEJB
  • Go to <OpenEJB install path>/bin and run the command
    openejb cipher root
  • Copy the generated encrypted password to the data source resource definition
  • Add the DataSourceCreator property to the data source resource definition:
    DataSourceCreator dbcp
  • Add the PasswordCipher property to the data source resource definition:
    PasswordCipher Static3DES

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

0
source

Source: https://habr.com/ru/post/1495497/


All Articles