Hi guys, I'm new to Spring (like 2 days new) and I'm working on a project for work and could use a little help. I'll try to explain it the best I can. Here's a Spring bean that I have:
As you can see, the password is stored in plain text in the .xml file. We're not huge fans of this. I know of several ways to work around that, but most are limited because the class for the bean (com.sybase...) isn't editable by us. So what we really want is a way to store an encrypted password in plain text in the password property, then have one of our custom classes decrypt it before connecting to the database.Code:<bean id="sybaseSQADataSource" class=" com.sybase.jdbc4.jdbc.SybDataSource" > <property name="networkProtocol" value="Tds" /> <property name="serverName" value="localhost" /> <property name="portNumber" value="2635" /> <property name="user" value="username" /> <property name="password" value="password" /> </bean>
I actually came close to a solution, which I found here. The problem is that, again, I can't modify that class, so I can't change the password field from being a string to being a custom field that has to be decrypted. One way around that would be to create a PropertyEditor for the String class which would scan all Strings and decrypt the ones that need it. But I don't know if that can be done.
Basically I need to store an encrypted (our own encryption method) password in the XML file and have it decrypted before the connection. Is this at all possible, or is it a lost cause?
Thanks in advance for your help.
P.S. - I hope this is in the right section. :/
EDIT: Should probably say that I'm using Spring 3.1 and Java 7.


Reply With Quote