[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNU Crypto] Using gnu-crypto-discuss to send emails via authorized
From: |
Øyvind Harboe |
Subject: |
Re: [GNU Crypto] Using gnu-crypto-discuss to send emails via authorized SMTP servers |
Date: |
Sat, 24 Jan 2004 11:52:27 +0100 |
lør, 24.01.2004 kl. 06.27 skrev Casey Marshall:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> >>>>> "Øyvind" == Øyvind Harboe <address@hidden> writes:
>
> Øyvind> The array contains {"LOGIN"}
>
> There you go; GNU Crypto doesn't implement this.
>
> I'm pretty sure that this is trivial to implement, so I may have a
> crack at it sometime soon.
Note that this is already implemented in the file below, it is just
commented out. Works fine on my rocket.
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/inetlib/source/gnu/inet/smtp/SMTPConnection.java?rev=HEAD&content-type=text/vnd.viewcvs-markup
/**
* LOGIN authentication mechanism.
* If this returns true, EHLO should be re-issued.
**/
public boolean authLogin(String username, String password)
throws IOException
{
send("AUTH LOGIN");
if (getResponse()==334)
{
String US_ASCII = "US-ASCII";
byte[] bytes = username.getBytes(US_ASCII);
String encoded = new String(BASE64.encode(bytes), US_ASCII);
send(encoded);
if (getResponse()==334)
{
bytes = password.getBytes(US_ASCII);
encoded = new String(BASE64.encode(bytes), US_ASCII);
send(encoded);
if (getResponse()==235)
return true;
}
}
return false;
}
/**
* PLAIN authentication mechanism.
**/
public boolean authPlain(String username, String password)
throws IOException
{
String plain = new StringBuffer(username)
.append('\u0000')
.append(username)
.append('\u0000')
.append(password)
.toString();
String US_ASCII = "US-ASCII";
byte[] bytes = plain.getBytes(US_ASCII);
String encoded = new String(BASE64.encode(bytes), US_ASCII);
String command = new StringBuffer("AUTH PLAIN ")
.append(encoded)
.toString();
send(command);
return (getResponse()==235);
}