Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtsuhiko Yamanaka2013-10-24 04:31:50 -0400
committerSzymon Ptaszkiewicz2013-10-24 04:50:06 -0400
commit7e0b232400cb860bb566abe97003da0408e5e219 (patch)
tree480b5150c4b28bdaca27782ab4b8e53b74180b55
parentf8523030fcb891524f5cf6d7cf8d6573a0cea03a (diff)
downloadeclipse.platform.team-7e0b232400cb860bb566abe97003da0408e5e219.tar.gz
eclipse.platform.team-7e0b232400cb860bb566abe97003da0408e5e219.tar.xz
eclipse.platform.team-7e0b232400cb860bb566abe97003da0408e5e219.zip
Bug 407660 - Add JSch 0.1.50 to Platform
-rw-r--r--bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java8
-rw-r--r--bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java83
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java8
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties8
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java321
6 files changed, 418 insertions, 12 deletions
diff --git a/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF
index f32547728..a00bcfd6f 100644
--- a/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.jsch.internal.core.JSchCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
- com.jcraft.jsch;bundle-version="[0.1.28,1.0.0)",
+ com.jcraft.jsch;bundle-version="[0.1.50,1.0.0)",
org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.jsch.core,
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java
index 5ec77eb89..872c79b31 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation 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
@@ -54,4 +54,10 @@ public interface IConstants{
public static final String PREF_PREFERRED_AUTHENTICATION_METHODS="CVSSSH2PreferencePage.PREF_AUTH_METHODS"; //$NON-NLS-1$
public static final String PREF_PREFERRED_AUTHENTICATION_METHODS_ORDER="CVSSSH2PreferencePage.PREF_AUTH_METHODS_ORDER"; //$NON-NLS-1$
+
+ public static final String PREF_PREFERRED_KEYEXCHANGE_METHODS="CVSSSH2PreferencePage.PREF_KEX_METHODS"; //$NON-NLS-1$
+ public static final String PREF_PREFERRED_KEYEXCHANGE_METHODS_ORDER="CVSSSH2PreferencePage.PREF_KEX_METHODS_ORDER"; //$NON-NLS-1$
+
+ public static final String PREF_PREFERRED_MAC_METHODS="CVSSSH2PreferencePage.PREF_MAC_METHODS"; //$NON-NLS-1$
+ public static final String PREF_PREFERRED_MAC_METHODS_ORDER="CVSSSH2PreferencePage.PREF_MAC_METHODS_ORDER"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java
index 26d71ba22..08b547e8e 100644
--- a/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java
+++ b/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 IBM Corporation 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
@@ -38,9 +38,36 @@ public class Utils{
"gssapi-with-mic", "publickey", "password", "keyboard-interactive"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
public static String getDefaultAuthMethods(){
- String defaultValue = PREFERRED_AUTH_METHODS[0];
- for(int i = 1; i < PREFERRED_AUTH_METHODS.length; i++){
- defaultValue += "," + PREFERRED_AUTH_METHODS[i]; //$NON-NLS-1$
+ return getDefaultMethods(PREFERRED_AUTH_METHODS);
+ }
+
+ private static final String[] PREFERRED_KEX_METHODS=new String[] {
+ "diffie-hellman-group1-sha1", //$NON-NLS-1$
+ "diffie-hellman-group14-sha1", //$NON-NLS-1$
+ "diffie-hellman-group-exchange-sha1", //$NON-NLS-1$
+ "diffie-hellman-group-exchange-sha256" //$NON-NLS-1$
+ };
+
+ public static String getDefaultKEXMethods(){
+ return getDefaultMethods(PREFERRED_KEX_METHODS);
+ }
+
+ private static final String[] PREFERRED_MAC_METHODS=new String[] {
+ "hmac-md5", //$NON-NLS-1$
+ "hmac-sha1", //$NON-NLS-1$
+ "hmac-sha2-256", //$NON-NLS-1$
+ "hmac-sha1-96", //$NON-NLS-1$
+ "hmac-md5-96" //$NON-NLS-1$
+ };
+
+ public static String getDefaultMACMethods(){
+ return getDefaultMethods(PREFERRED_MAC_METHODS);
+ }
+
+ private static String getDefaultMethods(String[] methods){
+ String defaultValue = methods[0];
+ for(int i = 1; i < methods.length; i++){
+ defaultValue += "," + methods[i]; //$NON-NLS-1$
}
return defaultValue;
}
@@ -97,7 +124,13 @@ public class Utils{
setProxy(session);
Hashtable config=new Hashtable();
config.put("PreferredAuthentications", //$NON-NLS-1$
- getEnabledPreferredAuthMethods());
+ getEnabledPreferredAuthMethods());
+ config.put("kex", //$NON-NLS-1$
+ getEnabledPreferredKEXMethods());
+ config.put("mac.c2s", //$NON-NLS-1$
+ getEnabledPreferredMACMethods());
+ config.put("mac.s2c", //$NON-NLS-1$
+ getEnabledPreferredMACMethods());
session.setConfig(config);
return session;
}
@@ -226,5 +259,43 @@ public class Utils{
service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put(
IConstants.PREF_PREFERRED_AUTHENTICATION_METHODS_ORDER, order);}
-
+ public static String getEnabledPreferredKEXMethods(){
+ IPreferencesService service = Platform.getPreferencesService();
+ return service.getString(JSchCorePlugin.ID,
+ IConstants.PREF_PREFERRED_KEYEXCHANGE_METHODS, getDefaultKEXMethods(), null);
+ }
+
+ public static String getKEXMethodsOrder(){
+ IPreferencesService service = Platform.getPreferencesService();
+ return service.getString(JSchCorePlugin.ID,
+ IConstants.PREF_PREFERRED_KEYEXCHANGE_METHODS_ORDER, getDefaultKEXMethods(), null);
+ }
+
+ public static void setEnabledPreferredKEXMethods(String methods, String order){
+ IPreferencesService service=Platform.getPreferencesService();
+ service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put(
+ IConstants.PREF_PREFERRED_KEYEXCHANGE_METHODS, methods);
+ service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put(
+ IConstants.PREF_PREFERRED_KEYEXCHANGE_METHODS_ORDER, order);
+ }
+
+ public static String getEnabledPreferredMACMethods(){
+ IPreferencesService service = Platform.getPreferencesService();
+ return service.getString(JSchCorePlugin.ID,
+ IConstants.PREF_PREFERRED_MAC_METHODS, getDefaultMACMethods(), null);
+ }
+
+ public static String getMACMethodsOrder(){
+ IPreferencesService service = Platform.getPreferencesService();
+ return service.getString(JSchCorePlugin.ID,
+ IConstants.PREF_PREFERRED_MAC_METHODS_ORDER, getDefaultMACMethods(), null);
+ }
+
+ public static void setEnabledPreferredMACMethods(String methods, String order){
+ IPreferencesService service=Platform.getPreferencesService();
+ service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put(
+ IConstants.PREF_PREFERRED_MAC_METHODS, methods);
+ service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put(
+ IConstants.PREF_PREFERRED_MAC_METHODS_ORDER, order);
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java
index a0e1ba854..cfc1a61e5 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation 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
@@ -88,6 +88,12 @@ public class Messages extends NLS{
public static String CVSSSH2PreferencePage_137;
public static String CVSSSH2PreferencePage_138;
public static String CVSSSH2PreferencePage_139;
+ public static String CVSSSH2PreferencePage_140;
+ public static String CVSSSH2PreferencePage_141;
+ public static String CVSSSH2PreferencePage_142;
+ public static String CVSSSH2PreferencePage_143;
+ public static String CVSSSH2PreferencePage_144;
+ public static String CVSSSH2PreferencePage_145;
public static String KeyboardInteractiveDialog_0;
public static String KeyboardInteractiveDialog_1;
public static String KeyboardInteractiveDialog_2;
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties
index 243e9d953..e69fe1342 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2009 IBM Corporation and others.
+# Copyright (c) 2000, 2013 IBM Corporation 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
@@ -78,6 +78,12 @@ CVSSSH2PreferencePage_136=Fingerprint
CVSSSH2PreferencePage_137=&Authentication Methods
CVSSSH2PreferencePage_138=&Remove
CVSSSH2PreferencePage_139=Keys of known hosts:
+CVSSSH2PreferencePage_140=Select preferred key exchange methods
+CVSSSH2PreferencePage_141=Select preferred MAC methods
+CVSSSH2PreferencePage_142=You must select at least one key exchange method.
+CVSSSH2PreferencePage_143=You must select at least one MAC method.
+CVSSSH2PreferencePage_144=&Key Exchange Methods
+CVSSSH2PreferencePage_145=&MAC Methods
UserInfoPrompter_0=SSH2 Message
UserInfoPrompter_1=SSH2 Message
KeyboardInteractiveDialog_0=Keyboard Interactive authentication for {0}: {1}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java
index d3c371688..1945516f2 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation 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
@@ -146,6 +146,14 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
tabItem=new TabItem(tabFolder, SWT.NONE);
tabItem.setText(Messages.CVSSSH2PreferencePage_137);
tabItem.setControl(createPreferredAuthenticationPage(tabFolder));
+
+ tabItem=new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_144);
+ tabItem.setControl(createPreferredKeyExchangePage(tabFolder));
+
+ tabItem=new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_145);
+ tabItem.setControl(createPreferredMACPage(tabFolder));
initControls();
@@ -807,10 +815,15 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
private Button removeHostKeyButton;
Table preferedAuthMethodTable;
+ Table preferedKeyExchangeMethodTable;
+ Table preferedMACMethodTable;
Button up;
-
Button down;
+ Button kex_up;
+ Button kex_down;
+ Button mac_up;
+ Button mac_down;
class TableLabelProvider extends LabelProvider implements ITableLabelProvider{
public String getColumnText(Object element, int columnIndex){
@@ -1063,7 +1076,259 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
}
}
}
+
+ private Control createPreferredKeyExchangePage(Composite parent){
+ Composite root = new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.numColumns = 2;
+ root.setLayout(layout);
+
+ Label label=new Label(root, SWT.NONE);
+ GridData textLayoutData=new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false);
+ textLayoutData.horizontalSpan = 2;
+ label.setLayoutData(textLayoutData);
+ label.setText(Messages.CVSSSH2PreferencePage_140);
+
+ preferedKeyExchangeMethodTable=new Table(root, SWT.CHECK | SWT.BORDER);
+ GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true);
+ layoutData.verticalSpan = 3;
+ preferedKeyExchangeMethodTable.setLayoutData(layoutData);
+ layoutData.minimumHeight = 150;
+ layoutData.minimumWidth = 200;
+ populateAuthMethods();
+
+ kex_up=new Button(root, SWT.PUSH);
+ kex_up.setText(Messages.CVSSSH2PreferencePage_2);
+ kex_up.setEnabled(false);
+ setButtonLayoutData(kex_up);
+
+ kex_down=new Button(root, SWT.PUSH);
+ kex_down.setText(Messages.CVSSSH2PreferencePage_3);
+ kex_down.setEnabled(false);
+ setButtonLayoutData(kex_down);
+
+ preferedKeyExchangeMethodTable.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e){
+ boolean anySelected = false;
+ for(int i = 0; i < preferedKeyExchangeMethodTable.getItemCount(); i++){
+ anySelected |= preferedKeyExchangeMethodTable.getItem(i).getChecked();
+ }
+
+ if(anySelected){
+ setErrorMessage(null);
+ setValid(true);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_142);
+ setValid(false);
+ }
+ kex_up.setEnabled(preferedKeyExchangeMethodTable.getSelectionIndex()>0);
+ kex_down
+ .setEnabled(preferedKeyExchangeMethodTable.getSelectionIndex()<preferedKeyExchangeMethodTable
+ .getItemCount()-1);
+ }
+
+ });
+ kex_up.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e){
+ int selectedIndex=preferedKeyExchangeMethodTable.getSelectionIndex();
+ if(selectedIndex == 1){ //this is the last possible swap
+ kex_up.setEnabled(false);
+ }
+ kex_down.setEnabled(true);
+ TableItem sourceItem = preferedKeyExchangeMethodTable.getItem(selectedIndex);
+ TableItem targetItem = preferedKeyExchangeMethodTable.getItem(selectedIndex-1);
+
+ //switch text
+ String stemp = targetItem.getText();
+ targetItem.setText(sourceItem.getText());
+ sourceItem.setText(stemp);
+
+ //switch selection
+ boolean btemp = targetItem.getChecked();
+ targetItem.setChecked(sourceItem.getChecked());
+ sourceItem.setChecked(btemp);
+
+ preferedKeyExchangeMethodTable.setSelection(targetItem);
+ }
+ });
+
+ kex_down.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e){
+ int selectedIndex=preferedKeyExchangeMethodTable.getSelectionIndex();
+ if(selectedIndex == preferedKeyExchangeMethodTable.getItemCount()-2){ //this is the last possible swap
+ kex_down.setEnabled(false);
+ }
+ kex_up.setEnabled(true);
+ TableItem sourceItem = preferedKeyExchangeMethodTable.getItem(selectedIndex);
+ TableItem targetItem = preferedKeyExchangeMethodTable.getItem(selectedIndex+1);
+
+ //switch text
+ String stemp = targetItem.getText();
+ targetItem.setText(sourceItem.getText());
+ sourceItem.setText(stemp);
+
+ //switch selection
+ boolean btemp = targetItem.getChecked();
+ targetItem.setChecked(sourceItem.getChecked());
+ sourceItem.setChecked(btemp);
+
+ preferedKeyExchangeMethodTable.setSelection(targetItem);
+ }
+ });
+
+ return root;
+ }
+
+ private void populateKeyExchangeMethods(){
+ preferedKeyExchangeMethodTable.removeAll();
+ String[] methods = Utils.getEnabledPreferredKEXMethods().split(","); //$NON-NLS-1$
+ Set smethods = new HashSet(Arrays.asList(methods));
+
+ String[] order = Utils.getKEXMethodsOrder().split(","); //$NON-NLS-1$
+
+ for(int i=0; i<order.length; i++){
+ TableItem tableItem= new TableItem(preferedKeyExchangeMethodTable, SWT.NONE);
+ tableItem.setText(0, order[i]);
+ if(smethods.contains(order[i])){
+ tableItem.setChecked(true);
+ }
+ }
+ }
+
+ private Control createPreferredMACPage(Composite parent){
+ Composite root = new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.numColumns = 2;
+ root.setLayout(layout);
+
+ Label label=new Label(root, SWT.NONE);
+ GridData textLayoutData=new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false);
+ textLayoutData.horizontalSpan = 2;
+ label.setLayoutData(textLayoutData);
+ label.setText(Messages.CVSSSH2PreferencePage_141);
+
+ preferedMACMethodTable=new Table(root, SWT.CHECK | SWT.BORDER);
+ GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true);
+ layoutData.verticalSpan = 3;
+ preferedMACMethodTable.setLayoutData(layoutData);
+ layoutData.minimumHeight = 150;
+ layoutData.minimumWidth = 200;
+ populateMACMethods();
+
+ mac_up=new Button(root, SWT.PUSH);
+ mac_up.setText(Messages.CVSSSH2PreferencePage_2);
+ mac_up.setEnabled(false);
+ setButtonLayoutData(mac_up);
+
+ mac_down=new Button(root, SWT.PUSH);
+ mac_down.setText(Messages.CVSSSH2PreferencePage_3);
+ mac_down.setEnabled(false);
+ setButtonLayoutData(mac_down);
+
+ preferedMACMethodTable.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e){
+ boolean anySelected = false;
+ for(int i = 0; i < preferedMACMethodTable.getItemCount(); i++){
+ anySelected |= preferedMACMethodTable.getItem(i).getChecked();
+ }
+
+ if(anySelected){
+ setErrorMessage(null);
+ setValid(true);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_143);
+ setValid(false);
+ }
+ mac_up.setEnabled(preferedMACMethodTable.getSelectionIndex()>0);
+ mac_down
+ .setEnabled(preferedMACMethodTable.getSelectionIndex()<preferedMACMethodTable
+ .getItemCount()-1);
+ }
+
+ });
+ mac_up.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e){
+ int selectedIndex=preferedMACMethodTable.getSelectionIndex();
+ if(selectedIndex == 1){ //this is the last possible swap
+ mac_up.setEnabled(false);
+ }
+ mac_down.setEnabled(true);
+ TableItem sourceItem = preferedMACMethodTable.getItem(selectedIndex);
+ TableItem targetItem = preferedMACMethodTable.getItem(selectedIndex-1);
+
+ //switch text
+ String stemp = targetItem.getText();
+ targetItem.setText(sourceItem.getText());
+ sourceItem.setText(stemp);
+
+ //switch selection
+ boolean btemp = targetItem.getChecked();
+ targetItem.setChecked(sourceItem.getChecked());
+ sourceItem.setChecked(btemp);
+
+ preferedMACMethodTable.setSelection(targetItem);
+ }
+ });
+
+ mac_down.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e){
+ int selectedIndex=preferedMACMethodTable.getSelectionIndex();
+ if(selectedIndex == preferedMACMethodTable.getItemCount()-2){ //this is the last possible swap
+ mac_down.setEnabled(false);
+ }
+ mac_up.setEnabled(true);
+ TableItem sourceItem = preferedMACMethodTable.getItem(selectedIndex);
+ TableItem targetItem = preferedMACMethodTable.getItem(selectedIndex+1);
+
+ //switch text
+ String stemp = targetItem.getText();
+ targetItem.setText(sourceItem.getText());
+ sourceItem.setText(stemp);
+
+ //switch selection
+ boolean btemp = targetItem.getChecked();
+ targetItem.setChecked(sourceItem.getChecked());
+ sourceItem.setChecked(btemp);
+
+ preferedMACMethodTable.setSelection(targetItem);
+ }
+ });
+
+ return root;
+ }
+ private void populateMACMethods(){
+ preferedMACMethodTable.removeAll();
+ String[] methods = Utils.getEnabledPreferredMACMethods().split(","); //$NON-NLS-1$
+ Set smethods = new HashSet(Arrays.asList(methods));
+
+ String[] order = Utils.getMACMethodsOrder().split(","); //$NON-NLS-1$
+
+ for(int i=0; i<order.length; i++){
+ TableItem tableItem= new TableItem(preferedMACMethodTable, SWT.NONE);
+ tableItem.setText(0, order[i]);
+ if(smethods.contains(order[i])){
+ tableItem.setChecked(true);
+ }
+ }
+ }
+
void handleSelection(){
boolean empty=viewer.getSelection().isEmpty();
removeHostKeyButton.setEnabled(!empty);
@@ -1177,8 +1442,14 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
keyExport.setEnabled(enable);
saveKeyPair.setEnabled(enable);
populateAuthMethods();
+ populateKeyExchangeMethods();
+ populateMACMethods();
up.setEnabled(false);
down.setEnabled(false);
+ kex_up.setEnabled(false);
+ kex_down.setEnabled(false);
+ mac_up.setEnabled(false);
+ mac_down.setEnabled(false);
}
public void init(IWorkbench workbench){
@@ -1202,6 +1473,8 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
public boolean performOk(){
boolean result=super.performOk();
storeAuthenticationMethodSettings();
+ storeKeyExchangeMethodSettings();
+ storeMACMethodSettings();
if(result){
setErrorMessage(null);
String home=ssh2HomeText.getText();
@@ -1251,6 +1524,50 @@ public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
}
Utils.setEnabledPreferredAuthMethods(selected, order);
}
+
+ private void storeKeyExchangeMethodSettings(){
+ String selected = null;
+ String order = null;
+ for(int i = 0; i < preferedKeyExchangeMethodTable.getItemCount(); i++){
+ TableItem item=preferedKeyExchangeMethodTable.getItem(i);
+ if(item.getChecked()){
+ if(selected==null){
+ selected=item.getText();
+ }
+ else{
+ selected+=","+item.getText(); //$NON-NLS-1$
+ }
+ }
+ if(order == null){
+ order = item.getText();
+ } else {
+ order += "," + item.getText(); //$NON-NLS-1$
+ }
+ }
+ Utils.setEnabledPreferredKEXMethods(selected, order);
+ }
+
+ private void storeMACMethodSettings(){
+ String selected = null;
+ String order = null;
+ for(int i = 0; i < preferedMACMethodTable.getItemCount(); i++){
+ TableItem item=preferedMACMethodTable.getItem(i);
+ if(item.getChecked()){
+ if(selected==null){
+ selected=item.getText();
+ }
+ else{
+ selected+=","+item.getText(); //$NON-NLS-1$
+ }
+ }
+ if(order == null){
+ order = item.getText();
+ } else {
+ order += "," + item.getText(); //$NON-NLS-1$
+ }
+ }
+ Utils.setEnabledPreferredMACMethods(selected, order);
+ }
public void performApply(){
performOk();

Back to the top