0

How to encrypt metadata password in tomcat server.xml file?

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Generating the password

    Tomcat does not support Datasource password encryption in the server.xml file.com.incorta.tools.tomcat.DataSourceFactory is a custom datasource factory that supports encrypted passwords. You will use the class main method to encrypt the password. It will print the encoded password that you should use in the data source definition. Assuming that you have the classpath properly configured, here's an example:

    java -cp encryptedDS.jar com.incorta.tools.tomcat.DataSourceFactory
    
    Enter password:
    
    Confirm password:
    
    
    Encrypted Password: m1rwxCXxhW7p87U9AWe8yg==
    

    Using the generated password in Tomcat

    In Tomcat server.xml file, find the JDBC Datasource definition (i.e. Resource tag). Here's a sample datasource definition:

         <Resource auth="Container" name="jdbc/incortaDB" type="javax.sql.DataSource"
         factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" testOnBorrow="true"
         initialSize="10" maxActive="500" minIdle="10" validationQuery="select 1"
         driverClassName="com.mysql.jdbc.Driver" username="root" password="passw0rd"
         url="jdbc:mysql://localhost:3306/incorta_dev?useUnicode=yes&amp;characterEncoding=UTF-8" />
    

    To use the encrypted password, you need to do the following:

    • Add (or change if exists) the data source factory to com.incorta.tools.tomcat.DataSourceFactory. -
    • Update the password to be the encrypted one -from the previous step.-

    Here's an update data source definition:

         <Resource auth="Container" name="jdbc/incortaDB" type="javax.sql.DataSource"
         factory="com.incorta.tools.tomcat.DataSourceFactory" testOnBorrow="true"
         initialSize="10" maxActive="500" minIdle="10" validationQuery="select 1"
         driverClassName="com.mysql.jdbc.Driver" username="root" password="m1rwxCXxhW7p87U9AWe8yg=="
         url="jdbc:mysql://localhost:3306/incorta_dev?useUnicode=yes&amp;characterEncoding=UTF-8" /> 
    Reply Like
  • getting class not found error ,can you helppppp

    Reply Like
  • You can try this.

    cd IncortaAnalytics/cmc
     java -cp "./webapps/cmc/WEB-INF/lib/encryptedDS.jar:./webapps/cmc/WEB-INF/lib/*" com.incorta.tools.tomcat.DataSourceFactory 
    Reply Like
Like Follow
  • Status Answered
  • 2 mths agoLast active
  • 3Replies
  • 667Views
  • 3 Following