2 Replies Latest reply on Sep 5, 2016 10:12 AM by gfuhr2016

    Encrypt datasource password

    gfuhr2016

      Hi,

       

      I'm working with JDBC datasources in Fuse 6.2.1. The datasource works fine with plain text password, but I cant figure out how to encrypt the password property.

       

      This is my datasource

      filename: FUSE_HOME/etc/org.ops4j.datasource-cmmDB.cfg

      Header 1

      osgi.jdbc.driver.name=oracle-pool

      osgi.jndi.service.name=jdbc/cmmConfigDS

       

       

      dataSourceName=cmmConfigDS

       

       

      pool.maxTotal=20

      pool.initialSize=10

      pool.maxWaitMillis=2000

       

       

      url=jdbc:oracle:thin:@cyberbank-qa-db:1521/DB12C

      user=CB_OMNICHANNEL_MANAGER_QA_FUSE

       

       

      password=OMNICHANNEL_QA_FUSE

       

      I've tried to generate an encrypted password from karaf console:

      JBossFuse:karaf@root> jasypt:encrypt MY_PLAIN_PASSWORD

      XXXX

       

      And then insert the result value in the cfg file as:

      password=ENC(XXXX)

       

      But I get the following exception:

      java.sql.SQLException: ORA-01017: invalid username/password; logon denied

       

      I'll appreciate if someone can help me

       

      Thanks in advance

      Regards

        • 1. Re: Encrypt datasource password
          grgrzybek

          Hello Gustavo

           

          Encrypting property in etc/*.cfg file is one thing. The other is to decrypt it where it's actually needed.

          If you're defining your datasource in blueprint XML file (and I guess you do), please read "Using encrypted property placeholders" section of http://karaf.apache.org/manual/latest-3.0.x/#_encryption_service. Even if it's about Karaf 3.0.x, it should work with Fuse as well.

           

          best regards

          Grzegorz Grzybek

          • 2. Re: Encrypt datasource password
            gfuhr2016

            Hi Grzegorz

             

            Thanks for your answer

             

            I'm not using blueprint, the datasource is used from java code (running in Karaf as a bundle). I think not possible to make a blueprint, because it's a legacy code (jar) integrated in a camel processor, and we need to use this code as black-box.

             

            The datasource is being accesed like a standard JNDI datasource from this legacy Java code:

             

            ....

            ....

            Context context = new InitialContext();

            dataSource = (DataSource)context.lookup("osgi:service/jdbc/cmmConfigDS");

            Connection connection = dataSource.getConnection();

            ....

            ....

             

             

             

            Thanks again

            Regards