みなさんおはようございます、
GWT フレームワークを使用して会社の ERP を開発しており、Java Mail API を使用して未読メールの数を取得します。私はこれを行うことができますが、問題は、SHA-512 ハッシュ化されたパスワードをデータベースに保存し、クリア パスワードを Java Mail API に渡さず、ハッシュ化されたパスワードだけを渡して、ネットワーク上でクリア パスワードを送信しないようにすることです。
このコードを使用して、未読メールの数を取得します。
private static int getNumberOfUnreadMails() {
int numberOfUnreadMails = 0;
Properties properties = new Properties();
properties.put("mail.imap.host", "myserver.com");
properties.put("mail.imap.user", "developper@myserver.com");
properties.put("mail.imap.socketFactory", 143);
properties.put("mail.imap.socketFactory.class", "java.net.ssl.SSLSocketFactory");
properties.put("mail.imap.port", 143);
Session session = Session.getDefaultInstance(properties, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("developper@myserver.com", "mypassword");
}
});
Store store;
try {
store = session.getStore("imap");
store.connect();
Folder folder = store.getFolder("Inbox");
numberOfUnreadMails = folder.getUnreadMessageCount();
} catch (Exception e) {
e.printStackTrace();
}
return numberOfUnreadMails;
}
別のハッシュ アルゴリズムを使用することもできます。私の問題の解決策を知っている場合は、事前に感謝します。
PS: 英語が下手で申し訳ありません。私はフランス人です。