使用加密密码连接到gmail(使用imap和javamail) [英] Connect to gmail (using imap and javamail) with encrypted password

查看:156
本文介绍了使用加密密码连接到gmail(使用imap和javamail)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用简单的Java程序(

I'm trying to connect to gmail using a simple java program (like this one). But my question is:

出于安全原因,当然可以使用加密密码而不是真实密码来执行此操作!!类似于我们在java-Oracle db中的工作方式?

Is there a way to do this with encrypted password and not the real password, for security reasons of course!! something like how we do in java-Oracle db ?

推荐答案

默认情况下,用于IMAP的唯一身份验证机制是

By default, the only authentication mechanism for IMAP is the LOGIN command, which takes an unencrypted username and password. You can add an encryption layer on top of it, either by connecting via IMAPs or starting a TLS layer via the STARTTLS command, but it still requires the client to know the cleartext password.

服务器还可以选择提供通过 AUTHENTICATE命令调用的SASL身份验证方法.服务器在响应CAPABILITY命令时公布其支持的SASL机制.例如,如果服务器包含功能"AUTH=PLAIN",则客户端可以通过AUTHENTICATE PLAIN IMAP命令使用PLAIN SASL身份验证方法.

A server can optionally also provide SASL authentication methods invokable via the AUTHENTICATE command. The server advertises which SASL mechanisms it supports in its response to the CAPABILITY command. For instance, if the server includes the capability "AUTH=PLAIN", the client can use the PLAIN SASL authentication method via the AUTHENTICATE PLAIN IMAP command.

Gmail仅支持一种SASL身份验证机制,XOAUTH:

Gmail supports only one SASL authentication mechanism, XOAUTH:

C: 1 capability
S: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA XLIST CHILDREN XYZZY
      SASL-IR AUTH=XOAUTH
S: 1 OK Thats all she wrote! dv32if2169247ibb.17

XOAUTH是使用OAuth的非标准SASL身份验证机制. (前导X表示未标准化.)Google已发布定义XOAUTH SASL机制.他们还提供了一个 google-mail-xoauth-tools包,其中包含示例代码,展示了如何通过XOAUTH在Gmail中使用JavaMail.

XOAUTH is a nonstandard SASL authentication mechanism using OAuth. (The leading 'X' means it's not standardized.) Google has published a document defining the XOAUTH SASL mechanism. They've also provided a google-mail-xoauth-tools package, which includes sample code showing how to use JavaMail with Gmail via XOAUTH.

这篇关于使用加密密码连接到gmail(使用imap和javamail)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆