On Thursday 18 May 2006 21:10, Achim Grolms wrote:
> How can that "use the sasl-objetcs interface only" be done with
> Net::POP3?
I have no GSSAPI enabeled POP3 Server to test, but my idea is to add
a authsasl() method to Net::POP3 that accepts the Authen::SASL object.
Does that work? I have no chance to test it myself at the moment:
#------usage example--------------
use Authen::SASL 2.10;
use Net::POP3;
my $sasl = Authen::SASL->new( mechanism => 'GSSAPI' );
$pop = Net::POP3->new('pop3host');
$pop->authsasl($sasl);
my $msgnums = $pop->list; # hashref of msgnum => size
foreach my $msgnum (keys %$msgnums) {
my $msg = $pop->get($msgnum);
print @$msg;
}
$pop->quit;
#------end of usage example--------------
#--------changes to Net::POP3--------------------
# add this to Net::POP3 pm-file
#
sub authsasl {
my ($self, $sasl) = @_;
eval {
require MIME::Base64;
} or $self->set_status(500,["Need MIME::Base64 todo auth"]), return 0;
my $client = $sasl->client_new('pop3',${*$self}{'net_pop3_host'},0);
my $str = $client->client_start;
my @cmd = ("AUTH", $client->mechanism);
my $code;
push @cmd, MIME::Base64::encode_base64($str,'')
if defined $str and length $str;
while (($code = $self->command(@cmd)->response()) == CMD_MORE) {
@cmd = (MIME::Base64::encode_base64(
$client->client_step(
MIME::Base64::decode_base64(
($self->message)[0]
)
), ''
));
}
$code == CMD_OK;
}
#--------end of changes to Net::POP3--------------------