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 200634 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/bugzilla/tests/RepositoryEditorWizardTest.java (-1 / +1 lines)
Lines 44-50 Link Here
44
		manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
44
		manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
45
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
45
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
46
		Credentials credentials = TestUtil.readCredentials();
46
		Credentials credentials = TestUtil.readCredentials();
47
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
47
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
48
		repository.setAnonymous(false);
48
		repository.setAnonymous(false);
49
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
49
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
50
				TasksUiPlugin.getDefault().getRepositoriesFilePath());
50
				TasksUiPlugin.getDefault().getRepositoriesFilePath());
(-)src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java (-7 / +9 lines)
Lines 44-54 Link Here
44
 */
44
 */
45
public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
45
public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
46
46
47
//  testReassign Bugs 
47
48
//	Version	BugNr	assigned				reporter     
49
//	2.22	92		user@mylar.eclipse.org	tests@mylar.eclipse.org
50
//	3.0		 5		tests@mylar.eclipse.org	tests2@mylar.eclipse.org
51
//	3.1		 1		rob.elves@eclipse.org	tests@mylar.eclipse.org
52
48
53
	public void testReassign222() throws CoreException {
49
	public void testReassign222() throws CoreException {
54
		init222();
50
		init222();
Lines 61-66 Link Here
61
		String taskNumber = "5";
57
		String taskNumber = "5";
62
		doReassignOld(taskNumber, "tests@mylyn.eclipse.org");
58
		doReassignOld(taskNumber, "tests@mylyn.eclipse.org");
63
	}
59
	}
60
	
61
	public void testReassign30MemoryonlyPassword() throws CoreException {
62
		init30MemoryonlyPassword();
63
		String taskNumber = "5";
64
		doReassignOld(taskNumber, "tests@mylyn.eclipse.org");
65
	}
64
66
65
	public void testReassign31() throws CoreException {
67
	public void testReassign31() throws CoreException {
66
		init31();
68
		init31();
Lines 235-241 Link Here
235
	public void testAnonymousRepositoryAccess() throws Exception {
237
	public void testAnonymousRepositoryAccess() throws Exception {
236
		init218();
238
		init218();
237
		assertNotNull(repository);
239
		assertNotNull(repository);
238
		repository.setAuthenticationCredentials("", "");
240
		repository.setAuthenticationCredentials("", "", true);
239
		// test anonymous task retrieval
241
		// test anonymous task retrieval
240
		BugzillaTask task = this.generateLocalTaskAndDownload("2");
242
		BugzillaTask task = this.generateLocalTaskAndDownload("2");
241
		assertNotNull(task);
243
		assertNotNull(task);
Lines 307-313 Link Here
307
		assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
309
		assertEquals(RepositoryTaskSyncState.SYNCHRONIZED, task.getSynchronizationState());
308
		sourceContextFile.createNewFile();
310
		sourceContextFile.createNewFile();
309
		sourceContextFile.deleteOnExit();
311
		sourceContextFile.deleteOnExit();
310
		repository.setAuthenticationCredentials("wrong", "wrong");
312
		repository.setAuthenticationCredentials("wrong", "wrong", true);
311
		try {
313
		try {
312
			connector.getAttachmentHandler().attachContext(repository, task, "", new NullProgressMonitor());
314
			connector.getAttachmentHandler().attachContext(repository, task, "", new NullProgressMonitor());
313
		} catch (CoreException e) {
315
		} catch (CoreException e) {
(-)src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java (-8 / +12 lines)
Lines 71-104 Link Here
71
	}
71
	}
72
72
73
	protected void init31() {
73
	protected void init31() {
74
		init(IBugzillaConstants.TEST_BUGZILLA_31_URL);
74
		init(IBugzillaConstants.TEST_BUGZILLA_31_URL, true);
75
	}
75
	}
76
76
77
	protected void init30() {
77
	protected void init30() {
78
		init(IBugzillaConstants.TEST_BUGZILLA_30_URL);
78
		init(IBugzillaConstants.TEST_BUGZILLA_30_URL, true);
79
	}
80
81
	protected void init30MemoryonlyPassword() {
82
		init(IBugzillaConstants.TEST_BUGZILLA_30_URL, false);
79
	}
83
	}
80
84
81
	protected void init222() {
85
	protected void init222() {
82
		init(IBugzillaConstants.TEST_BUGZILLA_222_URL);
86
		init(IBugzillaConstants.TEST_BUGZILLA_222_URL, true);
83
	}
87
	}
84
88
85
	protected void init2201() {
89
	protected void init2201() {
86
		init(IBugzillaConstants.TEST_BUGZILLA_2201_URL);
90
		init(IBugzillaConstants.TEST_BUGZILLA_2201_URL, true);
87
	}
91
	}
88
92
89
	protected void init220() {
93
	protected void init220() {
90
		init(IBugzillaConstants.TEST_BUGZILLA_220_URL);
94
		init(IBugzillaConstants.TEST_BUGZILLA_220_URL, true);
91
	}
95
	}
92
96
93
	protected void init218() {
97
	protected void init218() {
94
		init(IBugzillaConstants.TEST_BUGZILLA_218_URL);
98
		init(IBugzillaConstants.TEST_BUGZILLA_218_URL, true);
95
	}
99
	}
96
100
97
	@SuppressWarnings("deprecation")
101
	@SuppressWarnings("deprecation")
98
	protected void init(String url) {
102
	protected void init(String url, boolean useKeyring) {
99
		repository = new TaskRepository(DEFAULT_KIND, url);
103
		repository = new TaskRepository(DEFAULT_KIND, url);
100
		Credentials credentials = TestUtil.readCredentials();
104
		Credentials credentials = TestUtil.readCredentials();
101
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
105
		repository.setAuthenticationCredentials(credentials.username, credentials.password, useKeyring);
102
106
103
		repository.setTimeZoneId("Canada/Eastern");
107
		repository.setTimeZoneId("Canada/Eastern");
104
		assertNotNull(manager);
108
		assertNotNull(manager);
(-)src/org/eclipse/mylyn/bugzilla/tests/RepositoryReportFactoryTest.java (-2 / +2 lines)
Lines 49-55 Link Here
49
				BugzillaCorePlugin.REPOSITORY_KIND);
49
				BugzillaCorePlugin.REPOSITORY_KIND);
50
		repository = new TaskRepository(kind, url);
50
		repository = new TaskRepository(kind, url);
51
		Credentials credentials = TestUtil.readCredentials();
51
		Credentials credentials = TestUtil.readCredentials();
52
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
52
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
53
		return repository;
53
		return repository;
54
	}
54
	}
55
55
Lines 58-64 Link Here
58
		String errorMessage = "";
58
		String errorMessage = "";
59
		try {
59
		try {
60
			setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
60
			setRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
61
			repository.setAuthenticationCredentials("invalid", "invalid");
61
			repository.setAuthenticationCredentials("invalid", "invalid", true);
62
			init(bugid);
62
			init(bugid);
63
		} catch (CoreException e) {
63
		} catch (CoreException e) {
64
			errorMessage = e.getStatus().getMessage();
64
			errorMessage = e.getStatus().getMessage();
(-)src/org/eclipse/mylyn/bugzilla/tests/BugzillaProductParserTest.java (-1 / +1 lines)
Lines 45-51 Link Here
45
	private TaskRepository setRepository(String url) {
45
	private TaskRepository setRepository(String url) {
46
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, url);
46
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, url);
47
		Credentials credentials = TestUtil.readCredentials();
47
		Credentials credentials = TestUtil.readCredentials();
48
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
48
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
49
		return repository;
49
		return repository;
50
	}
50
	}
51
51
(-)src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaTaskHistoryTest.java (-1 / +1 lines)
Lines 47-53 Link Here
47
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
47
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
48
48
49
		Credentials credentials = TestUtil.readCredentials();
49
		Credentials credentials = TestUtil.readCredentials();
50
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
50
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
51
	}
51
	}
52
52
53
	public void testGetBugHistory() throws Exception {
53
	public void testGetBugHistory() throws Exception {
(-)src/org/eclipse/mylyn/bugzilla/tests/headless/BugzillaQueryTest.java (-2 / +2 lines)
Lines 55-61 Link Here
55
		handler = connector.getTaskDataHandler();
55
		handler = connector.getTaskDataHandler();
56
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
56
		repository = new TaskRepository(BugzillaCorePlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_222_URL);
57
		Credentials credentials = TestUtil.readCredentials();
57
		Credentials credentials = TestUtil.readCredentials();
58
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
58
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
59
	}
59
	}
60
60
61
	/**
61
	/**
Lines 64-70 Link Here
64
	public void testAddCredentials() {
64
	public void testAddCredentials() {
65
		if (!repository.hasCredentials()) {
65
		if (!repository.hasCredentials()) {
66
			Credentials credentials = TestUtil.readCredentials();
66
			Credentials credentials = TestUtil.readCredentials();
67
			repository.setAuthenticationCredentials(credentials.username, credentials.password);
67
			repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
68
68
69
			assertTrue(repository.hasCredentials());
69
			assertTrue(repository.hasCredentials());
70
		}
70
		}
(-)src/org/eclipse/mylyn/tests/integration/LiveWebConnectorTemplatesTest.java (-2 / +2 lines)
Lines 75-83 Link Here
75
		String url = repository.getUrl();
75
		String url = repository.getUrl();
76
		// HACK: repositories that require auth
76
		// HACK: repositories that require auth
77
		if ("http://demo.otrs.org".equals(url)) {
77
		if ("http://demo.otrs.org".equals(url)) {
78
			repository.setAuthenticationCredentials("skywalker", "skywalker");
78
			repository.setAuthenticationCredentials("skywalker", "skywalker", true);
79
		} else if ("http://changelogic.araneaframework.org".equals(url)) {
79
		} else if ("http://changelogic.araneaframework.org".equals(url)) {
80
			repository.setAuthenticationCredentials("mylar2", "mylar123");
80
			repository.setAuthenticationCredentials("mylar2", "mylar123", true);
81
		}
81
		}
82
82
83
		String queryUrlTemplate = template.taskQueryUrl;
83
		String queryUrlTemplate = template.taskQueryUrl;
(-)src/org/eclipse/mylyn/jira/tests/JiraTaskDataHandlerTest.java (-1 / +1 lines)
Lines 74-80 Link Here
74
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
74
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
75
75
76
		repository = new TaskRepository(kind, url);
76
		repository = new TaskRepository(kind, url);
77
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
77
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
78
		manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
78
		manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
79
		
79
		
80
		connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(kind);
80
		connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(kind);
(-)src/org/eclipse/mylyn/jira/tests/JiraClientFacadeTest.java (-4 / +4 lines)
Lines 52-62 Link Here
52
	public void testChangeCredentials() throws Exception {
52
	public void testChangeCredentials() throws Exception {
53
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
53
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
54
		TaskRepository repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
54
		TaskRepository repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
55
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
55
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
56
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
56
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
57
				TasksUiPlugin.getDefault().getRepositoriesFilePath());
57
				TasksUiPlugin.getDefault().getRepositoriesFilePath());
58
58
59
		repository.setAuthenticationCredentials("Bogus User", "Bogus Password");
59
		repository.setAuthenticationCredentials("Bogus User", "Bogus Password", true);
60
		jiraFacade.repositoryRemoved(repository);
60
		jiraFacade.repositoryRemoved(repository);
61
61
62
		try {
62
		try {
Lines 67-73 Link Here
67
		}
67
		}
68
68
69
		// check that it works after putting the right password in
69
		// check that it works after putting the right password in
70
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
70
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
71
		jiraFacade.repositoryRemoved(repository);
71
		jiraFacade.repositoryRemoved(repository);
72
		jiraFacade.getJiraClient(repository).getNamedFilters();
72
		jiraFacade.getJiraClient(repository).getNamedFilters();
73
	}
73
	}
Lines 104-110 Link Here
104
	public void testCharacterEncoding() throws Exception {
104
	public void testCharacterEncoding() throws Exception {
105
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
105
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
106
		TaskRepository repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
106
		TaskRepository repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
107
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
107
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
108
		assertFalse(JiraUtils.getCharacterEncodingValidated(repository));		
108
		assertFalse(JiraUtils.getCharacterEncodingValidated(repository));		
109
109
110
		JiraClient client = jiraFacade.getJiraClient(repository);
110
		JiraClient client = jiraFacade.getJiraClient(repository);
(-)src/org/eclipse/mylyn/jira/tests/JiraStackTraceDuplicateDetectorTest.java (-1 / +1 lines)
Lines 69-75 Link Here
69
69
70
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
70
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
71
		repository = new TaskRepository(kind, url);
71
		repository = new TaskRepository(kind, url);
72
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
72
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
73
73
74
		manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
74
		manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
75
75
(-)src/org/eclipse/mylyn/jira/tests/JiraTaskExternalizationTest.java (-1 / +1 lines)
Lines 61-67 Link Here
61
	protected void setUp() throws Exception {
61
	protected void setUp() throws Exception {
62
		super.setUp();
62
		super.setUp();
63
		repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, SERVER_URL);
63
		repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, SERVER_URL);
64
		repository.setAuthenticationCredentials(USER, PASSWORD);
64
		repository.setAuthenticationCredentials(USER, PASSWORD, true);
65
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
65
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
66
				TasksUiPlugin.getDefault().getRepositoriesFilePath());
66
				TasksUiPlugin.getDefault().getRepositoriesFilePath());
67
		TasksUiPlugin.getTaskListManager().resetTaskList();
67
		TasksUiPlugin.getTaskListManager().resetTaskList();
(-)src/org/eclipse/mylyn/jira/tests/JiraRepositoryConnectorTest.java (-1 / +1 lines)
Lines 89-95 Link Here
89
89
90
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
90
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
91
		repository = new TaskRepository(kind, url);
91
		repository = new TaskRepository(kind, url);
92
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
92
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
93
93
94
		manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
94
		manager.addRepository(repository, TasksUiPlugin.getDefault().getRepositoriesFilePath());
95
95
(-)src/org/eclipse/mylyn/jira/tests/JiraAttachmentHandlerTest.java (-1 / +1 lines)
Lines 72-78 Link Here
72
		}
72
		}
73
73
74
		repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
74
		repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
75
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
75
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
76
		repository.setCharacterEncoding(JiraClient.DEFAULT_CHARSET);
76
		repository.setCharacterEncoding(JiraClient.DEFAULT_CHARSET);
77
77
78
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
78
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
(-)src/org/eclipse/mylyn/jira/tests/JiraFilterTest.java (-1 / +1 lines)
Lines 77-83 Link Here
77
		}
77
		}
78
78
79
		repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
79
		repository = new TaskRepository(JiraUiPlugin.REPOSITORY_KIND, JiraTestConstants.JIRA_39_URL);
80
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
80
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
81
		repository.setCharacterEncoding(JiraClient.DEFAULT_CHARSET);
81
		repository.setCharacterEncoding(JiraClient.DEFAULT_CHARSET);
82
82
83
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
83
		TasksUiPlugin.getRepositoryManager().addRepository(repository,
(-)src/org/eclipse/mylyn/trac/tests/RepositorySearchQueryTest.java (-1 / +1 lines)
Lines 60-66 Link Here
60
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
60
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
61
61
62
		repository = new TaskRepository(TracCorePlugin.REPOSITORY_KIND, url);
62
		repository = new TaskRepository(TracCorePlugin.REPOSITORY_KIND, url);
63
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
63
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
64
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
64
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
65
		repository.setCharacterEncoding(ITracClient.CHARSET);
65
		repository.setCharacterEncoding(ITracClient.CHARSET);
66
		repository.setVersion(version.name());
66
		repository.setVersion(version.name());
(-)src/org/eclipse/mylyn/trac/tests/TracAttachmentHandlerTest.java (-1 / +1 lines)
Lines 70-76 Link Here
70
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
70
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
71
71
72
		repository = new TaskRepository(kind, url);
72
		repository = new TaskRepository(kind, url);
73
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
73
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
74
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
74
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
75
		repository.setCharacterEncoding(ITracClient.CHARSET);
75
		repository.setCharacterEncoding(ITracClient.CHARSET);
76
		repository.setVersion(version.name());
76
		repository.setVersion(version.name());
(-)src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java (-1 / +1 lines)
Lines 86-92 Link Here
86
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
86
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
87
87
88
		repository = new TaskRepository(kind, url);
88
		repository = new TaskRepository(kind, url);
89
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
89
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
90
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
90
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
91
		repository.setCharacterEncoding(ITracClient.CHARSET);
91
		repository.setCharacterEncoding(ITracClient.CHARSET);
92
		repository.setVersion(version.name());
92
		repository.setVersion(version.name());
(-)src/org/eclipse/mylyn/trac/tests/TracTaskDataHandlerTest.java (-2 / +2 lines)
Lines 76-82 Link Here
76
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
76
		Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
77
77
78
		repository = new TaskRepository(TracCorePlugin.REPOSITORY_KIND, url);
78
		repository = new TaskRepository(TracCorePlugin.REPOSITORY_KIND, url);
79
		repository.setAuthenticationCredentials(credentials.username, credentials.password);
79
		repository.setAuthenticationCredentials(credentials.username, credentials.password, true);
80
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
80
		repository.setTimeZoneId(ITracClient.TIME_ZONE);
81
		repository.setCharacterEncoding(ITracClient.CHARSET);
81
		repository.setCharacterEncoding(ITracClient.CHARSET);
82
		repository.setVersion(version.name());
82
		repository.setVersion(version.name());
Lines 257-263 Link Here
257
				task.getTaskId());
257
				task.getTaskId());
258
		
258
		
259
		taskData.setNewComment("new comment");
259
		taskData.setNewComment("new comment");
260
		repository.setAuthenticationCredentials("foo", "bar");
260
		repository.setAuthenticationCredentials("foo", "bar", true);
261
		try {
261
		try {
262
			taskDataHandler.postTaskData(repository, taskData, new NullProgressMonitor());
262
			taskDataHandler.postTaskData(repository, taskData, new NullProgressMonitor());
263
		} catch (CoreException expected) {
263
		} catch (CoreException expected) {
(-)src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java (+22 lines)
Lines 34-39 Link Here
34
import org.eclipse.jface.preference.IPreferenceStore;
34
import org.eclipse.jface.preference.IPreferenceStore;
35
import org.eclipse.jface.resource.ImageDescriptor;
35
import org.eclipse.jface.resource.ImageDescriptor;
36
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
36
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
37
import org.eclipse.jface.window.Window;
37
import org.eclipse.jface.wizard.WizardDialog;
38
import org.eclipse.jface.wizard.WizardDialog;
38
import org.eclipse.mylyn.context.core.ContextCorePlugin;
39
import org.eclipse.mylyn.context.core.ContextCorePlugin;
39
import org.eclipse.mylyn.internal.context.core.ContextPreferenceContstants;
40
import org.eclipse.mylyn.internal.context.core.ContextPreferenceContstants;
Lines 41-46 Link Here
41
import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer;
42
import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer;
42
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
43
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
43
import org.eclipse.mylyn.internal.tasks.core.TaskDataManager;
44
import org.eclipse.mylyn.internal.tasks.core.TaskDataManager;
45
import org.eclipse.mylyn.internal.tasks.ui.EnterMemoryPassordDialog;
44
import org.eclipse.mylyn.internal.tasks.ui.IDynamicSubMenuContributor;
46
import org.eclipse.mylyn.internal.tasks.ui.IDynamicSubMenuContributor;
45
import org.eclipse.mylyn.internal.tasks.ui.ITaskHighlighter;
47
import org.eclipse.mylyn.internal.tasks.ui.ITaskHighlighter;
46
import org.eclipse.mylyn.internal.tasks.ui.ITaskListNotification;
48
import org.eclipse.mylyn.internal.tasks.ui.ITaskListNotification;
Lines 1076-1079 Link Here
1076
		}
1078
		}
1077
	}
1079
	}
1078
1080
1081
	public static void testAndSetMemoryOnlyPassword(TaskRepository repository) {
1082
		boolean memoryOnlyPassword = repository.isMemoryOnlyPassword();
1083
		boolean doIt = memoryOnlyPassword && repository.getCachedPassword() == null;
1084
		if (doIt) {
1085
			EnterMemoryPassordDialog dialog = new EnterMemoryPassordDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), repository.getRepositoryLabel(), "Please set the memoryonly Password", repository.getUserName(), !memoryOnlyPassword);
1086
			int result = dialog.open();
1087
			if (result == Window.OK) {
1088
				String password = dialog.getPassword();
1089
				String username = dialog.getUsername();
1090
				boolean allowCaching = dialog.getAllowCaching();
1091
				if (password != null && username != null)
1092
					repository.setAuthenticationCredentials(username, password, allowCaching);
1093
				if (memoryOnlyPassword != allowCaching)
1094
					repository.setMemoryOnlyPassword(!allowCaching);
1095
1096
			}
1097
		}
1098
	}
1099
1100
1079
}
1101
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/EditRepositoryWizard.java (-1 / +3 lines)
Lines 57-64 Link Here
57
			repository.setVersion(abstractRepositorySettingsPage.getVersion());
57
			repository.setVersion(abstractRepositorySettingsPage.getVersion());
58
			repository.setCharacterEncoding(abstractRepositorySettingsPage.getCharacterEncoding());
58
			repository.setCharacterEncoding(abstractRepositorySettingsPage.getCharacterEncoding());
59
			repository.setAuthenticationCredentials(abstractRepositorySettingsPage.getUserName(),
59
			repository.setAuthenticationCredentials(abstractRepositorySettingsPage.getUserName(),
60
					abstractRepositorySettingsPage.getPassword());
60
					abstractRepositorySettingsPage.getPassword(), true);
61
			repository.setRepositoryLabel(abstractRepositorySettingsPage.getRepositoryLabel());
61
			repository.setRepositoryLabel(abstractRepositorySettingsPage.getRepositoryLabel());
62
			repository.setMemoryOnlyPassword(abstractRepositorySettingsPage.getMemoryonlyPassword());
63
62
			repository.setAnonymous(abstractRepositorySettingsPage.isAnonymousAccess());
64
			repository.setAnonymous(abstractRepositorySettingsPage.isAnonymousAccess());
63
			repository.setHttpAuthenticationCredentials(abstractRepositorySettingsPage.getHttpAuthUserId(),
65
			repository.setHttpAuthenticationCredentials(abstractRepositorySettingsPage.getHttpAuthUserId(),
64
					abstractRepositorySettingsPage.getHttpAuthPassword());
66
					abstractRepositorySettingsPage.getHttpAuthPassword());
(-)src/org/eclipse/mylyn/internal/tasks/ui/ScheduledTaskListSynchJob.java (+18 lines)
Lines 55-60 Link Here
55
		this.taskListManager = taskListManager;
55
		this.taskListManager = taskListManager;
56
		this.setSystem(true);
56
		this.setSystem(true);
57
		this.setPriority(Job.BUILD);
57
		this.setPriority(Job.BUILD);
58
59
		if (repositories == null) {
60
			repositories = TasksUiPlugin.getRepositoryManager().getAllRepositories();
61
		}
62
63
		for (final TaskRepository repository : repositories) {
64
			TasksUiPlugin.testAndSetMemoryOnlyPassword(repository);
65
		}
58
	}
66
	}
59
67
60
	public ScheduledTaskListSynchJob(TaskListManager taskListManager) {
68
	public ScheduledTaskListSynchJob(TaskListManager taskListManager) {
Lines 62-71 Link Here
62
		this.taskListManager = taskListManager;
70
		this.taskListManager = taskListManager;
63
		this.setPriority(Job.BUILD);
71
		this.setPriority(Job.BUILD);
64
		this.scheduleDelay = -1;
72
		this.scheduleDelay = -1;
73
74
		if (repositories == null) {
75
			repositories = TasksUiPlugin.getRepositoryManager().getAllRepositories();
76
		}
77
78
		for (final TaskRepository repository : repositories) {
79
			TasksUiPlugin.testAndSetMemoryOnlyPassword(repository);
80
		}
65
	}
81
	}
66
82
67
	@Override
83
	@Override
68
	public IStatus run(final IProgressMonitor monitor) {
84
	public IStatus run(final IProgressMonitor monitor) {
85
69
		try {
86
		try {
70
			taskList = taskListManager.getTaskList();
87
			taskList = taskListManager.getTaskList();
71
			if (repositories == null) {
88
			if (repositories == null) {
Lines 83-88 Link Here
83
					continue;
100
					continue;
84
				}
101
				}
85
102
103
				
86
				final AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager()
104
				final AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager()
87
						.getRepositoryConnector(repository.getConnectorKind());
105
						.getRepositoryConnector(repository.getConnectorKind());
88
				if (connector == null) {
106
				if (connector == null) {
(-)src/org/eclipse/mylyn/tasks/ui/wizards/AbstractRepositorySettingsPage.java (-3 / +47 lines)
Lines 188-193 Link Here
188
188
189
	private Hyperlink manageAccountHyperlink;
189
	private Hyperlink manageAccountHyperlink;
190
190
191
	protected Button memoryonlyPasswordButton;
192
	
193
	
191
	public AbstractRepositorySettingsPage(String title, String description, AbstractRepositoryConnectorUi repositoryUi) {
194
	public AbstractRepositorySettingsPage(String title, String description, AbstractRepositoryConnectorUi repositoryUi) {
192
		super(title);
195
		super(title);
193
		super.setTitle(title);
196
		super.setTitle(title);
Lines 318-323 Link Here
318
			});
321
			});
319
		}
322
		}
320
323
324
		memoryonlyPasswordButton = new Button(compositeContainer, SWT.CHECK);
325
		GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(memoryonlyPasswordButton);
326
327
		memoryonlyPasswordButton.setText("Memoryonly Password");
328
		memoryonlyPasswordButton.addSelectionListener(new SelectionAdapter() {
329
			@Override
330
			public void widgetSelected(SelectionEvent e) {
331
				setMemoryOnly(memoryonlyPasswordButton.getSelection());
332
				isPageComplete();
333
			}
334
		});
335
321
		repositoryUserNameEditor = new StringFieldEditor("", LABEL_USER, StringFieldEditor.UNLIMITED,
336
		repositoryUserNameEditor = new StringFieldEditor("", LABEL_USER, StringFieldEditor.UNLIMITED,
322
				compositeContainer) {
337
				compositeContainer) {
323
338
Lines 377-382 Link Here
377
				setAnonymous(true);
392
				setAnonymous(true);
378
			}
393
			}
379
		}
394
		}
395
		
396
		if (repository != null) {
397
			memoryonlyPasswordButton.setSelection(repository.isMemoryOnlyPassword());
398
		} else {
399
			memoryonlyPasswordButton.setSelection(false);
400
		}
401
		
380
402
381
		// TODO: put this back if we can't get the info from all connectors
403
		// TODO: put this back if we can't get the info from all connectors
382
		// if (needsTimeZone()) {
404
		// if (needsTimeZone()) {
Lines 832-837 Link Here
832
		}
854
		}
833
	}
855
	}
834
856
857
	public void setMemoryOnly(boolean selected) {
858
859
		memoryonlyPasswordButton.setSelection(selected);
860
861
		if (selected) {
862
			oldPassword = (repositoryPasswordEditor).getStringValue();
863
			repositoryPasswordEditor.setStringValue("");
864
		} else {
865
			repositoryPasswordEditor.setStringValue(oldPassword);
866
		}
867
868
		repositoryPasswordEditor.setEnabled(!selected, compositeContainer);
869
		if (getWizard() != null) {
870
			getWizard().getContainer().updateButtons();
871
		}
872
	}
873
835
	public void setHttpAuth(boolean selected) {
874
	public void setHttpAuth(boolean selected) {
836
		if (!needsHttpAuth) {
875
		if (!needsHttpAuth) {
837
			return;
876
			return;
Lines 1042-1050 Link Here
1042
1081
1043
	private String credentialsComplete() {
1082
	private String credentialsComplete() {
1044
		if ((needsAnonymousLogin() && !anonymousButton.getSelection())
1083
		if ((needsAnonymousLogin() && !anonymousButton.getSelection())
1045
				&& (repositoryUserNameEditor.getStringValue().trim().equals("") || repositoryPasswordEditor.getStringValue()
1084
				&& (repositoryUserNameEditor.getStringValue().trim().equals("") || (repositoryPasswordEditor.getStringValue()
1046
						.trim()
1085
						.trim()
1047
						.equals(""))) {
1086
						.equals("")) ) && !memoryonlyPasswordButton.getSelection()) {
1048
			return "Repository user name and password must not be blank";
1087
			return "Repository user name and password must not be blank";
1049
		}
1088
		}
1050
		return null;
1089
		return null;
Lines 1118-1127 Link Here
1118
		TaskRepository repository = new TaskRepository(connector.getConnectorKind(), getServerUrl(), getVersion(),
1157
		TaskRepository repository = new TaskRepository(connector.getConnectorKind(), getServerUrl(), getVersion(),
1119
				getCharacterEncoding(), "");
1158
				getCharacterEncoding(), "");
1120
		repository.setRepositoryLabel(getRepositoryLabel());
1159
		repository.setRepositoryLabel(getRepositoryLabel());
1121
		repository.setAuthenticationCredentials(getUserName(), getPassword());
1160
		repository.setAuthenticationCredentials(getUserName(), getPassword(), true);
1122
		if (needsAnonymousLogin()) {
1161
		if (needsAnonymousLogin()) {
1123
			repository.setAnonymous(anonymousButton.getSelection());
1162
			repository.setAnonymous(anonymousButton.getSelection());
1124
		}
1163
		}
1164
		repository.setMemoryOnlyPassword(memoryonlyPasswordButton.getSelection());
1125
		// repository.setProperty(TaskRepository.AUTH_HTTP_USERNAME,
1165
		// repository.setProperty(TaskRepository.AUTH_HTTP_USERNAME,
1126
		// getHttpAuthUserId());
1166
		// getHttpAuthUserId());
1127
		// repository.setProperty(TaskRepository.AUTH_HTTP_PASSWORD,
1167
		// repository.setProperty(TaskRepository.AUTH_HTTP_PASSWORD,
Lines 1314-1317 Link Here
1314
1354
1315
	}
1355
	}
1316
1356
1357
	public Boolean getMemoryonlyPassword() {
1358
			return memoryonlyPasswordButton.getSelection();
1359
	}
1360
1317
}
1361
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/EnterMemoryPassordDialog.java (+277 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers 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
9
package org.eclipse.mylyn.internal.tasks.ui;
10
11
import org.eclipse.jface.dialogs.Dialog;
12
import org.eclipse.jface.dialogs.IDialogConstants;
13
import org.eclipse.jface.window.Window;
14
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Label;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Text;
27
28
/**
29
 * This Dialog is used to enter a memory only Password for TaskRepositories.
30
 * 
31
 * Based on org.eclipse.jsch.internal.ui.UserValidationDialog
32
 * 
33
 * @author Frank Becker
34
 * @since 2.2
35
 */
36
public class EnterMemoryPassordDialog extends Dialog {
37
	// widgets
38
	protected Text usernameField;
39
40
	protected Text passwordField;
41
42
	protected Button allowCachingButton;
43
44
	protected String domain;
45
46
	protected String defaultUsername;
47
48
	protected String password = null;
49
50
	protected boolean allowCaching = false;
51
52
	protected boolean defaultAllowCaching;
53
54
	protected Image keyLockImage;
55
56
	protected String username = null;
57
58
	protected String message = null;
59
60
	/**
61
	 * Creates a new EnterMemoryPassordDialog.
62
	 * 
63
	 * @param parentShell  the parent shell
64
	 * @param repositoryName  the name of the repository
65
	 * @param message  a message to display to the user
66
	 * @param defaultName  the default user name
67
	 * @param defaultAllowCaching TODO
68
	 */
69
	public EnterMemoryPassordDialog(Shell parentShell, String repositoryName, String message, String defaultName, boolean defaultAllowCaching) {
70
		super(parentShell);
71
		setShellStyle(getShellStyle() | SWT.RESIZE);
72
		this.defaultUsername = defaultName;
73
		this.domain = repositoryName;
74
		this.message = message;
75
		this.defaultAllowCaching = defaultAllowCaching;
76
	}
77
78
	/**
79
	 * @see Window#configureShell
80
	 */
81
	protected void configureShell(Shell newShell) {
82
		super.configureShell(newShell);
83
		newShell.setText("Password Required");
84
	}
85
86
	/**
87
	 * @see Window#create
88
	 */
89
	public void create() {
90
		super.create();
91
		// add some default values
92
		usernameField.setText(defaultUsername);
93
		allowCachingButton.setSelection(defaultAllowCaching);		
94
95
		// give focus to user name field
96
		usernameField.selectAll();
97
		usernameField.setFocus();
98
	}
99
100
	/**
101
	 * @see Dialog#createDialogArea
102
	 */
103
	protected Control createDialogArea(Composite parent) {
104
		Composite top = new Composite(parent, SWT.NONE);
105
		GridLayout layout = new GridLayout();
106
		layout.numColumns = 2;
107
108
		top.setLayout(layout);
109
		top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
110
111
		Composite imageComposite = new Composite(top, SWT.NONE);
112
		layout = new GridLayout();
113
		imageComposite.setLayout(layout);
114
		imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
115
116
		Composite main = new Composite(top, SWT.NONE);
117
		layout = new GridLayout();
118
		layout.numColumns = 3;
119
		main.setLayout(layout);
120
		main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
121
122
		Label imageLabel = new Label(imageComposite, SWT.NONE);
123
		keyLockImage = TasksUiPlugin.imageDescriptorFromPlugin(TasksUiPlugin.ID_PLUGIN, "icons/wizban/keylock.gif")
124
				.createImage();
125
		imageLabel.setImage(keyLockImage);
126
		GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
127
		imageLabel.setLayoutData(data);
128
129
		if (message != null) {
130
			Label messageLabel = new Label(main, SWT.WRAP);
131
			messageLabel.setText(message);
132
			data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
133
			data.horizontalSpan = 3;
134
			data.widthHint = 300;
135
			messageLabel.setLayoutData(data);
136
		}
137
		if (domain != null) {
138
			Label d = new Label(main, SWT.WRAP);
139
			d.setText("Task Repository:");
140
			data = new GridData();
141
			d.setLayoutData(data);
142
			Label label = new Label(main, SWT.WRAP);
143
			label.setText(domain);
144
			data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
145
			data.horizontalSpan = 2;
146
			data.widthHint = 300;
147
			label.setLayoutData(data);
148
		}
149
		createUsernameFields(main);
150
		createPasswordFields(main);
151
152
		if (domain != null) {
153
			allowCachingButton = new Button(main, SWT.CHECK);
154
			allowCachingButton.setText("&Save password");
155
			data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
156
			data.horizontalSpan = 3;
157
			allowCachingButton.setLayoutData(data);
158
			allowCachingButton.addSelectionListener(new SelectionAdapter() {
159
				public void widgetSelected(SelectionEvent e) {
160
					allowCaching = allowCachingButton.getSelection();
161
				}
162
			});
163
			Composite warningComposite = new Composite(main, SWT.NONE);
164
			layout = new GridLayout();
165
			layout.numColumns = 2;
166
			layout.marginHeight = 0;
167
			layout.marginHeight = 0;
168
			warningComposite.setLayout(layout);
169
			data = new GridData(GridData.FILL_HORIZONTAL);
170
			data.horizontalSpan = 3;
171
			warningComposite.setLayoutData(data);
172
			Label warningLabel = new Label(warningComposite, SWT.NONE);
173
			warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING));
174
			warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING
175
					| GridData.HORIZONTAL_ALIGN_BEGINNING));
176
			Label warningText = new Label(warningComposite, SWT.WRAP);
177
			warningText.setText("Saved passwords are stored on your computer in a file that is difficult, but not impossible, for an intruder to read.");
178
			data = new GridData(GridData.FILL_HORIZONTAL);
179
			data.widthHint = 300;
180
			warningText.setLayoutData(data);
181
		}
182
183
		Dialog.applyDialogFont(parent);
184
185
		return main;
186
	}
187
188
	/**
189
	 * Creates the three widgets that represent the password entry area.
190
	 * 
191
	 * @param parent  the parent of the widgets
192
	 */
193
	protected void createPasswordFields(Composite parent) {
194
		new Label(parent, SWT.NONE).setText("&Password:");
195
196
		passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD);
197
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
198
		data.horizontalSpan = 2;
199
		data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
200
		passwordField.setLayoutData(data);
201
	}
202
203
	/**
204
	 * Creates the three widgets that represent the user name entry area.
205
	 * 
206
	 * @param parent  the parent of the widgets
207
	 */
208
	protected void createUsernameFields(Composite parent) {
209
		new Label(parent, SWT.NONE).setText("&User name:");
210
211
		usernameField = new Text(parent, SWT.BORDER);
212
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
213
		data.horizontalSpan = 2;
214
		data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
215
		usernameField.setLayoutData(data);
216
	}
217
218
	/**
219
	 * Returns the password entered by the user, or null
220
	 * if the user canceled.
221
	 * 
222
	 * @return the entered password
223
	 */
224
	public String getPassword() {
225
		return password;
226
	}
227
228
	/**
229
	 * Returns the user name entered by the user, or null
230
	 * if the user canceled.
231
	 * 
232
	 * @return the entered user name
233
	 */
234
	public String getUsername() {
235
		return username;
236
	}
237
238
	/**
239
	 * Returns <code>true</code> if the save password checkbox was selected.
240
	 * @return <code>true</code> if the save password checkbox was selected and <code>false</code>
241
	 * otherwise.
242
	 */
243
	public boolean getAllowCaching() {
244
		return allowCaching;
245
	}
246
247
	/**
248
	 * Notifies that the ok button of this dialog has been pressed.
249
	 * <p>
250
	 * The default implementation of this framework method sets
251
	 * this dialog's return code to <code>Window.OK</code>
252
	 * and closes the dialog. Subclasses may override.
253
	 * </p>
254
	 */
255
	protected void okPressed() {
256
		password = passwordField.getText();
257
		username = usernameField.getText();
258
259
		super.okPressed();
260
	}
261
262
	protected void cancelPressed() {
263
		password = null;
264
		username = null;
265
		super.cancelPressed();
266
	}
267
268
	/* (non-Javadoc)
269
	 * @see org.eclipse.jface.dialogs.Dialog#close()
270
	 */
271
	public boolean close() {
272
		if (keyLockImage != null) {
273
			keyLockImage.dispose();
274
		}
275
		return super.close();
276
	}
277
}
(-)src/org/eclipse/mylyn/tasks/core/TaskRepository.java (-2 / +44 lines)
Lines 73-78 Link Here
73
73
74
	public static final String OFFLINE = "org.eclipse.mylyn.tasklist.repositories.offline";
74
	public static final String OFFLINE = "org.eclipse.mylyn.tasklist.repositories.offline";
75
75
76
	public static final String MEMORYONLY_PASSWORD = "org.eclipse.mylyn.tasklist.repositories.memoryonly.password";
77
76
	// HACK: Lock used to work around race condition in
78
	// HACK: Lock used to work around race condition in
77
	// Platform.add/get/flushAuthorizationInfo()
79
	// Platform.add/get/flushAuthorizationInfo()
78
	private static final Object LOCK = new Object();
80
	private static final Object LOCK = new Object();
Lines 83-88 Link Here
83
	private boolean isCachedUserName;
85
	private boolean isCachedUserName;
84
86
85
	private String cachedUserName;
87
	private String cachedUserName;
88
	
89
	private boolean isCachedUserPassword;
90
91
	private String cachedUserPassword;
86
92
87
	static {
93
	static {
88
		URL url = null;
94
		URL url = null;
Lines 169-174 Link Here
169
	}
175
	}
170
176
171
	public String getPassword() {
177
	public String getPassword() {
178
		if (!isCachedUserPassword) {
179
			if (isMemoryOnlyPassword()) {
180
				StatusHandler.log("Memoryonly Password not set for repository "+ this.getRepositoryLabel(), this);
181
				cachedUserPassword = "";
182
			} else {
183
				cachedUserPassword = getUserPasswordFromKeyRing();
184
				isCachedUserPassword = true;
185
			}
186
		}
187
		return cachedUserPassword;
188
	}
189
190
	private String getUserPasswordFromKeyRing() {
172
		return getAuthInfo(AUTH_PASSWORD);
191
		return getAuthInfo(AUTH_PASSWORD);
173
	}
192
	}
174
193
Lines 188-197 Link Here
188
		return getAuthInfo(AUTH_HTTP_PASSWORD);
207
		return getAuthInfo(AUTH_HTTP_PASSWORD);
189
	}
208
	}
190
209
191
	public void setAuthenticationCredentials(String username, String password) {
210
	public void setAuthenticationCredentials(String username, String password, boolean storeInKeyring) {
192
		setCredentials(username, password, AUTH_USERNAME, AUTH_PASSWORD);
211
		if (storeInKeyring) {
212
			setCredentials(username, password, AUTH_USERNAME, AUTH_PASSWORD);
213
		} else {
214
			setCredentials(username, "", AUTH_USERNAME, AUTH_PASSWORD);
215
		}
193
		cachedUserName = username;
216
		cachedUserName = username;
194
		isCachedUserName = true;
217
		isCachedUserName = true;
218
		cachedUserPassword = password;
219
		isCachedUserPassword = true;
195
	}
220
	}
196
221
197
	public void setProxyAuthenticationCredentials(String username, String password) {
222
	public void setProxyAuthenticationCredentials(String username, String password) {
Lines 231-236 Link Here
231
					headlessCreds.clear();
256
					headlessCreds.clear();
232
				}
257
				}
233
				isCachedUserName = false;
258
				isCachedUserName = false;
259
				isCachedUserPassword = false;
234
			} catch (CoreException e) {
260
			} catch (CoreException e) {
235
				StatusHandler.fail(e, "could not flush authorization credentials", true);
261
				StatusHandler.fail(e, "could not flush authorization credentials", true);
236
			}
262
			}
Lines 467-470 Link Here
467
		return getProperty(OFFLINE) != null && "true".equals(getProperty(OFFLINE));
493
		return getProperty(OFFLINE) != null && "true".equals(getProperty(OFFLINE));
468
	}
494
	}
469
495
496
	public String getCachedPassword() {
497
		if (isCachedUserPassword)
498
			return cachedUserPassword;
499
		else
500
			return null;
501
	}
502
503
	public void setMemoryOnlyPassword(boolean b) {
504
		properties.put(MEMORYONLY_PASSWORD, String.valueOf(b));
505
	}
506
507
	public boolean isMemoryOnlyPassword() {
508
		return getProperty(MEMORYONLY_PASSWORD) != null && "true".equals(getProperty(MEMORYONLY_PASSWORD));
509
	}
510
511
470
}
512
}
(-)src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java (-1 / +1 lines)
Lines 346-352 Link Here
346
		manager.getTaskList().addTask(mockTask);
346
		manager.getTaskList().addTask(mockTask);
347
		mockTask.setCompleted(true);
347
		mockTask.setCompleted(true);
348
		mockTask.setCompletionDate(new Date());
348
		mockTask.setCompletionDate(new Date());
349
		repository.setAuthenticationCredentials("testUser", "testPassword");
349
		repository.setAuthenticationCredentials("testUser", "testPassword", true);
350
		mockTask.setOwner("testUser");
350
		mockTask.setOwner("testUser");
351
		assertTrue(manager.isCompletedToday(mockTask));
351
		assertTrue(manager.isCompletedToday(mockTask));
352
352
(-)src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java (-1 / +1 lines)
Lines 175-181 Link Here
175
		TaskRepository repository = new TaskRepository("eclipse.technology.mylar",
175
		TaskRepository repository = new TaskRepository("eclipse.technology.mylar",
176
				"nntp://news.eclipse.org/eclipse.technology.mylar");
176
				"nntp://news.eclipse.org/eclipse.technology.mylar");
177
177
178
		repository.setAuthenticationCredentials("testUser", "testPassword");
178
		repository.setAuthenticationCredentials("testUser", "testPassword", true);
179
179
180
		assertEquals("testUser", repository.getUserName());
180
		assertEquals("testUser", repository.getUserName());
181
		assertEquals("testPassword", repository.getPassword());
181
		assertEquals("testPassword", repository.getPassword());

Return to bug 200634