Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2014-01-30 21:55:41 +0000
committerSam Davis2014-02-18 22:47:19 +0000
commitbc7ac9f9f49fb5d672ab6845faf1223b8f09eac5 (patch)
tree97f696bc5205d237213eb57c4584c88ff56702b6 /org.eclipse.mylyn.tasks.ui
parente5b2bc7f021b1195509905f3397bb5086cecb167 (diff)
downloadorg.eclipse.mylyn.tasks-bc7ac9f9f49fb5d672ab6845faf1223b8f09eac5.tar.gz
org.eclipse.mylyn.tasks-bc7ac9f9f49fb5d672ab6845faf1223b8f09eac5.tar.xz
org.eclipse.mylyn.tasks-bc7ac9f9f49fb5d672ab6845faf1223b8f09eac5.zip
278474: perform migration of credentials to secure storage
Change-Id: I590cabb6f09c9bdfe28532d47ba5dc04aa15bff2 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=278474
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
index 1855dabdf..2ebc38160 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin.java
@@ -85,6 +85,8 @@ import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationMana
import org.eclipse.mylyn.internal.tasks.core.externalization.IExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizationParticipant;
import org.eclipse.mylyn.internal.tasks.core.externalization.TaskListExternalizer;
+import org.eclipse.mylyn.internal.tasks.core.util.TaskRepositoryKeyringMigrator;
+import org.eclipse.mylyn.internal.tasks.core.util.TaskRepositorySecureStoreMigrator;
import org.eclipse.mylyn.internal.tasks.core.util.TasksCoreExtensionReader;
import org.eclipse.mylyn.internal.tasks.ui.actions.ActivateTaskDialogAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskAction;
@@ -144,6 +146,12 @@ public class TasksUiPlugin extends AbstractUIPlugin {
private static final int NOTIFICATION_DELAY = 5000;
+ private static final String PREF_MIGRATED_TASK_REPOSITORIES_FROM_SECURE_STORE = "migrated.task.repositories.secure.store"; //$NON-NLS-1$
+
+ private static final String PREF_MIGRATED_TASK_REPOSITORIES_FROM_KEYRING = "migrated.task.repositories.keyring"; //$NON-NLS-1$
+
+ private static final String PROP_FORCE_CREDENTIALS_MIGRATION = "org.eclipse.mylyn.tasks.force.credentials.migration"; //$NON-NLS-1$
+
private static TasksUiPlugin INSTANCE;
private static ExternalizationManager externalizationManager;
@@ -669,6 +677,8 @@ public class TasksUiPlugin extends AbstractUIPlugin {
// initialize managers
initializeDataSources();
+ migrateCredentials(repositoryManager.getAllRepositories());
+
// make this available early for clients that are not initialized through tasks ui but need access
taskListNotificationManager = new TaskListNotificationManager();
@@ -704,6 +714,47 @@ public class TasksUiPlugin extends AbstractUIPlugin {
}
}
+ /**
+ * Migrate credentials from the old secure store location, and from the deprecated keyring if the compatibility.auth
+ * bundle is present.
+ */
+ @SuppressWarnings("deprecation")
+ private void migrateCredentials(final List<TaskRepository> repositories) {
+ // Use a UI job to ensure the UI has loaded
+ new UIJob("Credential Migration UI Job") { //$NON-NLS-1$
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ // use a Job to ensure we do not access the secure store on the UI thread
+ new Job("Credential Migration") { //$NON-NLS-1$
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ boolean force = Boolean.parseBoolean(System.getProperty(PROP_FORCE_CREDENTIALS_MIGRATION));
+ if (force) {
+ StatusHandler.log(new Status(IStatus.INFO, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
+ "Forcing task repository credential migration because system property {0} is set.", //$NON-NLS-1$
+ PROP_FORCE_CREDENTIALS_MIGRATION)));
+ }
+ if (force
+ || !getPluginPreferences().getBoolean(PREF_MIGRATED_TASK_REPOSITORIES_FROM_SECURE_STORE)) {
+ new TaskRepositorySecureStoreMigrator().migrateCredentials(repositories);
+ }
+ if ((force || !getPluginPreferences().getBoolean(PREF_MIGRATED_TASK_REPOSITORIES_FROM_KEYRING))
+ && isKeyringInstalled()) {
+ new TaskRepositoryKeyringMigrator("", "Basic").migrateCredentials(repositories); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return Status.OK_STATUS;
+ }
+
+ }.schedule();
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ private boolean isKeyringInstalled() {
+ return Platform.getBundle("org.eclipse.core.runtime.compatibility.auth") != null; //$NON-NLS-1$
+ }
+
private void initHttpLogging() {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); //$NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -821,6 +872,12 @@ public class TasksUiPlugin extends AbstractUIPlugin {
identityServiceTracker = null;
}
+ // wait until stop() to set these to reduce chance of crash after setting them but before creds are persisted
+ getPluginPreferences().setValue(PREF_MIGRATED_TASK_REPOSITORIES_FROM_SECURE_STORE, Boolean.toString(true));
+ if (isKeyringInstalled()) {
+ getPluginPreferences().setValue(PREF_MIGRATED_TASK_REPOSITORIES_FROM_KEYRING, Boolean.toString(true));
+ }
+
if (PlatformUI.isWorkbenchRunning()) {
if (taskListNotificationManager != null) {
getPreferenceStore().removePropertyChangeListener(taskListNotificationManager);

Back to the top