gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 00:46:37 25 4
gpt4 key购买 nike

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

这里的挑战是我不想给网络服务器团队一个明确的用户、密码、url。只是一个加密的密码,并在使用前进行了 spring 解密。

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

谢谢

最佳答案

通过使用 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

关于spring - 将加密属性传递给 spring 上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8933067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com