Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 278474 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java (-1 / +2 lines)
Lines 160-166 Link Here
160
160
161
	static final String VALUES_TARGET = "org.eclipse.mylyn.bugzilla.values.target"; //$NON-NLS-1$
161
	static final String VALUES_TARGET = "org.eclipse.mylyn.bugzilla.values.target"; //$NON-NLS-1$
162
162
163
164
	// Default values for keys
163
	// Default values for keys
165
164
166
	static final String[] DEFAULT_STATUS_VALUES = { "Unconfirmed", "New", "Assigned", "Reopened", "Resolved", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
165
	static final String[] DEFAULT_STATUS_VALUES = { "Unconfirmed", "New", "Assigned", "Reopened", "Resolved", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
Lines 272-275 Link Here
272
271
273
	public static final String LAST_COMPONENT_SELECTION = "last.selection.component"; //$NON-NLS-1$
272
	public static final String LAST_COMPONENT_SELECTION = "last.selection.component"; //$NON-NLS-1$
274
273
274
	public static final String PREFERENCE_SECURE_STORAGE_MIGRATED = "secure_storage.migration.done"; //$NON-NLS-1$
275
275
}
276
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java (+16 lines)
Lines 14-25 Link Here
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
18
import org.eclipse.core.runtime.jobs.Job;
19
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
17
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
21
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
19
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
22
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
20
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
23
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
21
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
24
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
22
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
25
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
26
import org.eclipse.mylyn.tasks.ui.MigrateToSecureStorageJob;
23
import org.eclipse.mylyn.tasks.ui.TasksUi;
27
import org.eclipse.mylyn.tasks.ui.TasksUi;
24
import org.eclipse.ui.plugin.AbstractUIPlugin;
28
import org.eclipse.ui.plugin.AbstractUIPlugin;
25
import org.osgi.framework.BundleContext;
29
import org.osgi.framework.BundleContext;
Lines 91-96 Link Here
91
95
92
		TasksUi.getRepositoryManager().addListener(bugzillaConnector.getClientManager());
96
		TasksUi.getRepositoryManager().addListener(bugzillaConnector.getClientManager());
93
97
98
		if (!getPreferenceStore().getBoolean(IBugzillaConstants.PREFERENCE_SECURE_STORAGE_MIGRATED)) {
99
			Job migrateJob = new MigrateToSecureStorageJob(BugzillaCorePlugin.CONNECTOR_KIND);
100
			migrateJob.addJobChangeListener(new JobChangeAdapter() {
101
				@Override
102
				public void done(IJobChangeEvent event) {
103
					super.done(event);
104
					getPreferenceStore().setValue(IBugzillaConstants.PREFERENCE_SECURE_STORAGE_MIGRATED, Boolean.TRUE);
105
				}
106
			});
107
			migrateJob.schedule();
108
		}
109
94
		// NOTE: initializing extensions in start(..) has caused race
110
		// NOTE: initializing extensions in start(..) has caused race
95
		// conditions previously
111
		// conditions previously
96
		BugzillaUiExtensionReader.initStartupExtensions();
112
		BugzillaUiExtensionReader.initStartupExtensions();
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java (+3 lines)
Lines 35-40 Link Here
35
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
35
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
36
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
36
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
37
import org.eclipse.mylyn.tasks.core.TaskRepository;
37
import org.eclipse.mylyn.tasks.core.TaskRepository;
38
import org.eclipse.mylyn.tasks.ui.MigrateToSecureStorageJob;
38
import org.eclipse.mylyn.tasks.ui.TasksUi;
39
import org.eclipse.mylyn.tasks.ui.TasksUi;
39
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
40
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
40
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.SWT;
Lines 267-272 Link Here
267
268
268
	@Override
269
	@Override
269
	public void applyTo(TaskRepository repository) {
270
	public void applyTo(TaskRepository repository) {
271
		MigrateToSecureStorageJob.migrateToSecureStorage(repository);
272
270
		super.applyTo(repository);
273
		super.applyTo(repository);
271
		repository.setProperty(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN,
274
		repository.setProperty(IBugzillaConstants.REPOSITORY_SETTING_SHORT_LOGIN,
272
				String.valueOf(cleanQAContact.getSelection()));
275
				String.valueOf(cleanQAContact.getSelection()));
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 10-15 Link Here
10
 org.eclipse.core.expressions,
10
 org.eclipse.core.expressions,
11
 org.eclipse.core.net,
11
 org.eclipse.core.net,
12
 org.eclipse.core.resources,
12
 org.eclipse.core.resources,
13
 org.eclipse.equinox.security,
13
 org.eclipse.jface.text,
14
 org.eclipse.jface.text,
14
 org.eclipse.ui.browser,
15
 org.eclipse.ui.browser,
15
 org.eclipse.ui.editors,
16
 org.eclipse.ui.editors,
(-)src/org/eclipse/mylyn/internal/tasks/ui/Messages.java (+4 lines)
Lines 25-30 Link Here
25
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
25
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
26
	}
26
	}
27
27
28
	public static String MigrateToSecureStorageJob_failed;
29
30
	public static String MigrateToSecureStorageJob_title;
31
28
	public static String ActiveContextExternalizationParticipant_Active_Task_Context;
32
	public static String ActiveContextExternalizationParticipant_Active_Task_Context;
29
33
30
	public static String ActivityExternalizationParticipant_Activity_Context;
34
	public static String ActivityExternalizationParticipant_Activity_Context;
(-)src/org/eclipse/mylyn/internal/tasks/ui/messages.properties (+3 lines)
Lines 84-86 Link Here
84
TaskHyperlink_Open_Task_X_in_X=Open Task {0} in {1}
84
TaskHyperlink_Open_Task_X_in_X=Open Task {0} in {1}
85
85
86
AbstractRetrieveTitleFromUrlJob_Retrieving_summary_from_URL=Retrieving summary from URL
86
AbstractRetrieveTitleFromUrlJob_Retrieving_summary_from_URL=Retrieving summary from URL
87
88
MigrateToSecureStorageJob_failed=Could not migrate credentials to secure storage for {0}
89
MigrateToSecureStorageJob_title=Migrating passwords to secure storage
(-)src/org/eclipse/mylyn/tasks/ui/MigrateToSecureStorageJob.java (+81 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Tasktop Technologies and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.tasks.ui;
13
14
import java.net.MalformedURLException;
15
import java.net.URL;
16
import java.util.Set;
17
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.mylyn.commons.core.StatusHandler;
24
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
25
import org.eclipse.mylyn.commons.net.AuthenticationType;
26
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
27
import org.eclipse.mylyn.internal.tasks.ui.Messages;
28
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
29
import org.eclipse.mylyn.tasks.core.TaskRepository;
30
import org.eclipse.osgi.util.NLS;
31
32
public class MigrateToSecureStorageJob extends Job {
33
34
	private final String kind;
35
36
	public MigrateToSecureStorageJob(String kind) {
37
		super(Messages.MigrateToSecureStorageJob_title);
38
		this.kind = kind;
39
	}
40
41
	@Override
42
	protected IStatus run(IProgressMonitor monitor) {
43
		Set<TaskRepository> repos = TasksUiPlugin.getRepositoryManager().getRepositories(kind);
44
		if (repos != null) {
45
			for (TaskRepository repo : repos) {
46
				migrateToSecureStorage(repo);
47
			}
48
		}
49
		return Status.OK_STATUS;
50
	}
51
52
	@SuppressWarnings({ "deprecation" })
53
	public static boolean migrateToSecureStorage(TaskRepository repository) {
54
		if (repository.getProperty(ITasksCoreConstants.PROPERTY_USE_SECURE_STORAGE) == null
55
				&& !repository.getUrl().equals("local")) { //$NON-NLS-1$
56
			try {
57
				AuthenticationCredentials creds = repository.getCredentials(AuthenticationType.REPOSITORY);
58
				boolean savePassword = repository.getSavePassword(AuthenticationType.REPOSITORY);
59
60
				repository.setProperty(ITasksCoreConstants.PROPERTY_USE_SECURE_STORAGE, "true"); //$NON-NLS-1$
61
62
				if (creds != null) {
63
					try {
64
						Platform.flushAuthorizationInfo(new URL(repository.getUrl()), "", "Basic"); //$NON-NLS-1$ //$NON-NLS-2$
65
					} catch (MalformedURLException ex) {
66
						Platform.flushAuthorizationInfo(
67
								new URL("http://eclipse.org/mylyn"), repository.getUrl(), "Basic"); //$NON-NLS-1$ //$NON-NLS-2$
68
					}
69
70
					repository.setCredentials(AuthenticationType.REPOSITORY, creds, savePassword);
71
				}
72
73
				return true;
74
			} catch (Exception e) {
75
				StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
76
						"Could not migrate credentials to secure storage for {0}", repository.getUrl()), e));
77
			}
78
		}
79
		return false;
80
	}
81
}

Return to bug 278474