Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 275233 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/repository/Credentials.java (-3 / +8 lines)
Lines 30-35 Link Here
30
 * in a store, if none is provided the user is optionally prompted for the information. 
30
 * in a store, if none is provided the user is optionally prompted for the information. 
31
 */
31
 */
32
public class Credentials {
32
public class Credentials {
33
	public static class LoginCanceledException extends Exception {
34
		private static final long serialVersionUID = 1L;
35
36
	}
37
33
	private static final Map savedAuthInfo = Collections.synchronizedMap(new HashMap());
38
	private static final Map savedAuthInfo = Collections.synchronizedMap(new HashMap());
34
39
35
	/**
40
	/**
Lines 48-54 Link Here
48
	 * @throws CoreException if the password cannot be read or saved
53
	 * @throws CoreException if the password cannot be read or saved
49
	 * @return The authentication info.
54
	 * @return The authentication info.
50
	 */
55
	 */
51
	public static AuthenticationInfo forLocation(URI location, boolean prompt) throws UserCancelledException, CoreException {
56
	public static AuthenticationInfo forLocation(URI location, boolean prompt) throws LoginCanceledException, CoreException {
52
		return forLocation(location, prompt, null);
57
		return forLocation(location, prompt, null);
53
	}
58
	}
54
59
Lines 70-76 Link Here
70
	 * @throws UserCancelledException - user canceled the prompt for name/password
75
	 * @throws UserCancelledException - user canceled the prompt for name/password
71
	 * @throws CoreException if there is an error
76
	 * @throws CoreException if there is an error
72
	 */
77
	 */
73
	public static AuthenticationInfo forLocation(URI location, boolean prompt, AuthenticationInfo lastUsed) throws UserCancelledException, CoreException {
78
	public static AuthenticationInfo forLocation(URI location, boolean prompt, AuthenticationInfo lastUsed) throws LoginCanceledException, CoreException {
74
		ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault();
79
		ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault();
75
80
76
		// if URI is not opaque, just getting the host may be enough
81
		// if URI is not opaque, just getting the host may be enough
Lines 137-143 Link Here
137
			loginDetails = lastUsed != null ? adminUIService.getUsernamePassword(host, lastUsed) : adminUIService.getUsernamePassword(host);
142
			loginDetails = lastUsed != null ? adminUIService.getUsernamePassword(host, lastUsed) : adminUIService.getUsernamePassword(host);
138
		//null result means user canceled password dialog
143
		//null result means user canceled password dialog
139
		if (loginDetails == null)
144
		if (loginDetails == null)
140
			throw new UserCancelledException();
145
			throw new LoginCanceledException();
141
		//save user name and password if requested by user
146
		//save user name and password if requested by user
142
		if (loginDetails.saveResult()) {
147
		if (loginDetails.saveResult()) {
143
			if (prefNode == null)
148
			if (prefNode == null)
(-)src/org/eclipse/equinox/internal/p2/repository/Messages.java (-1 / +1 lines)
Lines 72-78 Link Here
72
	public static String FileTransport_reader;
72
	public static String FileTransport_reader;
73
73
74
	public static String UnableToRead_0_TooManyAttempts;
74
	public static String UnableToRead_0_TooManyAttempts;
75
75
	public static String UnableToRead_0_UserCanceled;
76
	static {
76
	static {
77
		// initialize resource bundles
77
		// initialize resource bundles
78
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
78
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
(-)src/org/eclipse/equinox/internal/p2/repository/RepositoryTransport.java (+12 lines)
Lines 18-23 Link Here
18
import org.eclipse.ecf.core.security.ConnectContextFactory;
18
import org.eclipse.ecf.core.security.ConnectContextFactory;
19
import org.eclipse.ecf.core.security.IConnectContext;
19
import org.eclipse.ecf.core.security.IConnectContext;
20
import org.eclipse.ecf.filetransfer.UserCancelledException;
20
import org.eclipse.ecf.filetransfer.UserCancelledException;
21
import org.eclipse.equinox.internal.p2.repository.Credentials.LoginCanceledException;
21
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
22
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
22
import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI.AuthenticationInfo;
23
import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI.AuthenticationInfo;
23
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
24
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
Lines 92-97 Link Here
92
				return statusOn(target, RepositoryStatus.forException(e, toDownload), reader);
93
				return statusOn(target, RepositoryStatus.forException(e, toDownload), reader);
93
			} catch (AuthenticationFailedException e) {
94
			} catch (AuthenticationFailedException e) {
94
				promptUser = true;
95
				promptUser = true;
96
			} catch (Credentials.LoginCanceledException e) {
97
				DownloadStatus status = new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_AUTHENTICATION, //
98
						NLS.bind(Messages.UnableToRead_0_UserCanceled, toDownload), null);
99
				return statusOn(target, status, null);
100
95
			}
101
			}
96
		}
102
		}
97
		// reached maximum number of retries without success
103
		// reached maximum number of retries without success
Lines 147-152 Link Here
147
				if (e.getStatus().getException() == null)
153
				if (e.getStatus().getException() == null)
148
					throw new CoreException(RepositoryStatus.forException(e, toDownload));
154
					throw new CoreException(RepositoryStatus.forException(e, toDownload));
149
				throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
155
				throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
156
			} catch (LoginCanceledException e) {
157
				// i.e. same behavior when user cancels as when failing n attempts.
158
				throw new AuthenticationFailedException();
150
			}
159
			}
151
		}
160
		}
152
		throw new AuthenticationFailedException();
161
		throw new AuthenticationFailedException();
Lines 202-207 Link Here
202
				throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
211
				throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
203
			} catch (AuthenticationFailedException e) {
212
			} catch (AuthenticationFailedException e) {
204
				promptUser = true;
213
				promptUser = true;
214
			} catch (LoginCanceledException e) {
215
				// same behavior as if user failed n attempts.
216
				throw new AuthenticationFailedException();
205
			}
217
			}
206
		}
218
		}
207
		// reached maximum number of authentication retries without success
219
		// reached maximum number of authentication retries without success
(-)src/org/eclipse/equinox/internal/p2/repository/messages.properties (+1 lines)
Lines 69-71 Link Here
69
FileTransport_reader=File Transport Reader
69
FileTransport_reader=File Transport Reader
70
connection_to_0_failed_on_1_retry_attempt_2=Connection to {0} failed on {1}. Retry attempt {2} started
70
connection_to_0_failed_on_1_retry_attempt_2=Connection to {0} failed on {1}. Retry attempt {2} started
71
UnableToRead_0_TooManyAttempts=Unable to read repository at: {0}. Too many failed login attempts.
71
UnableToRead_0_TooManyAttempts=Unable to read repository at: {0}. Too many failed login attempts.
72
UnableToRead_0_UserCanceled=Unable to read repository at: {0}. Login canceled by user.

Return to bug 275233