将加密属性传递给spring上下文

Fab*_*bio 2 encryption spring properties system

我从来没有见过这个,但我想知道是否有人遇到过.拥有一个访问数据库的Web服务器.我想传递加密的数据库密码,并在设置数据源之前使用spring上下文对其进行解密.我知道spring安全性可以做一些事情,比如在Web服务器中使用salt文件等.

这里的挑战是我不想向Web服务器团队提供明确的用户,密码和URL.只是一个加密的密码,并在使用之前解密弹簧.

有没有这样的东西?我知道我可以编写代码,但它已经完成了吗?

谢谢

Abh*_*jan 5

通过使用org.jasypt.properties.EncryptableProperties对象,应用程序将能够正确读取和使用.properties文件,如下所示:

 datasource.driver=com.mysql.jdbc.Driver
 datasource.url=jdbc:mysql://localhost/reportsdb
 datasource.username=reportsUser
 datasource.password=ENC(G6N718UuyPE5bHyWKyuLQSm02auQPUtm)
Run Code Online (Sandbox Code Playgroud)

请注意,数据库密码是加密的(事实上,任何其他属性也可以加密,无论是否与数据库配置相关).

更多信息 :

http://www.jasypt.org/encrypting-configuration.html