问题描述
我有一个Spring bean,它使用用户名/密码作为其构造函数参数的一部分:
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>
我可以仅使用jasypt加密配置文件中的这些参数吗? Bean"org.apache.commons.httpclient.UsernamePasswordCredentials"将使用纯文本值实例化,但对用户而言,它们将显示为已加密.
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.
我可以使用以下答案使用核心Java库代码:在配置文件中加密密码? 并从Java内手动创建bean mysender,然后在实例化org.apache.commons.httpclient.UsernamePasswordCredentials之前先描fields字段
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 ?
推荐答案
是的,jasypt可以处理.见
Yes, jasypt can handle this. See
http://www.algowise.com/2013/04/encrypting-passwords-using-jasypt-in.html
这篇关于在Spring配置文件中加密密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!