Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-12-22 15:38:27 -0500
committermkersten2006-12-22 15:38:27 -0500
commitd73e9686a95dd8e9206d603c997fc2e99fd1c0f2 (patch)
treed997d94517419dec67813f2ec5a8b2f1884e782c
parent04ba1cb1f2b3a48f0098a1b0a9ba586d8001ac5f (diff)
downloadorg.eclipse.mylyn.tasks-d73e9686a95dd8e9206d603c997fc2e99fd1c0f2.tar.gz
org.eclipse.mylyn.tasks-d73e9686a95dd8e9206d603c997fc2e99fd1c0f2.tar.xz
org.eclipse.mylyn.tasks-d73e9686a95dd8e9206d603c997fc2e99fd1c0f2.zip
NEW - bug 168887: Caching user name for task repository is not working for anonymous user
https://bugs.eclipse.org/bugs/show_bug.cgi?id=168887
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java32
1 files changed, 19 insertions, 13 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 2f9cde69e..a7345b4d6 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
@@ -79,7 +79,9 @@ public class TaskRepository {
// HACK: private credentials for headless operation
private static Map<String, Map<String, String>> credentials = new HashMap<String, Map<String, String>>();
- private String cachedUserName = null;
+ private boolean isCachedUserName;
+
+ private String cachedUserName;
static {
URL url = null;
@@ -146,7 +148,7 @@ public class TaskRepository {
*/
public String getUserName() {
// NOTE: if anonymous, user name is "" string so we won't go to keyring
- if (cachedUserName == null) {
+ if (!isCachedUserName) {
cachedUserName = getUserNameFromKeyRing();
}
return cachedUserName;
@@ -179,6 +181,7 @@ public class TaskRepository {
public void setAuthenticationCredentials(String username, String password) {
setCredentials(username, password, AUTH_USERNAME, AUTH_PASSWORD);
cachedUserName = username;
+ isCachedUserName = true;
}
public void setProxyAuthenticationCredentials(String username, String password) {
@@ -205,19 +208,22 @@ public class TaskRepository {
}
public void flushAuthenticationCredentials() {
- try {
- if (Platform.isRunning()) {
- try {
- Platform.flushAuthorizationInfo(new URL(getUrl()), AUTH_REALM, AUTH_SCHEME);
- } catch (MalformedURLException ex) {
- Platform.flushAuthorizationInfo(DEFAULT_URL, getUrl(), AUTH_SCHEME);
+ synchronized (LOCK) {
+ try {
+ if (Platform.isRunning()) {
+ try {
+ Platform.flushAuthorizationInfo(new URL(getUrl()), AUTH_REALM, AUTH_SCHEME);
+ } catch (MalformedURLException ex) {
+ Platform.flushAuthorizationInfo(DEFAULT_URL, getUrl(), AUTH_SCHEME);
+ }
+ } else {
+ Map<String, String> headlessCreds = getAuthInfo();
+ headlessCreds.clear();
}
- } else {
- Map<String, String> headlessCreds = getAuthInfo();
- headlessCreds.clear();
+ isCachedUserName = false;
+ } catch (CoreException e) {
+ MylarStatusHandler.fail(e, "could not flush authorization credentials", true);
}
- } catch (CoreException e) {
- MylarStatusHandler.fail(e, "could not flush authorization credentials", true);
}
}

Back to the top