Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-04-14 16:36:39 +0000
committerJean Michel-Lemieux2004-04-14 16:36:39 +0000
commit33efc21049605ec29f12723ee3d2834377c227a2 (patch)
tree62f6d06fac6f3714a76839d5f4c82afc7aa17d68
parente27118c70d1d96e3c6d13c92a37b00424b2b3a2f (diff)
downloadeclipse.platform.team-33efc21049605ec29f12723ee3d2834377c227a2.tar.gz
eclipse.platform.team-33efc21049605ec29f12723ee3d2834377c227a2.tar.xz
eclipse.platform.team-33efc21049605ec29f12723ee3d2834377c227a2.zip
Allows users to determine if password caching should be enabled. And users
can manage saved passwords.
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java23
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java21
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java10
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.properties3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java204
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java111
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java27
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties16
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java36
11 files changed, 414 insertions, 48 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
index c0f0e4325..6ef1b2496 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation.java
@@ -85,7 +85,7 @@ public interface ICVSRepositoryLocation extends IAdaptable {
* encoding for commit comments.
*/
public String getEncoding();
-
+
/**
* Return the conection timeout value in milliseconds.
* A value of 0 means there is no timeout value.
@@ -116,6 +116,27 @@ public interface ICVSRepositoryLocation extends IAdaptable {
public void validateConnection(IProgressMonitor monitor) throws CVSException;
/**
+ * Set the option to allow the user settings to be cached between sessions.
+ * @since 3.0
+ */
+ public void setAllowCaching(boolean allowCaching);
+
+ /**
+ * Returns if the user info for this location is cached
+ */
+ public boolean getUserInfoCached();
+
+ /**
+ * Sets the user information used for this location
+ */
+ public void setUsername(String username);
+
+ /**
+ * Sets the user information used for this location
+ */
+ public void setPassword(String password);
+
+ /**
* Returns the plugged-in authenticator for this location.
* @since 3.0
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
index c22daabd8..304c62ff6 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation.java
@@ -82,6 +82,7 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit
private String root;
private boolean userFixed;
private boolean passwordFixed;
+ private boolean allowCaching;
private int serverPlatform = UNDETERMINED_PLATFORM;
@@ -756,7 +757,6 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit
throw new CVSAuthenticationException(Policy.bind("Client.noAuthenticator"), CVSAuthenticationException.NO_RETRY);//$NON-NLS-1$
}
authenticator.promptForUserInfo(this, this, message);
- updateCache();
} else {
throw ex;
}
@@ -827,9 +827,14 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit
userFixed = !muteable;
}
+ public void setAllowCaching(boolean value) {
+ allowCaching = value;
+ updateCache();
+ }
+
public void updateCache() {
// Nothing to cache if the password is fixed
- if (passwordFixed) return;
+ if (passwordFixed || ! allowCaching) return;
// Nothing to cache if the password is null and the user is fixed
if (password == null && userFixed) return;
if (updateCache(user, password)) {
@@ -1197,4 +1202,16 @@ public class CVSRepositoryLocation extends PlatformObject implements ICVSReposit
storePreferences();
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation#getUserInfoCached()
+ */
+ public boolean getUserInfoCached() {
+ Map map = Platform.getAuthorizationInfo(FAKE_URL, getLocation(), AUTH_SCHEME);
+ if (map != null) {
+ String password = (String) map.get(INFO_PASSWORD);
+ return (password != null);
+ }
+ return false;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java
index eb989c8ac..8a699d5e9 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/KnownRepositories.java
@@ -92,7 +92,7 @@ public class KnownRepositories {
// Check the cache for an equivalent instance and if there is one, just update the cache
CVSRepositoryLocation existingLocation = internalGetRepository(repository.getLocation());
if (existingLocation == null) {
- // Store the location and cache the password
+ // Store the location
store((CVSRepositoryLocation)repository);
existingLocation = (CVSRepositoryLocation)repository;
}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java
index 6f0e35e8c..821550214 100644
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java
+++ b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java
@@ -73,7 +73,6 @@ public class CVSSSH2PreferencePage extends PreferencePage
private Text privateKeyText;
private Button enableProxy;
private Button enableAuth;
- private Button enableSSH2;
private Button privateKeyAdd;
private boolean useProxy;
private boolean useAuth;
@@ -152,12 +151,6 @@ public class CVSSSH2PreferencePage extends PreferencePage
data.horizontalAlignment = GridData.FILL;
group.setLayoutData(data);
- enableSSH2=new Button(group, SWT.CHECK);
- enableSSH2.setText(Policy.bind("CVSSSH2PreferencePage.22")); //$NON-NLS-1$
- GridData gd=new GridData();
- gd.horizontalSpan=3;
- enableSSH2.setLayoutData(gd);
-
createSpacer(group, 3);
ssh2HomeLabel=new Label(group, SWT.NONE);
@@ -165,7 +158,7 @@ public class CVSSSH2PreferencePage extends PreferencePage
ssh2HomeText=new Text(group, SWT.SINGLE | SWT.BORDER);
ssh2HomeText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
+ GridData gd=new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan=1;
ssh2HomeText.setLayoutData(gd);
@@ -175,7 +168,6 @@ public class CVSSSH2PreferencePage extends PreferencePage
gd.horizontalSpan=1;
ssh2HomeBrowse.setLayoutData(gd);
-
createSpacer(group, 3);
privateKeyLabel=new Label(group, SWT.NONE);
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties
index 86115e18b..e6e5b2fcc 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.properties
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties
@@ -205,4 +205,5 @@ CVSRemoteQuickDiffProvider.label=&Latest CVS Revision
NewDateTagAction.label=&Date Tag...
NewDateTagAction.tooltip=Add new date tag
-newProjectCheckoutWizardDescription=Create a new project by checking out an existing project from a CVS repository. \ No newline at end of file
+newProjectCheckoutWizardDescription=Create a new project by checking out an existing project from a CVS repository.
+PasswordManagement=Password Management \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index e78d6812f..67efd50db 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -885,6 +885,15 @@
id="org.eclipse.team.cvs.ui.WatchEditPreferencePage">
</page>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ name="%PasswordManagement"
+ category="org.eclipse.team.cvs.ui.CVSPreferences"
+ class="org.eclipse.team.internal.ccvs.ui.PasswordManagementPreferencePage"
+ id="org.eclipse.team.cvs.ui.PasswordManagementPreferencePage">
+ </page>
+ </extension>
<!-- **************** Decorator ******************* -->
<extension
point="org.eclipse.ui.decorators">
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java
new file mode 100644
index 000000000..bfc21dd95
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/PasswordManagementPreferencePage.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui;
+
+import java.util.*;
+import java.util.List;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class PasswordManagementPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+ private TableViewer viewer;
+ private Button removeButton;
+ private Button removeAllButton;
+
+ class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object element, int columnIndex) {
+ ICVSRepositoryLocation entry = (ICVSRepositoryLocation)element;
+ switch (columnIndex) {
+ case 0:
+ return entry.toString();
+ case 1:
+ return entry.getUsername();
+ default:
+ return null;
+ }
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ };
+
+ public void init(IWorkbench workbench) {
+ setDescription(Policy.bind("PasswordManagementPreferencePage.2")); //$NON-NLS-1$
+ }
+
+ /**
+ * Creates preference page controls on demand.
+ *
+ * @param parent the parent for the preference page
+ */
+ protected Control createContents(Composite ancestor) {
+
+ Composite parent = new Composite(ancestor, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.numColumns = 2;
+ parent.setLayout(layout);
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ parent.setLayoutData(data);
+
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ Table table = viewer.getTable();
+ new TableEditor(table);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = convertWidthInCharsToPixels(30);
+ /*
+ * The hardcoded hint does not look elegant, but in reality
+ * it does not make anything bound to this 100-pixel value,
+ * because in any case the tree on the left is taller and
+ * that's what really determines the height.
+ */
+ gd.heightHint = 100;
+ table.setLayoutData(gd);
+ table.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ handleSelection();
+ }
+ });
+ // Create the table columns
+ new TableColumn(table, SWT.NULL);
+ new TableColumn(table, SWT.NULL);
+ TableColumn[] columns = table.getColumns();
+ columns[0].setText(Policy.bind("PasswordManagementPreferencePage.3")); //$NON-NLS-1$
+ columns[1].setText(Policy.bind("PasswordManagementPreferencePage.4")); //$NON-NLS-1$
+
+ viewer.setColumnProperties(new String[] {"location", "username"}); //$NON-NLS-1$ //$NON-NLS-2$
+ viewer.setLabelProvider(new TableLabelProvider());
+ viewer.setContentProvider(new IStructuredContentProvider() {
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public Object[] getElements(Object inputElement) {
+ if (inputElement == null) return null;
+ ICVSRepositoryLocation[] locations = ((KnownRepositories)inputElement).getRepositories();
+ List repos = new ArrayList();
+ for (int i = 0; i < locations.length; i++) {
+ ICVSRepositoryLocation l = locations[i];
+ if(l.getUserInfoCached())
+ repos.add(l);
+ }
+ return (ICVSRepositoryLocation[]) repos.toArray(new ICVSRepositoryLocation[repos.size()]);
+ }
+ });
+ TableLayout tl = new TableLayout();
+ tl.addColumnData(new ColumnWeightData(50));
+ tl.addColumnData(new ColumnWeightData(50));
+ table.setLayout(tl);
+
+ Composite buttons = new Composite(parent, SWT.NULL);
+ buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ buttons.setLayout(layout);
+
+ removeButton = new Button(buttons, SWT.PUSH);
+ removeButton.setText(Policy.bind("PasswordManagementPreferencePage.5")); //$NON-NLS-1$
+ data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ removeButton.setLayoutData(data);
+ removeButton.setEnabled(false);
+ removeButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ remove();
+ }
+ });
+ removeAllButton = new Button(buttons, SWT.PUSH);
+ removeAllButton.setText(Policy.bind("PasswordManagementPreferencePage.6")); //$NON-NLS-1$
+ data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
+ widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ data.widthHint = Math.max(widthHint, removeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ removeAllButton.setLayoutData(data);
+ removeAllButton.setEnabled(true);
+ removeAllButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ removeAll();
+ }
+ });
+ Dialog.applyDialogFont(ancestor);
+ viewer.setInput(KnownRepositories.getInstance());
+ handleSelection();
+ return parent;
+ }
+
+ public boolean performOk() {
+ return true;
+ }
+
+ protected void performDefaults() {
+ super.performDefaults();
+ }
+
+ private void remove() {
+ IStructuredSelection s = (IStructuredSelection)viewer.getSelection();
+ for (Iterator it = s.iterator(); it.hasNext();) {
+ ICVSRepositoryLocation location = (ICVSRepositoryLocation) it.next();
+ location.flushUserInfo();
+ }
+ viewer.refresh();
+ handleSelection();
+ }
+
+ private void removeAll() {
+ ICVSRepositoryLocation[] locations = KnownRepositories.getInstance().getRepositories();
+ List repos = new ArrayList();
+ for (int i = 0; i < locations.length; i++) {
+ ICVSRepositoryLocation l = locations[i];
+ if(l.getUserInfoCached())
+ l.flushUserInfo();
+ }
+ viewer.refresh();
+ handleSelection();
+ }
+
+ private void handleSelection() {
+ if (viewer.getTable().getSelectionCount() > 0) {
+ removeButton.setEnabled(true);
+ } else {
+ removeButton.setEnabled(false);
+ }
+ removeAllButton.setEnabled(viewer.getTable().getItemCount() > 0);
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java
index 42ae4378f..3c587adff 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java
@@ -13,14 +13,13 @@ package org.eclipse.team.internal.ccvs.ui;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.*;
import org.eclipse.ui.help.WorkbenchHelp;
/**
@@ -30,13 +29,16 @@ public class UserValidationDialog extends Dialog {
// widgets
protected Text usernameField;
protected Text passwordField;
+ protected Button allowCachingButton;
protected String domain;
protected String defaultUsername;
protected String password = null;
+ protected boolean allowCaching = false;
// whether or not the username can be changed
protected boolean isUsernameMutable = true;
+ protected boolean showAllowCachingButton = true;
protected String username = null;
protected String message = null;
@@ -80,46 +82,109 @@ public class UserValidationDialog extends Dialog {
passwordField.setFocus();
}
}
+
/**
* @see Dialog#createDialogArea
*/
protected Control createDialogArea(Composite parent) {
- Composite main = new Composite(parent, SWT.NONE);
+ Composite top = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+
+ top.setLayout(layout);
+ top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite imageComposite = new Composite(top, SWT.NONE);
+ layout = new GridLayout();
+ imageComposite.setLayout(layout);
+ imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+
+ Composite main = new Composite(top, SWT.NONE);
+ layout = new GridLayout();
layout.numColumns = 3;
+ layout.marginHeight = 0;
+ layout.marginHeight = 0;
main.setLayout(layout);
main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
+ Label imageLabel = new Label(imageComposite, SWT.NONE);
+ imageLabel.setImage(getImage(DLG_IMG_INFO));
+ GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ imageLabel.setLayoutData(data);
+
if (message != null) {
Label messageLabel = new Label(main, SWT.WRAP);
messageLabel.setText(message);
- messageLabel.setForeground(messageLabel.getDisplay().getSystemColor(SWT.COLOR_RED));
- GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 3;
- data.widthHint = 400;
+ data.widthHint = 300;
messageLabel.setLayoutData(data);
}
-
if (domain != null) {
+ Label d = new Label(main, SWT.WRAP);
+ d.setText(Policy.bind("UserValidationDialog.5")); //$NON-NLS-1$
+ data = new GridData();
+ d.setLayoutData(data);
Label label = new Label(main, SWT.WRAP);
if (isUsernameMutable) {
label.setText(Policy.bind("UserValidationDialog.labelUser", domain)); //$NON-NLS-1$
} else {
label.setText(Policy.bind("UserValidationDialog.labelPassword", new Object[]{defaultUsername, domain})); //$NON-NLS-1$
}
- GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- data.horizontalSpan = 3;
- data.widthHint = 400;
+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan = 2;
+ data.widthHint = 300;
label.setLayoutData(data);
}
createUsernameFields(main);
createPasswordFields(main);
-
+
+ if(showAllowCachingButton) {
+ allowCachingButton = new Button(main, SWT.CHECK);
+ allowCachingButton.setText(Policy.bind("UserValidationDialog.6")); //$NON-NLS-1$
+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan = 3;
+ allowCachingButton.setLayoutData(data);
+ allowCachingButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ allowCaching = allowCachingButton.getSelection();
+ }
+ });
+ Composite warningComposite = new Composite(main, SWT.NONE);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginHeight = 0;
+ warningComposite.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 3;
+ warningComposite.setLayoutData(data);
+ Label warningLabel = new Label(warningComposite, SWT.NONE);
+ warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING));
+ warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Label warningText = new Label(warningComposite, SWT.WRAP);
+ warningText.setText(Policy.bind("UserValidationDialog.7")); //$NON-NLS-1$
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 300;
+ warningText.setLayoutData(data);
+ }
+
Dialog.applyDialogFont(parent);
return main;
}
/**
+ * Create a spacer.
+ */
+ protected void createSpacer(Composite top, int columnSpan, int vertSpan) {
+ Label l = new Label(top, SWT.NONE);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan = columnSpan;
+ data.verticalSpan = vertSpan;
+ l.setLayoutData(data);
+ }
+
+ /**
* Creates the three widgets that represent the password entry area.
*
* @param parent the parent of the widgets
@@ -147,6 +212,7 @@ public class UserValidationDialog extends Dialog {
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
usernameField.setLayoutData(data);
}
+
/**
* Returns the password entered by the user, or null
* if the user canceled.
@@ -156,6 +222,7 @@ public class UserValidationDialog extends Dialog {
public String getPassword() {
return password;
}
+
/**
* Returns the username entered by the user, or null
* if the user canceled.
@@ -165,6 +232,16 @@ public class UserValidationDialog extends Dialog {
public String getUsername() {
return username;
}
+
+ /**
+ * Returns <code>true</code> if the save password checkbox was selected.
+ * @return <code>true</code> if the save password checkbox was selected and <code>false</code>
+ * otherwise.
+ */
+ public boolean getAllowCaching() {
+ return allowCaching;
+ }
+
/**
* Notifies that the ok button of this dialog has been pressed.
* <p>
@@ -189,4 +266,8 @@ public class UserValidationDialog extends Dialog {
public void setUsernameMutable(boolean value) {
isUsernameMutable = value;
}
+
+ public void setShowAllowCachingButton(boolean value) {
+ showAllowCachingButton = value;
+ }
}
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 404eee644..c3559c86b 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
@@ -12,18 +12,11 @@
package org.eclipse.team.internal.ccvs.ui;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.*;
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;
-import org.eclipse.team.internal.ccvs.core.IUserInfo;
+import org.eclipse.team.core.*;
+import org.eclipse.team.internal.ccvs.core.*;
/**
* An authenticator that prompts the user for authentication info,
@@ -66,13 +59,14 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator {
// ask the user for a password
final String[] result = new String[2];
Display display = Display.getCurrent();
+ final boolean allowCaching[] = {false};
if (display != null) {
- promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
+ allowCaching[0] = promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
} else {
// sync exec in default thread
Display.getDefault().syncExec(new Runnable() {
public void run() {
- promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
+ allowCaching[0] = promptForPassword(location, userinfo.getUsername(), message, userinfo.isUsernameMutable(), result);
}
});
}
@@ -81,9 +75,13 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator {
throw new OperationCanceledException(Policy.bind("WorkbenchUserAuthenticator.cancelled")); //$NON-NLS-1$
}
- if (userinfo.isUsernameMutable())
+ if (userinfo.isUsernameMutable()) {
userinfo.setUsername(result[0]);
+ location.setUsername(result[0]);
+ }
userinfo.setPassword(result[1]);
+ location.setPassword(result[1]);
+ location.setAllowCaching(allowCaching[0]);
}
/**
@@ -98,7 +96,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator {
* @param userMutable whether the user can be changed in the dialog
* @param result a String array of length two in which to put the result
*/
- private void promptForPassword(final ICVSRepositoryLocation location, final String username, final String message, final boolean userMutable, final String[] result) {
+ private boolean promptForPassword(final ICVSRepositoryLocation location, final String username, final String message, final boolean userMutable, final String[] result) {
Display display = Display.getCurrent();
Shell shell = new Shell(display);
String domain = location == null ? null : location.getLocation();
@@ -109,6 +107,7 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator {
result[0] = dialog.getUsername();
result[1] = dialog.getPassword();
+ return dialog.getAllowCaching();
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index ad0b152f4..2eec0044b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -8,6 +8,14 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
+PasswordManagementPreferencePage.2=When you create a CVS repository location you have the option of saving the password to disk. This page allows you to manage the stored passwords. The following CVS repository locations have saved passwords:
+PasswordManagementPreferencePage.3=Location
+PasswordManagementPreferencePage.4=Username
+PasswordManagementPreferencePage.5=&Remove
+PasswordManagementPreferencePage.6=Remove &All
+UserValidationDialog.5=CVS Repository:
+UserValidationDialog.6=&Save Password
+UserValidationDialog.7=Saved passwords are not secure when saved to disk. To protect the security of your passwords and data, use SSH key pairs for authentication or don't save the password.
details=Press the details button for more information.
simpleInternal=Internal error
internal=An internal error has occurred, consult the error log for details.
@@ -625,10 +633,10 @@ UpdateWizardPage.description=&Select a tag to update the project sharing to:
UpdateWizardPage.overwrite=&Overwrite local changes
UserValidationDialog.required=Password Required
-UserValidationDialog.labelUser=Enter a user name and password for the following repository: {0}
-UserValidationDialog.labelPassword=Enter a password for {0} in the following repository: {1}
-UserValidationDialog.password=Password:
-UserValidationDialog.user=User name:
+UserValidationDialog.labelUser={0}
+UserValidationDialog.labelPassword={1}
+UserValidationDialog.password=&Password:
+UserValidationDialog.user=&User name:
KeyboradInteractiveDialog.message=Keyboard Interactive authentication for {0}
KeyboardInteractiveDialog.labelRepository=Enter values for the following repository: {0}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java
index 81a6ba287..ed8ea5951 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardMainPage.java
@@ -13,13 +13,14 @@ package org.eclipse.team.internal.ccvs.ui.wizards;
import java.util.*;
import java.util.List;
-
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.team.internal.ccvs.core.*;
@@ -53,6 +54,9 @@ public class ConfigurationWizardMainPage extends CVSWizardPage {
private Combo repositoryPathCombo;
// Validation
private Button validateButton;
+ // Caching password
+ private Button allowCachingButton;
+ private boolean allowCaching = false;
private static final int COMBO_HISTORY_LENGTH = 5;
@@ -210,6 +214,35 @@ public class ConfigurationWizardMainPage extends CVSWizardPage {
});
}
+ allowCachingButton = new Button(composite, SWT.CHECK);
+ allowCachingButton.setText(Policy.bind("UserValidationDialog.6")); //$NON-NLS-1$
+ data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan = 3;
+ allowCachingButton.setLayoutData(data);
+ allowCachingButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ allowCaching = allowCachingButton.getSelection();
+ }
+ });
+
+ Composite warningComposite = new Composite(composite, SWT.NONE);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginHeight = 0;
+ warningComposite.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 3;
+ warningComposite.setLayoutData(data);
+ Label warningLabel = new Label(warningComposite, SWT.NONE);
+ warningLabel.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
+ warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Label warningText = new Label(warningComposite, SWT.WRAP);
+ warningText.setText(Policy.bind("UserValidationDialog.7")); //$NON-NLS-1$
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 300;
+ warningText.setLayoutData(data);
+
initializeValues();
updateWidgetEnablements();
hostCombo.setFocus();
@@ -273,6 +306,7 @@ public class ConfigurationWizardMainPage extends CVSWizardPage {
if (location == null) {
if (!isPageComplete()) return null;
location = CVSRepositoryLocation.fromProperties(createProperties());
+ location.setAllowCaching(allowCaching);
saveWidgetValues();
}
return location;

Back to the top