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 */
19 #include "imap_private.h"
22 static imap_auth_t imap_authenticators[] = {
24 {imap_auth_sasl, NULL},
26 {imap_auth_anon, "anonymous"},
29 {imap_auth_gss, "gssapi"},
31 /* SASL includes CRAM-MD5 (and GSSAPI, but that's not enabled by default) */
33 {imap_auth_cram_md5, "cram-md5"},
35 {imap_auth_login, "login"},
40 /* imap_authenticate: Attempt to authenticate using either user-specified
41 * authentication method if specified, or any. */
42 int imap_authenticate (IMAP_DATA * idata)
44 imap_auth_t *authenticator;
50 if (ImapAuthenticators && *ImapAuthenticators) {
51 /* Try user-specified list of authentication methods */
52 methods = safe_strdup (ImapAuthenticators);
54 for (method = methods; method; method = delim) {
55 delim = strchr (method, ':');
62 (debugfile, "imap_authenticate: Trying method %s\n", method));
63 authenticator = imap_authenticators;
65 while (authenticator->authenticate) {
66 if (!authenticator->method ||
67 !ascii_strcasecmp (authenticator->method, method))
68 if ((r = authenticator->authenticate (idata, method)) !=
81 /* Fall back to default: any authenticator */
83 (debugfile, "imap_authenticate: Using any available method.\n"));
84 authenticator = imap_authenticators;
86 while (authenticator->authenticate) {
88 authenticator->authenticate (idata, NULL)) != IMAP_AUTH_UNAVAIL)
94 if (r == IMAP_AUTH_UNAVAIL) {
95 mutt_error (_("No authenticators available"));