1

我的代码需要连接到 IMAP 和 SMTP 服务器以定期发送和接收电子邮件,目前每 3 分钟左右一次。典型用户流程如下

  1. 登录
  2. 通过输入您的 IMAP 和 SMTP 详细信息(包括 emailId 和密码)来集成您的电子邮件。
  3. 转到数据

在后台,我运行一个石英调度程序,它定期从 IMAP 服务器中提取电子邮件。Web UI 和石英调度程序在不同的 VM 中运行,并在 REST 上相互通信。

在这种情况下,保护用户电子邮件凭据的好方法是什么?一种方法散列将无济于事,因为我再也不想向用户询问他的密码,但我需要提供凭据才能在 IMAP 上连接

4

2 回答 2

1

Of course, the best way to ensure a password is safe is having a "no return to the original", but that's out of the scope of this question :-)

Having said that, your best option is to encrypt the password on the application code side, using a Private Key that exists only on the server (but not deployed together with the app). You can take a look at Jasypt, which is a tool for encryption for Java. Also, you might want to consider splitting the passphrase for the key into two parts: one coming from some configuration file inside the properties file, and one coming from, perhaps, the database itself.

于 2012-07-16T11:51:57.687 回答
0

如果应用程序在客户端机器上运行,则使用用户选择的主密码对密码进行加密。这允许用户锁定应用程序。

如果应用程序在服务器上运行,请确保密码是通过 HTTPS 发送的,或者至少使用非对称公钥对其进行加密并在服务器上对其进行解密。

使用私钥存储使用 AES 或其他一些好的加密算法加密的密码,只是为了防止以纯文本形式存储它们。

于 2012-07-16T18:17:11.307 回答