How to store an encrypted password in a DataSource resource definition without creating my own DataSourceFactory?

I have my own DataSourceFactory, where I decrypt my password as follows.

<Resource name="jdbc/mydb"
              auth="Container"
              type="javax.sql.DataSource"
              factory="mypackage.EncryptedDataSourceFactory"
              username="user"
              password="encryptedPassword"
              driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@ip:port:DB" 
              maxWaitMillis="1000"
              removeAbandoned="true"
              maxTotal="30"
              maxIdle="10"
              removeAbandonedTimeout="60"
              logAbandoned="false" />

I want to do the same without my class EncryptedDataSourceFactory, and is this possible? If so, how can I do this? I want to write like this

<Resource name="jdbc/mydb"
              auth="Container"
              type="javax.sql.DataSource"
              factory="org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory"
              username="user"
              password="encryptedPassword"
              driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@ip:port:DB" 
              maxWaitMillis="1000"
              removeAbandoned="true"
              maxTotal="30"
              maxIdle="10"
              removeAbandonedTimeout="60"
              logAbandoned="false" />

My tomcat version is 8.5.27

+4
source share

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


All Articles