1 | try {↵ | | |
|
2 | if (loginMethod == AuthenticationManager.LOGIN) {↵ | | 1 | if (loginMethod == AuthenticationManager.↵
|
| | | 2 | APOP) {↵
|
| | | 3 | try {↵
|
3 | protocol.login(item.get("user"), password);↵ | | 4 | protocol.apop(popItem.get("user"), password);↵
|
|
4 | // If no exception happened we have successfully logged↵ | | 5 | ↵
|
5 | // in↵ | | |
|
6 | authenticated↵ | | 6 | } catch (POP3Exception e1) {↵
|
| | | 7 | // some server have a bogus apop↵
|
| | | 8 | // try user/pass to check if the password is↵
|
| | | 9 | // correct↵
|
| | | 10 | protocol.userPass(popItem.get("user"), password);↵
|
|
| | | 11 | LOG↵
|
| | | 12 | .warning(popItem.get("host")↵
|
| | | 13 | + " : bogus APOP implementation -> falling back to USER/PASS.");↵
|
|
| | | 14 | // user/pass worked -> this is indeed↵
|
| | | 15 | // a bogus server.↵
|
| | | 16 | }↵
|
7 | = true;↵ | | 17 | login = true;↵
|
8 | } else {↵ | | 18 | } else {↵
|
9 | try {↵ | | 19 | try {↵
|
10 | // AUTH↵ | | 20 | // AUTH↵
|
11 | protocol.authenticate(AuthenticationManager↵ | | 21 | protocol.auth(AuthenticationManager↵
|
12 | .getSaslName(loginMethod), item.get("user"),↵ | | 22 | .getSaslName(loginMethod), popItem.get("user"),↵
|
13 | password);↵ | | 23 | password);↵
|
|
14 | // If no exception happened we have successfully logged↵ | | 24 | ↵
|
15 | // in↵ | | |
|
16 | authenticated = true;↵ | | 25 | login = true;↵
|
17 | } catch (AuthenticationException e) {↵ | | 26 | } catch (AuthenticationException e) {↵
|
18 | // If the cause is a IMAPExcpetion then only password↵ | | 27 | // If the cause is a IMAPExcpetion then only password↵
|
19 | // wrong↵ | | 28 | // wrong↵
|
20 | // else bogus authentication mechanism↵ | | 29 | // else bogus authentication mechanism↵
|
21 | if (e.getCause() instanceof IMAPException)↵ | | 30 | if (e.getCause() instanceof POP3Exception)↵
|
22 | throw (IMAPException) e.getCause();↵ | | 31 | throw (POP3Exception) e.getCause();↵
|
|
23 | // Some error in the client/server communication↵ | | 32 | // Some error in the client/server communication↵
|
24 | // --> fall back to default login process↵ | | 33 | // --> fall back to default login process↵
|
25 | int result = JOptionPane↵ | | 34 | int result = JOptionPane↵
|
26 | .showConfirmDialog(↵ | | 35 | .showConfirmDialog(↵
|
27 | FrameManager.getInstance()↵ | | 36 | FrameManager.getInstance()↵
|
28 | .getActiveFrame(),↵ | | 37 | .getActiveFrame(),↵
|
29 | new MultiLineLabel(↵ | | 38 | new MultiLineLabel(↵
|
30 | e.getMessage()↵ | | 39 | e.getMessage()↵
|
31 | + "\n"↵ | | 40 | + "\n"↵
|
32 | + MailResourceLoader↵ | | 41 | + MailResourceLoader↵
|
33 | .getString(↵ | | 42 | .getString(↵
|
34 | "dialog",↵ | | 43 | "dialog",↵
|
35 | "error",↵ | | 44 | "error",↵
|
36 | "authentication_fallback_to_default")),↵ | | 45 | "authentication_fallback_to_default")),↵
|
37 | MailResourceLoader.getString("dialog",↵ | | 46 | MailResourceLoader.getString("dialog",↵
|
38 | "error",↵ | | 47 | "error",↵
|
39 | "authentication_process_error"),↵ | | 48 | "authentication_process_error"),↵
|
40 | JOptionPane.OK_CANCEL_OPTION);↵ | | 49 | JOptionPane.OK_CANCEL_OPTION);↵
|
|
41 | if (result == JOptionPane.OK_OPTION) {↵ | | 50 | if (result == JOptionPane.OK_OPTION) {↵
|
42 | loginMethod = AuthenticationManager.LOGIN;↵ | | 51 | loginMethod = AuthenticationManager.USER;↵
|
43 | item.setString("login_method", Integer↵ | | 52 | popItem.setString("login_method", Integer↵
|
44 | .toString(loginMethod));↵ | | 53 | .toString(loginMethod));↵
|
45 | } else {↵ | | 54 | } else {↵
|
46 | throw new CommandCancelledException();↵ | | 55 | throw new CommandCancelledException();↵
|
47 | }↵ | | 56 | }↵
|
48 | }↵ | | 57 | }↵
|
49 | }↵ | | 58 | }
|
|
50 | } catch (IMAPException ex) {↵ | | | |
51 | // login failed?↵ | | | |
52 | IMAPResponse response = ex.getResponse();↵ | | | |
53 | if (response == null || !response.isNO()) {↵ | | | |
54 | // This exception is not because wrong username or↵ | | | |
55 | // password↵ | | | |
56 | throw ex;↵ | | | |
57 | }↵ | | | |
58 | } | | | |