RE: GNU JavaMail CRAM-MD5 Support
"Jos Collin-ERS,HCLTech" <[email protected]> Tue, 5 Oct 2010 14:23:13 +0530
| Newsgroups | gmane.comp.java.classpath.extensions.javamail |
|---|---|
| Message-ID | <8DEDC34680D63646A30A754A2DC02B163855A7855B@CHN-HCLT-EVS07.HCLT.CORP.HCL.IN> |
> final String userName =3D ...;
> final String password =3D ...;
> Authenticator auth =3D new Authenticator() {
> protected PasswordAuthentication getPasswordAuthentication() {
> return new PasswordAuthentication(userName, password);
> }
> };
Yes, I have already done that in my code. So I will do the following and te=
st the code and see whether it authenticate with the SMTP server using CRAM=
-MD5.
props.put("mail.smtp.auth.mechanisms", "CRAM-MD5")
Thanks for your support,
Jos Collin
________________________________________
From: Chris Burdess [[email protected]]
Sent: Tuesday, October 05, 2010 2:09 PM
To: Jos Collin-ERS,HCLTech
Cc: [email protected]
Subject: Re: [Classpathx-javamail] GNU JavaMail CRAM-MD5 Support
Jos Collin-ERS,HCLTech wrote:
> Thanks Chris for the information.
>
> So you mean, I have to set the property mail.smtp.auth.mechanisms as prop=
s.put("mail.smtp.auth.mechanisms", "CRAM-MD5").
Yes.
> The following is my code where I set the properties. Also, do I have to d=
o anything additional, as the CRAM-MD5 authentication is different from PLA=
IN? How does it receive the challenge from the server and send the digest b=
ack?
>
> Thanks,
> Jos Collin
> -----------------------
>
>
> //Create a Properties object and set the properties
> Properties props =3D new Properties();
> props.put("mail.transport.protocol", "smtp");
> props.put("mail.smtp.host", SMTP_HOST_NAME);
> props.put("mail.smtp.port", SMTP_HOST_PORT);
> props.put("mail.smtp.auth", "true");
props.put("mail.smtp.auth.mechanisms", "CRAM-MD5");
> props.put("mail.smtp.ssl.enable", "true");
>
> //Authenticator can be used only by creating a child class
> Authenticator auth =3D new SMTPAuthenticator();
final String userName =3D ...;
final String password =3D ...;
Authenticator auth =3D new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
};
>
> // Create a session using the authenticator object
> Session mailSession =3D Session.getDefaultInstance(props, auth);
>
> Transport transport =3D mailSession.getTransport();
--
Chris Burdess