Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid King2014-02-25 23:36:37 -0500
committerDavid King2014-02-25 23:38:20 -0500
commit9a45470c9411e8f3cde842af43fcadb7c4d5f900 (patch)
tree1f125f6f4cb4fdd1af2c55a58834e15daba09f6a
parentbb4ca77e42fbd5032c9211d53a6f9ad2ca798cf9 (diff)
downloadorg.eclipse.mylyn.tasks-9a45470c9411e8f3cde842af43fcadb7c4d5f900.tar.gz
org.eclipse.mylyn.tasks-9a45470c9411e8f3cde842af43fcadb7c4d5f900.tar.xz
org.eclipse.mylyn.tasks-9a45470c9411e8f3cde842af43fcadb7c4d5f900.zip
Add missing null checks when handling repository credentials in Trac
connector Change-Id: Ic9cb1cffbbeb4cb5024557d8521c03df19568ce3 Signed-off-by: David King <david.king@tasktop.com>
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java6
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java2
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java5
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties1
4 files changed, 12 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
index 61ba37846..3c266560d 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
@@ -105,8 +106,9 @@ public class TracRepositorySettingsPageTest extends TestCase {
TaskRepository repository = fixture.repository();
page.setAnonymous(false);
page.setUrl(repository.getRepositoryUrl());
- page.setUserId(repository.getCredentials(AuthenticationType.REPOSITORY).getUserName());
- page.setPassword(repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ AuthenticationCredentials credentials = repository.getCredentials(AuthenticationType.REPOSITORY);
+ page.setUserId(credentials == null ? null : credentials.getUserName());
+ page.setPassword(credentials == null ? null : credentials.getPassword());
page.setTracVersion(fixture.getAccessMode());
validator = page.new TracValidator(page.createTaskRepository(), fixture.getAccessMode());
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java
index dc74dc68c..4bfd68c7d 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java
@@ -91,6 +91,8 @@ public class Messages extends NLS {
public static String TracRepositorySettingsPage_Access_Type_;
+ public static String TracRepositorySettingsPage_auth_failed_missing_credentials;
+
public static String TracRepositorySettingsPage_Authentication_credentials_are_valid;
public static String TracRepositorySettingsPage_Authentication_credentials_valid_Update_to_latest_XmlRpcPlugin_Warning;
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java
index f5b544d86..f28be58c1 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java
@@ -191,6 +191,11 @@ public class TracRepositorySettingsPage extends AbstractRepositorySettingsPage {
} catch (TracLoginException e) {
if (e.isNtlmAuthRequested()) {
AuthenticationCredentials credentials = taskRepository.getCredentials(AuthenticationType.REPOSITORY);
+ if (credentials == null || credentials.getUserName() == null || credentials.getPassword() == null) {
+ throw new CoreException(new RepositoryStatus(IStatus.ERROR, TracUiPlugin.ID_PLUGIN,
+ RepositoryStatus.ERROR_EMPTY_PASSWORD,
+ Messages.TracRepositorySettingsPage_auth_failed_missing_credentials, e));
+ }
if (!credentials.getUserName().contains("\\")) { //$NON-NLS-1$
throw new CoreException(RepositoryStatus.createStatus(repositoryUrl, IStatus.ERROR,
TracUiPlugin.ID_PLUGIN,
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties
index 4f168a184..df911ef47 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties
@@ -43,6 +43,7 @@ TracQueryPage_Type=Type
TracQueryPage_Version=Version
TracRepositorySettingsPage_Access_Type_=Access Type:
+TracRepositorySettingsPage_auth_failed_missing_credentials=Authentication failed. No credentials have been supplied.
TracRepositorySettingsPage_Authentication_credentials_are_valid=Authentication credentials are valid. Note: Insufficient permissions for XML-RPC access, falling back to web access.
TracRepositorySettingsPage_Authentication_credentials_valid_Update_to_latest_XmlRpcPlugin_Warning=Authentication credentials are valid. Note: An update to the latest version of Trac's XmlRpcPlugin is recommended.
TracRepositorySettingsPage_Automatic__Use_Validate_Settings_=Automatic (Use Validate Settings)

Back to the top