问题
I have a Spring bean which uses a username/password as part of its constructor parameters :
<bean id="mysender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender">
<property name="c">
<bean class="org.apache.commons.httpclient.UsernamePasswordCredentials">
<constructor-arg value="plaintext"/>
<constructor-arg value="plaintext"/>
</bean>
</property>
</bean>
Can I use jasypt to encrypt these parameters from the configuration file only ? The bean "org.apache.commons.httpclient.UsernamePasswordCredentials" will be instantiated with plain text values but to the user they will appear encrypted.
I could use core java library code using this answer : Encrypt Password in Configuration Files? and manually create the bean mysender from within java, then depcript the fields before instantiating org.apache.commons.httpclient.UsernamePasswordCredentials
Or is there a tried method of I have not mentioned which will implement this ?
回答1:
Yes, jasypt can handle this. See
http://www.algowise.com/2013/04/encrypting-passwords-using-jasypt-in.html
来源:https://stackoverflow.com/questions/20149939/encrypting-a-password-within-a-spring-configuration-file