diff options
author | relves | 2006-12-14 22:08:31 +0000 |
---|---|---|
committer | relves | 2006-12-14 22:08:31 +0000 |
commit | 00490d0988bea79025b616b332f7c5ae5860ce02 (patch) | |
tree | 5801a72fe53bf08421a93461126fe5ddc0ccdc5f /org.eclipse.mylyn.tasks.core/src | |
parent | d7bbb1aafd2e1803be344679dd43fbead4ac2808 (diff) | |
download | org.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
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src')
-rw-r--r-- | org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java | 37 | ||||
-rw-r--r-- | org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java | 24 |
2 files changed, 45 insertions, 16 deletions
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 */ |