我在属性文件中有一个密码,我想用任何双向加密加密.
password = 123456
我在spring-security xml中使用它进行活动目录身份验证.那个时候密码应该被解密.有人能指点我怎么做吗?
我是春天的新手,我不确定在这里采取什么路线.我使用了Jasypt但是我得到了LDAP authenticaton错误52,这意味着密码不正确.我假设解密没有正确发生.
我正在使用春天4.
解决方法:
看看here.主要步骤是:
>在spring上下文xml文件中定义名称空间:
的xmlns:加密= “http://www.jasypt.org/schema/encryption”
>定义加密器:
< encryption:strong-password-encryptor id =“passwordEncryptor”/>
>而不是您的上下文:property-placeholder标记,使用:
< encryption:encryptable-property-placeholder encryptor =“passwordEncryptor”location =“classpath:application.properties”/>
>现在,您可以使用加密的属性,如下所示,加密属性占位符将确保它们被解密.请注意,您需要使用与使用定义的编码器相同的alghorithm(和相同的配置)来加密属性(密码).
密码= ENC(G6N718UuyPE5bHyWKyuLQSm02auQPUtm)
标签:java,authentication,spring,encryption
来源: https://codeday.me/bug/20190628/1315492.html