将加密的属性传递给spring context [英] Passing encrypted properties to spring context

查看:179
本文介绍了将加密的属性传递给spring context的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有看过这个,但我想知道有人遇到过。拥有访问数据库的Web服务器。我想传递加密的数据库密码,并在设置数据源之前对其进行弹簧上下文解密。我知道春天的安全可以做一些像在网络服务器中使用盐文件等。



这里的挑战是我不想给清除用户,密码,网址到Web服务器团队。只是一个加密的密码,并在使用之前弹簧解密。



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



谢谢

解决方案

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

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

请注意,数据库密码已加密(实际上,任何其他属性也可以加密,与数据库配置是否相关)。



更多信息:



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


I never seen this but I wondering if somebody has come across. Having a web server which access a database. I want to pass the database password encrypted and have spring context decrypting it before setting the datasource. I know the spring security can do some of this like using a salt file in the web server, etc.

The challenge here is that I don't want to give a clear user,password,url to the web server team. Just an encrypted password and have spring decrypted before using it.

Is there something like this already? I know I could code something but is it already done?

Thanks

解决方案

By using an org.jasypt.properties.EncryptableProperties object, an application would be able to correctly read and use a .properties file like this:

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

Note that the database password is encrypted (in fact, any other property could also be encrypted, be it related with database configuration or not).

More information :

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

这篇关于将加密的属性传递给spring context的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆