diff options
author | Tobias Oberlies | 2012-01-02 13:38:21 +0000 |
---|---|---|
committer | Tobias Oberlies | 2012-01-09 14:23:37 +0000 |
commit | c56d3086f43989513d7e3d2a149a0b6b1f82e9a7 (patch) | |
tree | 2fe59ce961a71a129c10520bf4d0ae582ad34639 | |
parent | 47549f93278cc0296730577528c106b452b43420 (diff) | |
download | rt.equinox.p2-c56d3086f43989513d7e3d2a149a0b6b1f82e9a7.tar.gz rt.equinox.p2-c56d3086f43989513d7e3d2a149a0b6b1f82e9a7.tar.xz rt.equinox.p2-c56d3086f43989513d7e3d2a149a0b6b1f82e9a7.zip |
348366 Only remember cancel if dialog explicitly signals cancelv20120109-1423
- Introduced a new constant in UIServices to give the implementations
the possibility to explicitly indicate that the user cancelled a
prompt for password.
- Only remember cancel in class Credentials on explicit user cancels.
This ensures that the authentication prompt is shown at least once.
Bug: 348366 - [repository] Cannot update from update site with authentication
7 files changed, 29 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF index 2e227ad9d..c2d53fae2 100644 --- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.core;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-ClassPath: . Bundle-Activator: org.eclipse.equinox.internal.p2.core.Activator Bundle-Vendor: %providerName diff --git a/bundles/org.eclipse.equinox.p2.core/pom.xml b/bundles/org.eclipse.equinox.p2.core/pom.xml index a98bfe8ab..6714ce8df 100644 --- a/bundles/org.eclipse.equinox.p2.core/pom.xml +++ b/bundles/org.eclipse.equinox.p2.core/pom.xml @@ -10,6 +10,6 @@ </parent> <groupId>org.eclipse</groupId> <artifactId>org.eclipse.equinox.p2.core</artifactId> - <version>2.1.0-SNAPSHOT</version> + <version>2.2.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/UIServices.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/UIServices.java index 00d79e370..161622745 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/UIServices.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/UIServices.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,6 +31,14 @@ public abstract class UIServices { public static final String SERVICE_NAME = UIServices.class.getName(); /** + * This constant may be returned by the <code>getUsernamePassword</code> methods if the user + * explicitly canceled the authentication prompt. + * + * @since 2.2 + */ + public static final AuthenticationInfo AUTHENTICATION_PROMPT_CANCELED = new AuthenticationInfo("", "", false); //$NON-NLS-1$//$NON-NLS-2$ + + /** * Authentication information returned from an authentication prompt request. */ public static class AuthenticationInfo { @@ -109,7 +117,7 @@ public abstract class UIServices { * Opens a UI prompt for authentication details * * @param location - the location requiring login details, may be <code>null</code>. - * @return The authentication result + * @return The authentication result, or <code>null</code>, or {@link #AUTHENTICATION_PROMPT_CANCELED} */ public abstract AuthenticationInfo getUsernamePassword(String location); @@ -119,7 +127,7 @@ public abstract class UIServices { * * @param location the location requiring login details * @param previousInfo - the previously used authentication details - may not be null. - * @return The authentication result + * @return The authentication result, or <code>null</code>, or {@link #AUTHENTICATION_PROMPT_CANCELED} */ public abstract AuthenticationInfo getUsernamePassword(String location, AuthenticationInfo previousInfo); diff --git a/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF index 692c9c6a7..524be7d70 100644 --- a/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.repository;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.1.100.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.repository.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.repository/pom.xml b/bundles/org.eclipse.equinox.p2.repository/pom.xml index bb8b06c9a..ef4538821 100644 --- a/bundles/org.eclipse.equinox.p2.repository/pom.xml +++ b/bundles/org.eclipse.equinox.p2.repository/pom.xml @@ -10,6 +10,6 @@ </parent> <groupId>org.eclipse</groupId> <artifactId>org.eclipse.equinox.p2.repository</artifactId> - <version>2.1.0-SNAPSHOT</version> + <version>2.1.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java index 309757241..96cd71426 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 IBM Corporation and others. + * Copyright (c) 2009, 2012 IBM Corporation and others. * The code, documentation and other materials contained herein have been * licensed under the Eclipse Public License - v 1.0 by the copyright holder * listed above, as the Initial Contributor under such license. The text of @@ -233,13 +233,15 @@ public class Credentials { loginDetails = lastUsed != null ? adminUIService.getUsernamePassword(host, lastUsed) : adminUIService.getUsernamePassword(host); //null result means user canceled password dialog if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) { - if (loginDetails == null) + if (loginDetails == UIServices.AUTHENTICATION_PROMPT_CANCELED) DebugHelper.debug("Credentials", "forLocation:PROMPTED - USER CANCELED (PROMPT LOCK RELEASED)", // //$NON-NLS-1$ //$NON-NLS-2$ new Object[] {"host", location}); //$NON-NLS-1$ } - if (loginDetails == null) { + if (loginDetails == UIServices.AUTHENTICATION_PROMPT_CANCELED) { rememberCancel(host); throw new LoginCanceledException(); + } else if (loginDetails == null) { + throw new LoginCanceledException(); } //save user name and password if requested by user if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) { diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java index b731d0e33..ff6209f26 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -63,8 +63,11 @@ public class ValidationDialogServiceUI extends UIServices { Shell shell = ProvUI.getDefaultParentShell(); String message = NLS.bind(ProvUIMessages.ServiceUI_LoginDetails, location); UserValidationDialog dialog = new UserValidationDialog(shell, ProvUIMessages.ServiceUI_LoginRequired, null, message); - if (dialog.open() == Window.OK) { + int dialogCode = dialog.open(); + if (dialogCode == Window.OK) { result[0] = dialog.getResult(); + } else if (dialogCode == Window.CANCEL) { + result[0] = AUTHENTICATION_PROMPT_CANCELED; } } @@ -170,8 +173,11 @@ public class ValidationDialogServiceUI extends UIServices { message = NLS.bind(ProvUIMessages.ProvUIMessages_NotAccepted_EnterFor_0, location); UserValidationDialog dialog = new UserValidationDialog(previousInfo, shell, ProvUIMessages.ServiceUI_LoginRequired, null, message); - if (dialog.open() == Window.OK) { + int dialogCode = dialog.open(); + if (dialogCode == Window.OK) { result[0] = dialog.getResult(); + } else if (dialogCode == Window.CANCEL) { + result[0] = AUTHENTICATION_PROMPT_CANCELED; } } |