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