aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Weninger2013-03-28 02:37:12 (EDT)
committerUwe Stieber2013-03-28 02:37:12 (EDT)
commit9f28fd160e04c277307f7807c743031f84f3a681 (patch)
tree70fef584c6dbedebd1a0c52d3399b132ae67a644
parent47953ad492844481c55776d72892a0f9d3705ef4 (diff)
downloadorg.eclipse.tcf-9f28fd160e04c277307f7807c743031f84f3a681.zip
org.eclipse.tcf-9f28fd160e04c277307f7807c743031f84f3a681.tar.gz
org.eclipse.tcf-9f28fd160e04c277307f7807c743031f84f3a681.tar.bz2
Target Explorer: Add "Save Password" checkbox to allow the user to decide if the password shall be saved or not
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties3
3 files changed, 56 insertions, 7 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
index 71479cd..ef2f3c9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
@@ -22,14 +22,17 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TypedEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tcf.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer;
import org.eclipse.tcf.te.ui.terminals.panels.AbstractConfigurationPanel;
+import org.eclipse.tcf.te.ui.terminals.ssh.nls.Messages;
import org.eclipse.tm.internal.terminal.provisional.api.AbstractSettingsPage;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
import org.eclipse.tm.internal.terminal.ssh.SshConnector;
@@ -42,8 +45,11 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
@SuppressWarnings("restriction")
public class SshWizardConfigurationPanel extends AbstractConfigurationPanel implements IDataExchangeNode {
+ private static final String SAVE_PASSWORD = "savePassword"; //$NON-NLS-1$
+
private SshSettings sshSettings;
private ISettingsPage sshSettingsPage;
+ private Button passwordButton;
/**
* Constructor.
@@ -92,6 +98,9 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
// Create the encoding selection combo
createEncodingUI(panel, true);
+ // if password for host should be saved or no
+ createPasswordUI(panel, true);
+
setControl(panel);
}
@@ -169,6 +178,7 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
*/
@Override
protected void fillSettingsForHost(String host){
+ boolean savePassword = false;
if (host != null && host.length() != 0){
if (hostSettingsMap.containsKey(host)){
Map<String, String> hostSettings = hostSettingsMap.get(host);
@@ -187,9 +197,16 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
if (hostSettings.get(ITerminalsConnectorConstants.PROP_SSH_USER) != null) {
sshSettings.setUser(hostSettings.get(ITerminalsConnectorConstants.PROP_SSH_USER));
}
- String password = accessSecurePassword(sshSettings.getHost());
- if (password != null) {
- sshSettings.setPassword(password);
+ if (hostSettings.get(SAVE_PASSWORD) != null) {
+ savePassword = new Boolean(hostSettings.get(SAVE_PASSWORD)).booleanValue();
+ }
+ if (!savePassword){
+ sshSettings.setPassword(""); //$NON-NLS-1$
+ } else {
+ String password = accessSecurePassword(sshSettings.getHost());
+ if (password != null) {
+ sshSettings.setPassword(password);
+ }
}
String encoding = hostSettings.get(ITerminalsConnectorConstants.PROP_ENCODING);
@@ -198,9 +215,11 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
} else {
sshSettings.setHost(getSelectionHost());
sshSettings.setUser(getDefaultUser());
+ savePassword = false;
}
// set settings in page
sshSettingsPage.loadSettings();
+ passwordButton.setSelection(savePassword);
}
}
@@ -218,6 +237,7 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
*/
@Override
protected void saveSettingsForHost(boolean add){
+ boolean savePassword = passwordButton.getSelection();
String host = getHostFromSettings();
if (host != null && host.length() != 0) {
if (hostSettingsMap.containsKey(host)){
@@ -228,10 +248,16 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
+ hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
- if (sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
+ if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
saveSecurePassword(host, sshSettings.getPassword());
}
+
+ // maybe unchecked the password button - so try to remove a saved password - if any
+ if (!savePassword){
+ removeSecurePassword(host);
+ }
} else if (add) {
Map<String, String> hostSettings = new HashMap<String, String>();
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
@@ -240,9 +266,10 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
hostSettings.put(ITerminalsConnectorConstants.PROP_ENCODING, getEncoding());
+ hostSettings.put(SAVE_PASSWORD, Boolean.toString(savePassword));
hostSettingsMap.put(host, hostSettings);
- if (sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
+ if (savePassword && sshSettings.getPassword() != null && sshSettings.getPassword().length() != 0){
saveSecurePassword(host, sshSettings.getPassword());
}
}
@@ -337,4 +364,24 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
sshSettingsPage.saveSettings();
return sshSettings.getHost();
}
+
+ private void createPasswordUI(final Composite parent, boolean separator) {
+ Assert.isNotNull(parent);
+
+ if (separator) {
+ Label sep = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
+
+ Composite panel = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ passwordButton = new Button(panel, SWT.CHECK);
+ passwordButton.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, true, false));
+ passwordButton.setText(Messages.SshWizardConfigurationPanel_savePasword);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java
index 0a3133d..5f57cd5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -32,4 +32,5 @@ public class Messages extends NLS {
public static String SshLauncherDelegate_terminalTitle;
public static String SshLauncherDelegate_terminalTitle_default;
+ public static String SshWizardConfigurationPanel_savePasword;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties
index 15c4296..c2d6e5b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/nls/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+# Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved.
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License v1.0 which accompanies this distribution, and is
# available at http://www.eclipse.org/legal/epl-v10.html
@@ -10,3 +10,4 @@
SshLauncherDelegate_terminalTitle=SSH {0}@{1} ({2})
SshLauncherDelegate_terminalTitle_default=SSH Terminal
+SshWizardConfigurationPanel_savePasword=Save password