2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-8 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
5 * Copyright (C) 1999-2001 Brendan Cully <brendan@kublai.com>
7 * This file is part of mutt-ng, see http://www.muttng.org/.
8 * It's licensed under the GNU General Public License,
9 * please see the file GPL in the top level source directory.
12 /* IMAP login/authentication code */
14 #include <lib-lib/lib-lib.h>
17 #include "imap_private.h"
20 static imap_auth_t imap_authenticators[] = {
22 {imap_auth_sasl, NULL},
24 {imap_auth_anon, "anonymous"},
27 {imap_auth_gss, "gssapi"},
29 /* SASL includes CRAM-MD5 (and GSSAPI, but that's not enabled by default) */
31 {imap_auth_cram_md5, "cram-md5"},
33 {imap_auth_login, "login"},
38 /* imap_authenticate: Attempt to authenticate using either user-specified
39 * authentication method if specified, or any. */
40 int imap_authenticate (IMAP_DATA * idata)
42 imap_auth_t *authenticator;
48 if (ImapAuthenticators && *ImapAuthenticators) {
49 /* Try user-specified list of authentication methods */
50 methods = m_strdup(ImapAuthenticators);
52 for (method = methods; method; method = delim) {
53 delim = strchr (method, ':');
59 authenticator = imap_authenticators;
61 while (authenticator->authenticate) {
62 if (!authenticator->method ||
63 !ascii_strcasecmp (authenticator->method, method))
64 if ((r = authenticator->authenticate (idata, method)) !=
77 /* Fall back to default: any authenticator */
78 authenticator = imap_authenticators;
80 while (authenticator->authenticate) {
82 authenticator->authenticate (idata, NULL)) != IMAP_AUTH_UNAVAIL)
88 if (r == IMAP_AUTH_UNAVAIL) {
89 mutt_error (_("No authenticators available"));