File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/imap/IMAPServer.java | File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/pop3/POP3Store.java | |||
Method name: void login()
|
Method name: void login()
|
|||
Number of AST nodes: 7 | Number of AST nodes: 7 | |||
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 | } | |||
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 3.8 |
Clones location | Clones are in different classes |
Number of node comparisons | 19 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 36.7 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
21 | if (loginMethod == AuthenticationManager.LOGIN) |
| 19 | if (loginMethod == AuthenticationManager.APOP) | ||||||||||||||||||||||||||
| 20 | try | ||||||||||||||||||||||||||||
|
| 21 | protocol.apop(popItem.get("user"), password); | |||||||||||||||||||||||||||
22 | protocol.login(item.get("user"), password); |
| | |||||||||||||||||||||||||||
23 | authenticated = true; |
| 22 | login = true; | ||||||||||||||||||||||||||
24 | try |
| 23 | try | ||||||||||||||||||||||||||
25 | protocol.authenticate(AuthenticationManager.getSaslName(loginMethod), item.get("user"), password); |
| 24 | protocol.auth(AuthenticationManager.getSaslName(loginMethod), popItem.get("user"), password); | ||||||||||||||||||||||||||
26 | authenticated = true; |
| 25 | login = true; |
Row | Violation |
---|---|
1 | Unmatched statement protocol.apop(popItem.get("user"),password); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
2 | Unmatched statement protocol.login(item.get("user"),password); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
3 | Expression e.getCause() instanceof IMAPException cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression e.getCause() instanceof POP3Exception cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression (IMAPException)e.getCause() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression (POP3Exception)e.getCause() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression protocol.authenticate(AuthenticationManager.getSaslName(loginMethod),item.get("user"),password) is a void method call, and thus it cannot be parameterized |
10 | Expression protocol.auth(AuthenticationManager.getSaslName(loginMethod),popItem.get("user"),password) is a void method call, and thus it cannot be parameterized |
11 | Expression protocol cannot be unified with expression protocol , because common superclass org.columba.ristretto.auth.AuthenticationServer does not declare member(s) public void authenticate(java.lang.String, java.lang.String, char[]) throws java.io.IOException, org.columba.ristretto.imap.IMAPException, org.columba.ristretto.auth.AuthenticationException, public void auth(java.lang.String, java.lang.String, char[]) throws java.io.IOException, org.columba.ristretto.pop3.POP3Exception, org.columba.ristretto.auth.AuthenticationException |