Re: Supplying a JDBC password at run-time.

2019-12-04 Thread Richard Monson-Haefel
Great work, Jon! Glad you found a solution that works for you. On Tue, Dec 3, 2019 at 3:43 PM randygalbraith wrote: > Hi Jon, > > You make mention of this, but probably good to emphasize this point... The > code I posted is proof-of-concept work and it contains a rather glaring > security

Re: Supplying a JDBC password at run-time.

2019-12-03 Thread Jonathan Gallimore
Glad you have it working. The other approach you could take is to implement a custom password cipher: https://tomee.apache.org/latest/examples/datasource-ciphered-password.html or a properties provider: https://tomee.apache.org/latest/docs/admin/configuration/resources.html which you might be able

Re: Supplying a JDBC password at run-time.

2019-12-03 Thread randygalbraith
Hi Dmitry & Richard, Thank you for all your help! Here is my anonymized source for what worked :-) DataSourceFactory.java: package path1.path2; import java.io.IOException; import path3.path4.FooStore; public class DataSourceFactory { public Object create() { String password =

Re: Supplying a JDBC password at run-time.

2019-12-03 Thread Richard Monson-Haefel
Hi, I probably was not clear. There is a text file under tomee/conf called system.properties. You can simply write the property as follows DB.Password = password It just takes keys and values and then adds them to the system properties on start up. It contains a lot of commented out examples

Re: Supplying a JDBC password at run-time.

2019-12-03 Thread randygalbraith
Hi Richard, I was reading that document (among others). In the "Defining Resources" section it shows this code: p.setProperty("DB.Password", "password"); This is close to what I need to work. Alas, the example does not show how the variable "p" is created. Thus I was on the hunt to understand

Re: Supplying a JDBC password at run-time.

2019-12-03 Thread Richard Monson-Haefel
Hi Randy, I think you'll find this documentation very helpful is setting up a factory for your resource http://tomee.apache.org/application-resources.html Also, system properties override resource.xml and tomee.xml. There is a system.properties files under the conf directory I believe that also

RE: Supplying a JDBC password at run-time.

2019-12-02 Thread randygalbraith
Hi Dimtry, I hope to work on this again tomorrow. The idea of creating a custom DataSourceFactory seems like the way to go. This approach does raise the question about where to store the elements other than the password. For example the UserName= will need to be variable on a per-environment

RE: Supplying a JDBC password at run-time.

2019-12-02 Thread Shultz, Dmitry
ss, definition, null, null, null, false); } } Cheers, Dmitry -Original Message- From: randygalbraith [mailto:regalbra...@aetna.com.INVALID] Sent: Monday, December 2, 2019 2:32 PM To: users@tomee.apache.org Subject: RE: Supplying a JDBC password at run-time. Hi Dmitry, I

RE: Supplying a JDBC password at run-time.

2019-12-02 Thread randygalbraith
Hi Dmitry, Interesting. I did not know ${} syntax within resources.xml would pull in values from the environment. Alas, that would not work in my case, since our Oracle password is not and cannot be an environment variable. Cheers, -Randy -- Sent from:

RE: Supplying a JDBC password at run-time.

2019-12-02 Thread Shultz, Dmitry
Hi Randy, I'm using TomEE substitution in tomee.xml for this, here is some example: JdbcDriver = org.postgresql.Driver JdbcUrl = ${SOME_DS_URL} UserName = ${SOME_DS_USER} Password = ${SOME_DS_PASSWORD} //all other data source config