Spring集成 - 是否可以在imap-idle-channel-adapter中提供加密密码?

时间:2012-12-19 10:41:29

标签: spring spring-integration

我使用以下配置来使用spring integration和imap来阅读电子邮件。

<mail:imap-idle-channel-adapter id="imapAdapter"
                              store-uri="imaps://username:password@mydomain:993/inbox"                                    
                              channel="recieveEmailChannel"
                              should-delete-messages="false"
                              auto-startup="true"
                              java-mail-properties="javaMailProperties" />

问题

此处用户名和密码是明文,但出于安全原因,我需要提供加密的或用户名和密码存储在属性文件中。有没有可用的选项吗?

感谢。

1 个答案:

答案 0 :(得分:1)

您可以使用Jasypt加密从*.properties文件加载的属性值:

 <mail:imap-idle-channel-adapter 
     store-uri="imaps://${username}:${password}@mydomain:993/inbox" ...                                 

此处提供了更多示例:http://www.jasypt.org/spring3.html

更新:它也适用于Spring 2.x:http://www.jasypt.org/spring2.html

相关问题