Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-06-01 17:15:22 -0400
committerspingel2010-06-01 17:15:22 -0400
commitd74d400094f1fdf54456f0ff5b305b5bd8f5cd4f (patch)
treeebbca2b513b5ebc8edab6546ec1dbfea0520a6ca /org.eclipse.mylyn.tasks.core
parent7fe74c7e3c42e63f4035c80bcce7b5abfa3dfb2a (diff)
downloadorg.eclipse.mylyn.tasks-d74d400094f1fdf54456f0ff5b305b5bd8f5cd4f.tar.gz
org.eclipse.mylyn.tasks-d74d400094f1fdf54456f0ff5b305b5bd8f5cd4f.tar.xz
org.eclipse.mylyn.tasks-d74d400094f1fdf54456f0ff5b305b5bd8f5cd4f.zip
NEW - bug 315024: fix dead lock when credentials are retrieved from secure store
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315024
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java95
1 files changed, 37 insertions, 58 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 059d61052..7acbbb184 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
@@ -245,22 +245,22 @@ public final class TaskRepository extends PlatformObject {
}
private void addAuthInfo(String username, String password, String userProperty, String passwordProperty) {
- synchronized (LOCK) {
- if (Platform.isRunning()) {
- if (useSecureStorage()) {
- try {
- ISecurePreferences securePreferences = getSecurePreferences();
- if (userProperty.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) {
- this.setProperty(userProperty, username);
- } else {
- securePreferences.put(userProperty, username, false);
- }
- securePreferences.put(passwordProperty, password, true);
- } catch (StorageException e) {
- StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
- "Could not store authorization credentials", e)); //$NON-NLS-1$
+ if (Platform.isRunning()) {
+ if (useSecureStorage()) {
+ try {
+ ISecurePreferences securePreferences = getSecurePreferences();
+ if (userProperty.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) {
+ this.setProperty(userProperty, username);
+ } else {
+ securePreferences.put(userProperty, username, false);
}
- } else {
+ securePreferences.put(passwordProperty, password, true);
+ } catch (StorageException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Could not store authorization credentials", e)); //$NON-NLS-1$
+ }
+ } else {
+ synchronized (LOCK) {
Map<String, String> map = getAuthInfo();
if (map == null) {
map = new HashMap<String, String>();
@@ -278,7 +278,9 @@ public final class TaskRepository extends PlatformObject {
"Could not set authorization credentials", e)); //$NON-NLS-1$
}
}
- } else {
+ }
+ } else {
+ synchronized (LOCK) {
Map<String, String> headlessCreds = credentials.get(getRepositoryUrl());
if (headlessCreds == null) {
headlessCreds = new HashMap<String, String>();
@@ -390,27 +392,24 @@ public final class TaskRepository extends PlatformObject {
@SuppressWarnings("unchecked")
private String getAuthInfo(String property) {
- synchronized (LOCK) {
- if (Platform.isRunning()) {
- if (useSecureStorage()) {
- String propertyValue = null;
- if (property.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) {
- propertyValue = this.getProperty(property);
- } else {
- try {
- ISecurePreferences securePreferences = getSecurePreferences();
- propertyValue = securePreferences.get(property, null);
- } catch (StorageException e) {
- StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
- "Could not retrieve authorization credentials", e)); //$NON-NLS-1$
- }
- if (propertyValue == null) {
- propertyValue = getFromLegacyKeystore(property);
- }
- }
- return propertyValue;
+ if (Platform.isRunning()) {
+ if (useSecureStorage()) {
+ String propertyValue = null;
+ if (property.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) {
+ propertyValue = this.getProperty(property);
} else {
try {
+ ISecurePreferences securePreferences = getSecurePreferences();
+ propertyValue = securePreferences.get(property, null);
+ } catch (StorageException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Could not retrieve authorization credentials", e)); //$NON-NLS-1$
+ }
+ }
+ return propertyValue;
+ } else {
+ synchronized (LOCK) {
+ try {
Map<String, String> map = Platform.getAuthorizationInfo(new URL(getRepositoryUrl()),
AUTH_REALM, AUTH_SCHEME);
if (map != null) {
@@ -430,7 +429,9 @@ public final class TaskRepository extends PlatformObject {
}
return null;
}
- } else {
+ }
+ } else {
+ synchronized (LOCK) {
Map<String, String> headlessCreds = credentials.get(getRepositoryUrl());
if (headlessCreds == null) {
headlessCreds = new HashMap<String, String>();
@@ -441,28 +442,6 @@ public final class TaskRepository extends PlatformObject {
}
}
- @SuppressWarnings("unchecked")
- private String getFromLegacyKeystore(String property) {
- String propertyValue = null;
- try {
- Map<String, String> map = Platform.getAuthorizationInfo(new URL(getRepositoryUrl()), AUTH_REALM,
- AUTH_SCHEME);
- if (map != null) {
- propertyValue = map.get(property);
- if (propertyValue != null) {
- ISecurePreferences securePreferences = getSecurePreferences();
- securePreferences.put(property, propertyValue, property.endsWith(PASSWORD));
- map.remove(property);
- }
- }
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
- "Could not retrieve authorization credentials", e)); //$NON-NLS-1$
- }
- return propertyValue;
-
- }
-
public String getCharacterEncoding() {
final String encoding = properties.get(IRepositoryConstants.PROPERTY_ENCODING);
return encoding == null || "".equals(encoding) ? DEFAULT_CHARACTER_ENCODING : encoding; //$NON-NLS-1$

Back to the top