Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-05-13 12:01:33 -0400
committerjames2002-05-13 12:01:33 -0400
commitb3b4770ab1143056468f773e5c152f2777f57bc6 (patch)
tree725971cf46962bbf086d12a2f6fe8c123a214ff1 /bundles/org.eclipse.team.cvs.ui
parent5d62f2f3cefe6da013bf3ce193e265d8c84d1183 (diff)
downloadeclipse.platform.team-b3b4770ab1143056468f773e5c152f2777f57bc6.tar.gz
eclipse.platform.team-b3b4770ab1143056468f773e5c152f2777f57bc6.tar.xz
eclipse.platform.team-b3b4770ab1143056468f773e5c152f2777f57bc6.zip
Alternate password prompter integration
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java82
1 files changed, 75 insertions, 7 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
index 744e38a63..f132d525f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java
@@ -1,10 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2002 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM - Initial implementation
+ ******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
@@ -13,8 +18,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.IFileTypeInfo;
+import org.eclipse.team.core.IIgnoreInfo;
+import org.eclipse.team.core.Team;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IUserAuthenticator;
@@ -25,18 +34,39 @@ import org.eclipse.team.internal.ccvs.core.IUserInfo;
* and stores the results in the Platform's authentication keyring.
*/
public class WorkbenchUserAuthenticator implements IUserAuthenticator {
-
+ public static boolean USE_ALTERNATE_PROMPTER = false;
+
/**
* WorkbenchUserAuthenticator constructor.
*/
public WorkbenchUserAuthenticator() {
super();
+ // Initialize USE_ALTERNATE_PROMPTER
+ IIgnoreInfo[] ignores = Team.getAllIgnores();
+ boolean found = false;
+ for (int i = 0; i < ignores.length; i++) {
+ if (ignores[i].getPattern().equals("*.notes")) { //$NON-NLS-1$
+ found = true;
+ }
+ }
+ if (!found) return;
+ IFileTypeInfo[] types = Team.getAllTypes();
+ for (int i = 0; i < types.length; i++) {
+ if (types[i].getExtension().equals("notes")) { //$NON-NLS-1$
+ USE_ALTERNATE_PROMPTER = true;
+ return;
+ }
+ }
+ USE_ALTERNATE_PROMPTER = false;
}
/**
* @see IUserAuthenticator#authenticateUser
*/
public void promptForUserInfo(final ICVSRepositoryLocation location, final IUserInfo userinfo, final String message) throws CVSException {
-
+ if (!userinfo.isUsernameMutable() && USE_ALTERNATE_PROMPTER) {
+ alternatePromptForUserInfo(userinfo);
+ return;
+ }
// ask the user for a password
final String[] result = new String[2];
Display display = Display.getCurrent();
@@ -83,4 +113,42 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator {
result[0] = dialog.getUsername();
result[1] = dialog.getPassword();
}
+
+ /**
+ * Special alternate prompting. Returns the password. Username must be fixed.
+ */
+ private String alternatePromptForPassword(final String username) {
+ Display display = Display.getCurrent();
+ Shell shell = new Shell(display);
+ AlternateUserValidationDialog dialog = new AlternateUserValidationDialog(shell, (username == null) ? "" : username); //$NON-NLS-1$
+ dialog.setUsername(username);
+ int result = dialog.open();
+ shell.dispose();
+ if (result == Dialog.CANCEL) return null;
+ return dialog.getPassword();
+ }
+ /**
+ * Special alternate prompting.
+ */
+ public void alternatePromptForUserInfo(final IUserInfo userinfo) throws CVSException {
+ // ask the user for a password
+ final String[] result = new String[1];
+ Display display = Display.getCurrent();
+ if (display != null) {
+ result[0] = alternatePromptForPassword(userinfo.getUsername());
+ } else {
+ // sync exec in default thread
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ result[0] = alternatePromptForPassword(userinfo.getUsername());
+ }
+ });
+ }
+
+ if (result[0] == null) {
+ throw new OperationCanceledException(Policy.bind("WorkbenchUserAuthenticator.The_operation_was_canceled_by_the_user_1")); //$NON-NLS-1$
+ }
+
+ userinfo.setPassword(result[0]);
+ }
}

Back to the top