diff options
author | Sam Davis | 2013-01-16 19:14:38 +0000 |
---|---|---|
committer | Steffen Pingel | 2013-10-08 01:55:47 +0000 |
commit | 3b1cb33184c84edfc8a6bba711ab9d47acd648b4 (patch) | |
tree | b49163b64284cfafff81446cfcaac7df5cb32c76 /org.eclipse.mylyn.tasks.core | |
parent | ed32420d9f87d18a801caed2caddcfa6901492cb (diff) | |
download | org.eclipse.mylyn.tasks-3b1cb33184c84edfc8a6bba711ab9d47acd648b4.tar.gz org.eclipse.mylyn.tasks-3b1cb33184c84edfc8a6bba711ab9d47acd648b4.tar.xz org.eclipse.mylyn.tasks-3b1cb33184c84edfc8a6bba711ab9d47acd648b4.zip |
326119: Repository credentials are overwritten during repository
settings validation
Change-Id: I0f8becdc0bc2869d67de80401920bf6f7d69bd87
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=326119
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r-- | org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java | 31 |
1 files changed, 28 insertions, 3 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 3cc5f42a8..4dc4d7995 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 @@ -233,6 +233,8 @@ public final class TaskRepository extends PlatformObject { private transient volatile boolean updating; + private boolean shouldPersistCredentials = true; + public TaskRepository(String connectorKind, String repositoryUrl) { this(connectorKind, repositoryUrl, NO_VERSION_SPECIFIED); } @@ -284,7 +286,7 @@ public final class TaskRepository extends PlatformObject { } private void addAuthInfo(String username, String password, String userProperty, String passwordProperty) { - if (Platform.isRunning()) { + if (Platform.isRunning() && shouldPersistCredentials()) { if (useSecureStorage()) { try { ISecurePreferences securePreferences = getSecurePreferences(); @@ -387,7 +389,7 @@ public final class TaskRepository extends PlatformObject { } synchronized (LOCK) { - if (Platform.isRunning()) { + if (Platform.isRunning() && shouldPersistCredentials()) { if (useSecureStorage()) { if (Platform.isRunning()) { ISecurePreferences securePreferences = getSecurePreferences(); @@ -431,7 +433,7 @@ public final class TaskRepository extends PlatformObject { @SuppressWarnings("unchecked") private String getAuthInfo(String property) { - if (Platform.isRunning()) { + if (Platform.isRunning() && shouldPersistCredentials()) { if (useSecureStorage()) { String propertyValue = null; if (property.equals(getKeyPrefix(AuthenticationType.REPOSITORY) + USERNAME)) { @@ -481,6 +483,29 @@ public final class TaskRepository extends PlatformObject { } } + /** + * Returns {@code} if credentials persisted in the platform keystore. + * + * @since 3.10 + * @see #setShouldPersistCredentials(boolean) + */ + public boolean shouldPersistCredentials() { + return shouldPersistCredentials; + } + + /** + * Toggles the flag for persisting credentials. If {@code shouldPersistCredentials} is {@code false} credentials + * will not be persisted in the platform keystore. + * <p> + * This flag does not have any effect if not running in an OSGi environment. + * + * @since 3.10 + * @see #shouldPersistCredentials() + */ + public void setShouldPersistCredentials(boolean shouldPersistCredentials) { + this.shouldPersistCredentials = shouldPersistCredentials; + } + public String getCharacterEncoding() { final String encoding = properties.get(IRepositoryConstants.PROPERTY_ENCODING); return encoding == null || "".equals(encoding) ? DEFAULT_CHARACTER_ENCODING : encoding; //$NON-NLS-1$ |