try { if (loginMethod == AuthenticationManager.LOGIN) { protocol.login(item.get("user"), password); // If no exception happened we have successfully logged // in authenticated = true; } else { try { // AUTH protocol.authenticate(AuthenticationManager .getSaslName(loginMethod), item.get("user"), password); // If no exception happened we have successfully logged // in authenticated = true; } catch (AuthenticationException e) { // If the cause is a IMAPExcpetion then only password // wrong // else bogus authentication mechanism if (e.getCause() instanceof IMAPException) throw (IMAPException) e.getCause(); // Some error in the client/server communication // --> fall back to default login process int result = JOptionPane .showConfirmDialog( FrameManager.getInstance() .getActiveFrame(), new MultiLineLabel( e.getMessage() + "\n" + MailResourceLoader .getString( "dialog", "error", "authentication_fallback_to_default")), MailResourceLoader.getString("dialog", "error", "authentication_process_error"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { loginMethod = AuthenticationManager.LOGIN; item.setString("login_method", Integer .toString(loginMethod)); } else { throw new CommandCancelledException(); } } } } catch (IMAPException ex) { // login failed? IMAPResponse response = ex.getResponse(); if (response == null || !response.isNO()) { // This exception is not because wrong username or // password throw ex;
} else if (loginMethod == AuthenticationManager.APOP) { try { protocol.apop(popItem.get("user"), password); } catch (POP3Exception e1) { // some server have a bogus apop // try user/pass to check if the password is // correct protocol.userPass(popItem.get("user"), password); LOG .warning(popItem.get("host") + " : bogus APOP implementation -> falling back to USER/PASS."); // user/pass worked -> this is indeed // a bogus server. } login = true; } else { try { // AUTH protocol.auth(AuthenticationManager .getSaslName(loginMethod), popItem.get("user"), password); login = true; } catch (AuthenticationException e) { // If the cause is a IMAPExcpetion then only password // wrong // else bogus authentication mechanism if (e.getCause() instanceof POP3Exception) throw (POP3Exception) e.getCause(); // Some error in the client/server communication // --> fall back to default login process int result = JOptionPane .showConfirmDialog( FrameManager.getInstance() .getActiveFrame(), new MultiLineLabel( e.getMessage() + "\n" + MailResourceLoader .getString( "dialog", "error", "authentication_fallback_to_default")), MailResourceLoader.getString("dialog", "error", "authentication_process_error"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { loginMethod = AuthenticationManager.USER; popItem.setString("login_method", Integer .toString(loginMethod)); } else { throw new CommandCancelledException();
Clone fragments detected by clone detection tool
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: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
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
				
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0