I have a datasource in tomcat which has password that is encrypted using some algorithm and I want to decrypt the same when i establish connection with DB.
Following is my spring config code
<!--<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jdbc.jndiName}"/>
</bean>-->
<bean id="dataSource" class="my.app.util.EncryptedDataSource">
<property name="jndiName" value="${jdbc.jndiName}"/>
</bean>
The above bean is a custom one that extends the JndiObjectFactoryBean
public class EncryptedDataSource extends JndiObjectFactoryBean{ ... }
What should I do here to get the encryted password and set it back. I have my decrytion algorithm with me but I am not sure which super class method will fetch me the password that i can set back again.
Please suggest, i have search and tried a lot.
I figured it out, Instead of overriding the JndiBeanFacotry, I used the tomcat data source "factory" property, it allows you to have a custom resource factory class that gets called every time data source lookup is instantiated.
Below link specifies step by step configuration,
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
"Adding Custom Resource Factories" section emphasises how to write a simple custom resource factory.
Thanks.