Re: Mail::Box::IMAP4

Mark Overmeer <[email protected]> Tue, 21 Dec 2004 09:56:42 +0100
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Tom Allison ([email protected]) [041220 15:09]:
> ~ line 68:
> if(@types == 1 && $types[0] eq 'AUTO')
> -  {   @types = ('CRAM-MD5', ($ntml_installed ? 'NTLM' : ()), 'PLAIN');
> +  {
> +      undef @types;
> +      my @supported = qw(PLAIN CRAM-MD5); # Mail::IMAPClient supported
> +      foreach (grep {^AUTH=/o} $imap->capability)
> 
> Something like that?

Something in the right direction, but a bit on the wrong spot.  And
there are some more problems with that method.  I have a replacement
(untested!) which is made along the path you paved:

    if(@types == 1 && $types[0] eq 'AUTO')
    {   @types = ('CRAM-MD5', ($ntml_installed ? 'NTLM' : ()), 'PLAIN');
    }
                                                                                
    my @clientside;
    foreach my $auth (@types)
    {   push @clientside
           , ref $auth eq 'ARRAY' ? $auth
           : $auth eq 'NTLM'      ? [NTLM  => \&Authen::NTLM::ntlm ]
           :                        [$auth => undef];
    }
                                                                                
    my %clientside = map { ($_->[0] => $_) } @clientside;;
                                                                                
    # What does the server support? in its order of preference.
                                                                                
    my @serverside = map { m/^AUTH=(\w+)/ ? uc($1) : () } $self->capabilities;
                                                                                
    my @auth;
    if(@serverside)  # servers list auth capabilities
    {   @auth = map { $clientside{$_->[0]} ? delete $clientside{$_->[0]} : () }
             @serverside;
    }
    @auth = @clientside unless @auth;  # fallback to client's preference

    $self->{MTI_auth} = \@auth;
    @auth;
 }

Tell me if this works for you.
As you may have figured-out by now: authentication does need some work
for IMAPs... accessing messages and so on is more developed.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net