diff options
author | fbecker | 2011-05-28 21:25:39 +0000 |
---|---|---|
committer | fbecker | 2011-05-28 21:25:39 +0000 |
commit | 8caeddb9195362d83d1a23bbc6e3a0be7374549e (patch) | |
tree | 44ee5427e7b7555cc9aa77661e1353d4bf0e6790 | |
parent | 468c6d9816b604e4c456011e48336c6a965a60a0 (diff) | |
download | org.eclipse.mylyn.tasks-8caeddb9195362d83d1a23bbc6e3a0be7374549e.tar.gz org.eclipse.mylyn.tasks-8caeddb9195362d83d1a23bbc6e3a0be7374549e.tar.xz org.eclipse.mylyn.tasks-8caeddb9195362d83d1a23bbc6e3a0be7374549e.zip |
ASSIGNED - bug 289174: account locked due to unsaved password
https://bugs.eclipse.org/bugs/show_bug.cgi?id=289174
6 files changed, 41 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java index 478d6569c..d175dace8 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java @@ -419,6 +419,13 @@ public class BugzillaClient { "Authentication credentials from location missing.")); //$NON-NLS-1$ } if (credentials != null) { + String password = credentials.getPassword(); + if ("".equals(password) && !hasHTTPAuthenticationCredentials()) { //$NON-NLS-1$ + loggedIn = false; + throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, + RepositoryStatus.ERROR_EMPTY_PASSWORD, repositoryUrl.toString(), + "Empty password not allowed for Authentication credentials.")); //$NON-NLS-1$ + } formData[0] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, credentials.getUserName()); formData[1] = new NameValuePair(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, credentials.getPassword()); diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java index a31209b20..344f658cc 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaStatus.java @@ -60,6 +60,8 @@ public class BugzillaStatus extends Status { public String getMessage() { switch (getCode()) { + case RepositoryStatus.ERROR_EMPTY_PASSWORD: + return NLS.bind(Messages.BugzillaStatus_emptyPassword, this.getRepositoryUrl(), this.errorMessage); case RepositoryStatus.ERROR_REPOSITORY_LOGIN: return NLS.bind(Messages.BugzillaStatus_repositoryLoginFailure, this.getRepositoryUrl(), this.errorMessage); case RepositoryStatus.ERROR_REPOSITORY_NOT_FOUND: diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java index c345d781d..cfab0373d 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java @@ -301,6 +301,8 @@ public class Messages extends NLS { public static String BugzillaStatus_operationCancelled; + public static String BugzillaStatus_emptyPassword; + public static String BugzillaStatus_errorIo; public static String BugzillaStatus_errorInternal; diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties index 66b7f2e55..1332cc8bf 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties @@ -149,6 +149,7 @@ IBugzillaConstants_requested_operation_not_permitted=The requested operation is SaxMultiBugReportContentHandler_id_not_found=\ id not found. +BugzillaStatus_emptyPassword=Empty password not allowed to login to {0}.\n\n{1}\n\nPlease validate credentials via Task Repositories view. BugzillaStatus_errorRepository = Repository error from {0}:\n\n{1} BugzillaStatus_repositoryLoginFailure = Unable to login to {0}.\n\n{1}\n\nPlease validate credentials via Task Repositories view. BugzillaStatus_repositoryNotFound = Repository {0} could not be found. diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java index f6e75f8b4..d08e377b5 100644 --- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java +++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java @@ -24,6 +24,7 @@ import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture; import org.eclipse.mylyn.commons.net.AuthenticationCredentials; import org.eclipse.mylyn.commons.net.AuthenticationType; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaOperation; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler; @@ -33,6 +34,7 @@ import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; import org.eclipse.mylyn.internal.context.core.ContextCorePlugin; import org.eclipse.mylyn.internal.tasks.core.AbstractTask; import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; +import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryLocation; import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizationSession; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil; @@ -42,6 +44,7 @@ import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState; import org.eclipse.mylyn.tasks.core.RepositoryResponse; import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind; import org.eclipse.mylyn.tasks.core.TaskMapping; +import org.eclipse.mylyn.tasks.core.TaskRepository; import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; @@ -1156,4 +1159,25 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { } } + public void testCredentialsWithoutPassword() throws Exception { + TaskRepository repository = BugzillaFixture.current().repository(); + AuthenticationCredentials oldCreds = repository.getCredentials(AuthenticationType.REPOSITORY); + AuthenticationCredentials anonymousCreds = new AuthenticationCredentials(oldCreds.getUserName(), ""); + repository.setCredentials(AuthenticationType.REPOSITORY, anonymousCreds, false); + TaskRepositoryLocation location = new TaskRepositoryLocation(repository); + + client = new BugzillaClient(location, repository, BugzillaFixture.current().connector()); + try { + client.validate(new NullProgressMonitor()); + + } catch (CoreException e) { + assertTrue(e.getStatus().getMessage().indexOf("Please validate credentials via Task Repositories view.") != -1); + return; + } finally { + repository.setCredentials(AuthenticationType.REPOSITORY, oldCreds, false); + TasksUiPlugin.getRepositoryManager().notifyRepositorySettingsChanged(repository); + } + fail("Should have failed due to an empty password."); + } + } diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/RepositoryStatus.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/RepositoryStatus.java index b6ec7b84a..e064439f3 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/RepositoryStatus.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/RepositoryStatus.java @@ -49,6 +49,11 @@ public class RepositoryStatus extends Status { public final static int ERROR_INTERNAL = 7; + /** + * @since 3.6 + */ + public final static int ERROR_EMPTY_PASSWORD = 13; + private String htmlMessage; protected String repositoryUrl; |