Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the database password be encrypted in database-conf.xml? #64

Closed
tggagne opened this issue Apr 15, 2015 · 9 comments
Closed

Can the database password be encrypted in database-conf.xml? #64

tggagne opened this issue Apr 15, 2015 · 9 comments

Comments

@tggagne
Copy link
Contributor

tggagne commented Apr 15, 2015

I want to push my database-conf.xml file to a git repository, but am uncomfortable doing so with my password in the clear.

I haven't read in the documentation that DB passwords can be encrypted like the SFDC passwords can.

Does anyone know?

@tggagne
Copy link
Contributor Author

tggagne commented Apr 15, 2015

Apparently, the same "encrypt" command used for obscuring passwords in config.properties works for database-conf.xml, too.

@tggagne tggagne closed this as completed Apr 15, 2015
@tggagne
Copy link
Contributor Author

tggagne commented Apr 15, 2015

I should re-open this. The encrypted password seems to work for postgres, but does not work for SqlServer. I have yet to try it with Oracle. I begin to wonder if the fact it worked with Postgres was an accident or some other environmental issue.

@tggagne tggagne reopened this Apr 15, 2015
@diracz
Copy link
Contributor

diracz commented Apr 15, 2015

I think what you might look into: http://stackoverflow.com/questions/12834604/using-encrypted-password-for-the-datasource-used-in-spring-applicationcontext-xm

DatabaeReader/Writer uses org.apache.commons.dbcp.BasicDataSource, which you can override to have getPassword/setPassword decrypt/encrypt password.

Hope that helps.

@tggagne
Copy link
Contributor Author

tggagne commented Apr 16, 2015

I think it does...

So, if I created a subclass of org.apache.commons.dbcp.BasicDataSource I would have to specify its name in the database-conf.xml's bean for my DB connection?

If the subclass was named ObscuredPasswordDataSource the bean would look like..

<bean id="mypostgres" class="org.apache.commons.dbcp.ObscuredPasswordDataSource" .. >
    ...
    <property name="password" value="some encrypted value" />
</bean>

@tggagne
Copy link
Contributor Author

tggagne commented Apr 16, 2015

Not being a Maven expert... how can I rebuild dataloader from the command line and skip the step where it tries to "install" it on my mac?

@tggagne
Copy link
Contributor Author

tggagne commented Apr 16, 2015

diracz, I followed the advice from that stackoverflow link and created a new class, DataSource, that does the simple base64 decoding of the password.

While this obscures the password it doesn't obscure as well as dataloader's encryption/decryption of the sfdc.password.

I would prefer to use that approach, but hacking the Config class doesn't quite seem the right approach.

Do you know how I might get some help or clues if there's a better way to use Config's encryption?

The code has been committed to my repository here.

tggagne@e0562ab

@tggagne
Copy link
Contributor Author

tggagne commented Apr 16, 2015

I hacked in the UncryptUtil stuff, so the password may be decrypted. To be /totally/ compatible with Config's use of encryption, it needs to use the keyfile -- which it doesn't yet.

As it is, a password encrypted with "encrypt -e password" should be used. And the bean's classname should be "com.salesforce.dataloader.dao.database.DataSource".

It could use some improved exception handling, but I'm a little out of my element inside Java.

The latest commit is below. I don't know if it's pull request. I have a few people I need to share the jar with--because none of us wants to push a configuration file to git with our passwords in the clear.

tggagne@b9e82f6

@tggagne
Copy link
Contributor Author

tggagne commented Apr 17, 2015

Is there a way to reference the ProcessRunner instance from other classes?

The ProcessRunner has the current config, which means it has already processed the key file and has an initialized EncryptionUtil instance (config.encrypter).

Rather than initializing my own inside DataSource without the benefit of the keyfile, it would be valuable to just use the already-initialized one.

@tggagne
Copy link
Contributor Author

tggagne commented Apr 19, 2015

For our next trick, we should get the keyfile working. Until then, let's call this closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants