Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2006-12-14 17:08:31 -0500
committerrelves2006-12-14 17:08:31 -0500
commit00490d0988bea79025b616b332f7c5ae5860ce02 (patch)
tree5801a72fe53bf08421a93461126fe5ddc0ccdc5f
parentd7bbb1aafd2e1803be344679dd43fbead4ac2808 (diff)
downloadorg.eclipse.mylyn.tasks-00490d0988bea79025b616b332f7c5ae5860ce02.tar.gz
org.eclipse.mylyn.tasks-00490d0988bea79025b616b332f7c5ae5860ce02.tar.xz
org.eclipse.mylyn.tasks-00490d0988bea79025b616b332f7c5ae5860ce02.zip
NEW - bug 168086: Store http auth credentials in keystore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=168086
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java37
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java24
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java18
5 files changed, 59 insertions, 30 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
index ca9e068c2..3dfe36ca5 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java
@@ -33,10 +33,8 @@ public class BugzillaClientManager implements ITaskRepositoryListener {
BugzillaClient client = clientByUrl.get(taskRepository.getUrl());
if (client == null) {
- String htUser = taskRepository.getProperty(TaskRepository.AUTH_HTTP_USERNAME) != null ? taskRepository
- .getProperty(TaskRepository.AUTH_HTTP_USERNAME) : "";
- String htPass = taskRepository.getProperty(TaskRepository.AUTH_HTTP_PASSWORD) != null ? taskRepository
- .getProperty(TaskRepository.AUTH_HTTP_PASSWORD) : "";
+ String htUser = taskRepository.getHttpUser() != null ? taskRepository.getHttpUser() : "";
+ String htPass = taskRepository.getHttpPassword() != null ? taskRepository.getHttpPassword() : "";
client = BugzillaClientFactory.createClient(taskRepository.getUrl(), taskRepository.getUserName(),
taskRepository.getPassword(), htUser, htPass, taskRepository.getProxy(), taskRepository
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
index 6a7d2ba2e..2f9cde69e 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
@@ -167,38 +167,43 @@ public class TaskRepository {
public String getProxyPassword() {
return getAuthInfo(PROXY_PASSWORD);
}
+
+ public String getHttpUser() {
+ return getAuthInfo(AUTH_HTTP_USERNAME);
+ }
+
+ public String getHttpPassword() {
+ return getAuthInfo(AUTH_HTTP_PASSWORD);
+ }
public void setAuthenticationCredentials(String username, String password) {
- Map<String, String> map = getAuthInfo();
- if (map == null) {
- map = new HashMap<String, String>();
- }
-
- if (username != null) {
- map.put(AUTH_USERNAME, username);
- cachedUserName = username;
- }
- if (password != null) {
- map.put(AUTH_PASSWORD, password);
- }
- addAuthInfo(map);
+ setCredentials(username, password, AUTH_USERNAME, AUTH_PASSWORD);
+ cachedUserName = username;
}
public void setProxyAuthenticationCredentials(String username, String password) {
+ setCredentials(username, password, PROXY_USERNAME, PROXY_PASSWORD);
+ }
+
+ public void setHttpAuthenticationCredentials(String username, String password) {
+ setCredentials(username, password, AUTH_HTTP_USERNAME, AUTH_HTTP_PASSWORD);
+ }
+
+ private void setCredentials(String username, String password, String userProperty, String passwordProperty) {
Map<String, String> map = getAuthInfo();
if (map == null) {
map = new HashMap<String, String>();
}
if (username != null) {
- map.put(PROXY_USERNAME, username);
+ map.put(userProperty, username);
}
if (password != null) {
- map.put(PROXY_PASSWORD, password);
+ map.put(passwordProperty, password);
}
addAuthInfo(map);
}
-
+
public void flushAuthenticationCredentials() {
try {
if (Platform.isRunning()) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java
index dc6f99466..904b0a781 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java
@@ -219,6 +219,7 @@ public class TaskRepositoryManager {
private void loadRepositories(String repositoriesFilePath) {
try {
+ boolean migration = false;
// String dataDirectory =
// TasksUiPlugin.getDefault().getDataDirectory();
File repositoriesFile = new File(repositoriesFilePath);
@@ -231,6 +232,11 @@ public class TaskRepositoryManager {
Set<TaskRepository> repositories = externalizer.readRepositoriesFromXML(repositoriesFile);
if (repositories != null && repositories.size() > 0) {
for (TaskRepository repository : repositories) {
+
+ if(removeHttpAuthMigration(repository)) {
+ migration = true;
+ }
+
if (repositoryMap.containsKey(repository.getKind())) {
repositoryMap.get(repository.getKind()).add(repository);
} else {
@@ -238,12 +244,30 @@ public class TaskRepositoryManager {
}
}
}
+ if(migration) {
+ System.err.println(">> saving");
+ saveRepositories(repositoriesFilePath);
+ }
}
} catch (Throwable t) {
MylarStatusHandler.fail(t, "could not load repositories", false);
}
}
+ private boolean removeHttpAuthMigration(TaskRepository repository) {
+ String httpusername = repository.getProperty(TaskRepository.AUTH_HTTP_USERNAME);
+ String httppassword = repository.getProperty(TaskRepository.AUTH_HTTP_PASSWORD);
+ if (httpusername != null && httppassword != null) {
+ repository.removeProperty(TaskRepository.AUTH_HTTP_USERNAME);
+ repository.removeProperty(TaskRepository.AUTH_HTTP_PASSWORD);
+ if (httpusername.length() > 0 && httppassword.length() > 0) {
+ repository.setHttpAuthenticationCredentials(httpusername, httppassword);
+ }
+ return true;
+ }
+ return false;
+ }
+
/**
* for testing purposes
*/
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java
index fa7e1dce7..97092fb4a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java
@@ -63,8 +63,8 @@ public class EditRepositoryWizard extends Wizard implements INewWizard {
repository.setAuthenticationCredentials(abstractRepositorySettingsPage.getUserName(), abstractRepositorySettingsPage.getPassword());
repository.setRepositoryLabel(abstractRepositorySettingsPage.getRepositoryLabel());
- repository.setProperty(TaskRepository.AUTH_HTTP_USERNAME, abstractRepositorySettingsPage.getHttpAuthUserId());
- repository.setProperty(TaskRepository.AUTH_HTTP_PASSWORD, abstractRepositorySettingsPage.getHttpAuthPassword());
+ repository.setHttpAuthenticationCredentials(abstractRepositorySettingsPage.getHttpAuthUserId(),
+ abstractRepositorySettingsPage.getHttpAuthPassword());
repository.setProperty(TaskRepository.PROXY_USEDEFAULT, String.valueOf(abstractRepositorySettingsPage.getUseDefaultProxy()));
repository.setProperty(TaskRepository.PROXY_HOSTNAME, abstractRepositorySettingsPage.getProxyHostname());
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java
index d9b1bc6cc..64b8b9e50 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java
@@ -245,10 +245,10 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage {
originalUrl = repository.getUrl();
oldUsername = repository.getUserName();
oldPassword = repository.getPassword();
- if (repository.hasProperty(TaskRepository.AUTH_HTTP_USERNAME)
- && repository.hasProperty(TaskRepository.AUTH_HTTP_PASSWORD)) {
- oldHttpAuthUserId = repository.getProperty(TaskRepository.AUTH_HTTP_USERNAME);
- oldHttpAuthPassword = repository.getProperty(TaskRepository.AUTH_HTTP_PASSWORD);
+
+ if (repository.getHttpUser() != null && repository.getHttpPassword() != null) {
+ oldHttpAuthUserId = repository.getHttpUser();
+ oldHttpAuthPassword = repository.getHttpPassword();
} else {
oldHttpAuthPassword = "";
oldHttpAuthUserId = "";
@@ -894,15 +894,17 @@ public abstract class AbstractRepositorySettingsPage extends WizardPage {
repository.setRepositoryLabel(getRepositoryLabel());
repository.setAuthenticationCredentials(getUserName(), getPassword());
- repository.setProperty(TaskRepository.AUTH_HTTP_USERNAME, getHttpAuthUserId());
- repository.setProperty(TaskRepository.AUTH_HTTP_PASSWORD, getHttpAuthPassword());
+ //repository.setProperty(TaskRepository.AUTH_HTTP_USERNAME, getHttpAuthUserId());
+ //repository.setProperty(TaskRepository.AUTH_HTTP_PASSWORD, getHttpAuthPassword());
+ if(getHttpAuthUserId().length()>0 && getHttpAuthPassword().length()>0) {
+ repository.setHttpAuthenticationCredentials(getHttpAuthUserId(), getHttpAuthPassword());
+ }
repository.setProperty(TaskRepository.PROXY_USEDEFAULT, String.valueOf(getUseDefaultProxy()));
repository.setProperty(TaskRepository.PROXY_HOSTNAME, getProxyHostname());
repository.setProperty(TaskRepository.PROXY_PORT, getProxyPort());
- if (getProxyUsername() != null && getProxyPassword() != null && getProxyUsername().length() > 0
- && getProxyPassword().length() > 0) {
+ if (getProxyUsername().length() > 0 && getProxyPassword().length() > 0) {
repository.setProxyAuthenticationCredentials(getProxyUsername(), getProxyPassword());
}
// repository.setProperty(TaskRepository.PROXY_USERNAME,

Back to the top