Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.jsch.ui/src/org')
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IHelpContextIds.java4
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IUIConstants.java14
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java166
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/KeyboardInteractiveDialog.java316
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java214
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/UserValidationDialog.java12
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/IHelpContextIds.java10
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java542
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/UserValidationDialog.java408
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/WorkbenchUserAuthenticator.java352
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/ExportDialog.java122
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PassphraseDialog.java122
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PixelConverter.java12
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java3132
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/SWTUtils.java360
-rw-r--r--bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/ui/UserInfoPrompter.java382
16 files changed, 3084 insertions, 3084 deletions
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IHelpContextIds.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IHelpContextIds.java
index cc47d2591..8012ddbfd 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IHelpContextIds.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IHelpContextIds.java
@@ -15,7 +15,7 @@ package org.eclipse.jsch.internal.ui;
public interface IHelpContextIds{
- public final String USER_VALIDATION_DIALOG="org.eclipse.team.cvs.ui.user_validation_dialog_contex"; //$NON-NLS-1$
- public final String KEYBOARD_INTERACTIVE_DIALOG="org.eclipse.team.cvs.ui.keyboard_interactive_dialog_context"; //$NON-NLS-1$
+ public final String USER_VALIDATION_DIALOG="org.eclipse.team.cvs.ui.user_validation_dialog_contex"; //$NON-NLS-1$
+ public final String KEYBOARD_INTERACTIVE_DIALOG="org.eclipse.team.cvs.ui.keyboard_interactive_dialog_context"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IUIConstants.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IUIConstants.java
index b7a5a84a7..8144daf9c 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IUIConstants.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/IUIConstants.java
@@ -15,15 +15,15 @@
package org.eclipse.jsch.internal.ui;
public interface IUIConstants{
- public final String PREFIX=JSchUIPlugin.ID+"."; //$NON-NLS-1$
+ public final String PREFIX=JSchUIPlugin.ID+"."; //$NON-NLS-1$
- // image path
- public final String ICON_PATH="$nl$/icons/full/"; //$NON-NLS-1$
+ // image path
+ public final String ICON_PATH="$nl$/icons/full/"; //$NON-NLS-1$
- // preferences
- public final String PREF_FIRST_STARTUP="pref_first_startup"; //$NON-NLS-1$
+ // preferences
+ public final String PREF_FIRST_STARTUP="pref_first_startup"; //$NON-NLS-1$
- // images
- public final String IMG_KEY_LOCK="wizban/keylock.gif"; //$NON-NLS-1$
+ // images
+ public final String IMG_KEY_LOCK="wizban/keylock.gif"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java
index 8345362fb..b8eef4087 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java
@@ -29,95 +29,95 @@ import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
public class JSchUIPlugin extends AbstractUIPlugin{
- public static final String ID="org.eclipse.jsch.ui"; //$NON-NLS-1$
- public static final String DECORATOR_ID="org.eclipse.jsch.ui.decorator"; //$NON-NLS-1$
-
- private static Hashtable<String, ImageDescriptor> imageDescriptors = new Hashtable<>(20);
- /**
- * The singleton plug-in instance
- */
- private static JSchUIPlugin plugin;
- private ServiceTracker<?, ?> tracker;
-
- public JSchUIPlugin(){
- super();
- plugin=this;
- }
-
- /**
- * Returns the singleton plug-in instance.
- *
- * @return the plugin instance
- */
- public static JSchUIPlugin getPlugin(){
- return plugin;
- }
-
- /**
- * Returns the image descriptor for the given image ID.
- * Returns null if there is no such image.
- * @param id the id of the image descriptor
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String id){
- return imageDescriptors.get(id);
- }
-
- /**
- * Creates an image and places it in the image registry.
- */
- protected void createImageDescriptor(String id){
- URL url=FileLocator.find(JSchUIPlugin.getPlugin().getBundle(), new Path(
- IUIConstants.ICON_PATH+id), null);
- ImageDescriptor desc=ImageDescriptor.createFromURL(url);
- imageDescriptors.put(id, desc);
- }
-
- /**
- * Convenience method to get an image descriptor for an extension
- *
- * @param extension the extension declaring the image
- * @param subdirectoryAndFilename the path to the image
- * @return the image
- */
- public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) {
- URL fullPathString = FileLocator.find(Platform.getBundle(extension.getNamespaceIdentifier()), new Path(subdirectoryAndFilename), null);
- return ImageDescriptor.createFromURL(fullPathString);
- }
-
- /**
- * Initializes the table of images used in this plugin.
- */
- private void initializeImages() {
- createImageDescriptor(IUIConstants.IMG_KEY_LOCK);
- }
-
- @Override
+ public static final String ID="org.eclipse.jsch.ui"; //$NON-NLS-1$
+ public static final String DECORATOR_ID="org.eclipse.jsch.ui.decorator"; //$NON-NLS-1$
+
+ private static Hashtable<String, ImageDescriptor> imageDescriptors = new Hashtable<>(20);
+ /**
+ * The singleton plug-in instance
+ */
+ private static JSchUIPlugin plugin;
+ private ServiceTracker<?, ?> tracker;
+
+ public JSchUIPlugin(){
+ super();
+ plugin=this;
+ }
+
+ /**
+ * Returns the singleton plug-in instance.
+ *
+ * @return the plugin instance
+ */
+ public static JSchUIPlugin getPlugin(){
+ return plugin;
+ }
+
+ /**
+ * Returns the image descriptor for the given image ID.
+ * Returns null if there is no such image.
+ * @param id the id of the image descriptor
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String id){
+ return imageDescriptors.get(id);
+ }
+
+ /**
+ * Creates an image and places it in the image registry.
+ */
+ protected void createImageDescriptor(String id){
+ URL url=FileLocator.find(JSchUIPlugin.getPlugin().getBundle(), new Path(
+ IUIConstants.ICON_PATH+id), null);
+ ImageDescriptor desc=ImageDescriptor.createFromURL(url);
+ imageDescriptors.put(id, desc);
+ }
+
+ /**
+ * Convenience method to get an image descriptor for an extension
+ *
+ * @param extension the extension declaring the image
+ * @param subdirectoryAndFilename the path to the image
+ * @return the image
+ */
+ public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) {
+ URL fullPathString = FileLocator.find(Platform.getBundle(extension.getNamespaceIdentifier()), new Path(subdirectoryAndFilename), null);
+ return ImageDescriptor.createFromURL(fullPathString);
+ }
+
+ /**
+ * Initializes the table of images used in this plugin.
+ */
+ private void initializeImages() {
+ createImageDescriptor(IUIConstants.IMG_KEY_LOCK);
+ }
+
+ @Override
public void start(BundleContext context) throws Exception {
- super.start(context);
+ super.start(context);
- initializeImages();
+ initializeImages();
- IPreferenceStore store = getPreferenceStore();
- if (store.getBoolean(IUIConstants.PREF_FIRST_STARTUP)) {
- store.setValue(IUIConstants.PREF_FIRST_STARTUP, false);
- }
+ IPreferenceStore store = getPreferenceStore();
+ if (store.getBoolean(IUIConstants.PREF_FIRST_STARTUP)) {
+ store.setValue(IUIConstants.PREF_FIRST_STARTUP, false);
+ }
- tracker = new ServiceTracker(getBundle().getBundleContext(),IJSchService.class.getName(), null);
- tracker.open();
- }
+ tracker = new ServiceTracker(getBundle().getBundleContext(),IJSchService.class.getName(), null);
+ tracker.open();
+ }
- @Override
+ @Override
public void stop(BundleContext context) throws Exception{
- super.stop(context);
- tracker.close();
- }
+ super.stop(context);
+ tracker.close();
+ }
- public IJSchService getJSchService() {
- return (IJSchService)tracker.getService();
- }
+ public IJSchService getJSchService() {
+ return (IJSchService)tracker.getService();
+ }
- public URL getImageUrl(String relative){
- return FileLocator.find(Platform.getBundle(ID), new Path(IUIConstants.ICON_PATH + relative), null);
- }
+ public URL getImageUrl(String relative){
+ return FileLocator.find(Platform.getBundle(ID), new Path(IUIConstants.ICON_PATH + relative), null);
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/KeyboardInteractiveDialog.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/KeyboardInteractiveDialog.java
index 85f6dcd07..6b1328251 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/KeyboardInteractiveDialog.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/KeyboardInteractiveDialog.java
@@ -37,68 +37,68 @@ import org.eclipse.ui.PlatformUI;
* A dialog for keyboard-interactive authentication for the ssh2 connection.
*/
public class KeyboardInteractiveDialog extends TrayDialog {
- // widgets
- private Text[] texts;
- protected Image keyLockImage;
- protected Button allowCachingButton;
- protected Text usernameField;
-
- protected String userName;
- protected String domain;
- protected String destination;
- protected String name;
- protected String instruction;
- protected String lang;
- protected String[] prompt;
- protected boolean[] echo;
- private String message;
- private String[] result;
- protected boolean allowCaching=false;
-
- private boolean isPasswordAuth=false;
-
-
- /**
- * Creates a new KeyboardInteractiveDialog.
- *
- * @param parentShell the parent shell
- * @param location
- * @param destination
- * @param name the name
- * @param userName
- * @param instruction the instruction
- * @param prompt the titles for text fields
- * @param echo '*' should be used or not
- */
- public KeyboardInteractiveDialog(Shell parentShell,
- String location,
- String destination,
- String name,
- String userName,
- String instruction,
- String[] prompt,
- boolean[] echo){
- super(parentShell);
- this.domain=location;
- this.destination=destination;
- this.name=name;
- this.userName=userName;
- this.instruction=instruction;
- this.prompt=prompt;
- this.echo=echo;
- if (name!=null && name.length()>0) {
- this.message=NLS.bind(Messages.KeyboardInteractiveDialog_0, new String[] { destination, name });
- } else {
- this.message=NLS.bind(Messages.KeyboardInteractiveDialog_1, destination);
- }
-
- if(KeyboardInteractiveDialog.isPasswordAuth(prompt)){
- isPasswordAuth=true;
- }
- }
+ // widgets
+ private Text[] texts;
+ protected Image keyLockImage;
+ protected Button allowCachingButton;
+ protected Text usernameField;
+
+ protected String userName;
+ protected String domain;
+ protected String destination;
+ protected String name;
+ protected String instruction;
+ protected String lang;
+ protected String[] prompt;
+ protected boolean[] echo;
+ private String message;
+ private String[] result;
+ protected boolean allowCaching=false;
+
+ private boolean isPasswordAuth=false;
+
+
+ /**
+ * Creates a new KeyboardInteractiveDialog.
+ *
+ * @param parentShell the parent shell
+ * @param location
+ * @param destination
+ * @param name the name
+ * @param userName
+ * @param instruction the instruction
+ * @param prompt the titles for text fields
+ * @param echo '*' should be used or not
+ */
+ public KeyboardInteractiveDialog(Shell parentShell,
+ String location,
+ String destination,
+ String name,
+ String userName,
+ String instruction,
+ String[] prompt,
+ boolean[] echo){
+ super(parentShell);
+ this.domain=location;
+ this.destination=destination;
+ this.name=name;
+ this.userName=userName;
+ this.instruction=instruction;
+ this.prompt=prompt;
+ this.echo=echo;
+ if (name!=null && name.length()>0) {
+ this.message=NLS.bind(Messages.KeyboardInteractiveDialog_0, new String[] { destination, name });
+ } else {
+ this.message=NLS.bind(Messages.KeyboardInteractiveDialog_1, destination);
+ }
+
+ if(KeyboardInteractiveDialog.isPasswordAuth(prompt)){
+ isPasswordAuth=true;
+ }
+ }
@Override
- protected void configureShell(Shell newShell) {
+ protected void configureShell(Shell newShell) {
super.configureShell(newShell);
if (isPasswordAuth) {
newShell.setText(Messages.KeyboardInteractiveDialog_2);
@@ -112,7 +112,7 @@ public class KeyboardInteractiveDialog extends TrayDialog {
}
@Override
- public void create() {
+ public void create() {
super.create();
if (isPasswordAuth && usernameField != null && userName != null) {
@@ -124,7 +124,7 @@ public class KeyboardInteractiveDialog extends TrayDialog {
texts[0].setFocus();
}
}
- @Override
+ @Override
protected Control createDialogArea(Composite parent) {
Composite top = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -212,109 +212,109 @@ protected Control createDialogArea(Composite parent) {
return main;
}
- /**
- * Creates the three widgets that represent the user name entry area.
- *
- * @param parent the parent of the widgets
- */
- protected void createUsernameFields(Composite parent){
- new Label(parent, SWT.NONE).setText(Messages.KeyboardInteractiveDialog_6);
-
- usernameField=new Text(parent, SWT.BORDER);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- usernameField.setLayoutData(data);
- }
-
- /**
+ /**
+ * Creates the three widgets that represent the user name entry area.
+ *
+ * @param parent the parent of the widgets
+ */
+ protected void createUsernameFields(Composite parent){
+ new Label(parent, SWT.NONE).setText(Messages.KeyboardInteractiveDialog_6);
+
+ usernameField=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ usernameField.setLayoutData(data);
+ }
+
+ /**
* Creates the widgets that represent the entry area.
*
* @param parent
* the parent of the widgets
*/
- protected void createPasswordFields(Composite parent) {
- texts=new Text[prompt.length];
-
- for(int i=0; i<prompt.length; i++){
- new Label(parent, SWT.NONE).setText(prompt[i]);
- int flag=SWT.BORDER;
- if(!echo[i]){
- flag|=SWT.PASSWORD;
- }
- texts[i]=new Text(parent, flag);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- texts[i].setLayoutData(data);
- if(!echo[i]){
- texts[i].setEchoChar('*');
- }
- }
- }
- /**
- * Returns the entered values, or null
- * if the user canceled.
- *
- * @return the entered values
- */
- public String[] getResult() {
- return result;
- }
-
- /**
- * 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>
- * The default implementation of this framework method sets
- * this dialog's return code to <code>Window.OK</code>
- * and closes the dialog. Subclasses may override.
- * </p>
- */
- @Override
+ protected void createPasswordFields(Composite parent) {
+ texts=new Text[prompt.length];
+
+ for(int i=0; i<prompt.length; i++){
+ new Label(parent, SWT.NONE).setText(prompt[i]);
+ int flag=SWT.BORDER;
+ if(!echo[i]){
+ flag|=SWT.PASSWORD;
+ }
+ texts[i]=new Text(parent, flag);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ texts[i].setLayoutData(data);
+ if(!echo[i]){
+ texts[i].setEchoChar('*');
+ }
+ }
+ }
+ /**
+ * Returns the entered values, or null
+ * if the user canceled.
+ *
+ * @return the entered values
+ */
+ public String[] getResult() {
+ return result;
+ }
+
+ /**
+ * 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>
+ * The default implementation of this framework method sets
+ * this dialog's return code to <code>Window.OK</code>
+ * and closes the dialog. Subclasses may override.
+ * </p>
+ */
+ @Override
protected void okPressed() {
- result=new String[prompt.length];
- for(int i=0; i<texts.length; i++){
- result[i]=texts[i].getText();
- }
- super.okPressed();
- }
- /**
- * Notifies that the cancel button of this dialog has been pressed.
- * <p>
- * The default implementation of this framework method sets
- * this dialog's return code to <code>Window.CANCEL</code>
- * and closes the dialog. Subclasses may override.
- * </p>
- */
- @Override
+ result=new String[prompt.length];
+ for(int i=0; i<texts.length; i++){
+ result[i]=texts[i].getText();
+ }
+ super.okPressed();
+ }
+ /**
+ * Notifies that the cancel button of this dialog has been pressed.
+ * <p>
+ * The default implementation of this framework method sets
+ * this dialog's return code to <code>Window.CANCEL</code>
+ * and closes the dialog. Subclasses may override.
+ * </p>
+ */
+ @Override
protected void cancelPressed() {
- result=null;
- super.cancelPressed();
- }
-
- @Override
- public boolean close(){
- if(keyLockImage!=null){
- keyLockImage.dispose();
- }
- return super.close();
- }
-
- /**
- * Guesses if this dialog is used for password authentication.
- * @param prompt prompts for keyboard-interactive authentication method.
- * @return <code>true</code> if this dialog is used for password authentication.
- */
- static boolean isPasswordAuth(String[] prompt) {
+ result=null;
+ super.cancelPressed();
+ }
+
+ @Override
+ public boolean close(){
+ if(keyLockImage!=null){
+ keyLockImage.dispose();
+ }
+ return super.close();
+ }
+
+ /**
+ * Guesses if this dialog is used for password authentication.
+ * @param prompt prompts for keyboard-interactive authentication method.
+ * @return <code>true</code> if this dialog is used for password authentication.
+ */
+ static boolean isPasswordAuth(String[] prompt) {
return prompt != null && prompt.length == 1
&& prompt[0].trim().equalsIgnoreCase("password:"); //$NON-NLS-1$
}
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 0dbd5e9ca..0453c56f0 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
@@ -17,117 +17,117 @@ package org.eclipse.jsch.internal.ui;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS{
- private static final String BUNDLE_NAME="org.eclipse.jsch.internal.ui.messages";//$NON-NLS-1$
+ private static final String BUNDLE_NAME="org.eclipse.jsch.internal.ui.messages";//$NON-NLS-1$
- static{
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
+ static{
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
- public static String CVSSSH2ServerConnection_open;
- public static String CVSSSH2PreferencePage_18;
- public static String CVSSSH2PreferencePage_19;
- public static String CVSSSH2PreferencePage_2;
- public static String CVSSSH2PreferencePage_20;
- public static String CVSSSH2PreferencePage_21;
- public static String CVSSSH2PreferencePage_23;
- public static String CVSSSH2PreferencePage_24;
- public static String CVSSSH2PreferencePage_25;
- public static String CVSSSH2PreferencePage_26;
- public static String CVSSSH2PreferencePage_27;
- public static String CVSSSH2PreferencePage_3;
- public static String CVSSSH2PreferencePage_30;
- public static String CVSSSH2PreferencePage_31;
- public static String CVSSSH2PreferencePage_32;
- public static String CVSSSH2PreferencePage_33;
- public static String CVSSSH2PreferencePage_34;
- public static String CVSSSH2PreferencePage_35;
- public static String CVSSSH2PreferencePage_36;
- public static String CVSSSH2PreferencePage_39;
- public static String CVSSSH2PreferencePage_4;
- public static String CVSSSH2PreferencePage_41;
- public static String CVSSSH2PreferencePage_42;
- public static String CVSSSH2PreferencePage_43;
- public static String CVSSSH2PreferencePage_44;
- public static String CVSSSH2PreferencePage_45;
- public static String CVSSSH2PreferencePage_47;
- public static String CVSSSH2PreferencePage_48;
- public static String CVSSSH2PreferencePage_49;
- public static String CVSSSH2PreferencePage_5;
- public static String CVSSSH2PreferencePage_50;
- public static String CVSSSH2PreferencePage_53;
- public static String CVSSSH2PreferencePage_55;
- public static String CVSSSH2PreferencePage_57;
- public static String CVSSSH2PreferencePage_59;
- public static String CVSSSH2PreferencePage_99;
- public static String CVSSSH2PreferencePage_100;
- public static String CVSSSH2PreferencePage_104;
- public static String CVSSSH2PreferencePage_105;
- public static String CVSSSH2PreferencePage_106;
- public static String CVSSSH2PreferencePage_107;
- public static String CVSSSH2PreferencePage_108;
- public static String CVSSSH2PreferencePage_109;
- public static String CVSSSH2PreferencePage_110;
- public static String CVSSSH2PreferencePage_111;
- public static String CVSSSH2ServerConnection_3;
- public static String CVSSSH2ServerConnection_0;
- public static String CVSSSH2ServerConnection_1;
- public static String CVSSSH2PreferencePage_information;
- public static String CVSSSH2PreferencePage_error;
- public static String CVSSSH2PreferencePage_confirmation;
- public static String CVSSSH2PreferencePage_question;
- public static String CVSSSH2PreferencePage_125;
- public static String CVSSSH2PreferencePage_126;
- public static String CVSSSH2PreferencePage_127;
- public static String CVSSSH2PreferencePage_128;
- public static String CVSSSH2PreferencePage_129;
- public static String CVSSSH2PreferencePage_130;
- public static String CVSSSH2PreferencePage_131;
- public static String CVSSSH2PreferencePage_132;
- public static String CVSSSH2PreferencePage_133;
- public static String CVSSSH2PreferencePage_134;
- public static String CVSSSH2PreferencePage_135;
- public static String CVSSSH2PreferencePage_136;
- 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 CVSSSH2PreferencePage_146;
- public static String CVSSSH2PreferencePage_147;
- public static String KeyboardInteractiveDialog_0;
- public static String KeyboardInteractiveDialog_1;
- public static String KeyboardInteractiveDialog_2;
- public static String KeyboardInteractiveDialog_3;
- public static String KeyboardInteractiveDialog_4;
- public static String KeyboardInteractiveDialog_6;
- public static String KeyboradInteractiveDialog_message;
- public static String KeyboardInteractiveDialog_labelRepository;
+ public static String CVSSSH2ServerConnection_open;
+ public static String CVSSSH2PreferencePage_18;
+ public static String CVSSSH2PreferencePage_19;
+ public static String CVSSSH2PreferencePage_2;
+ public static String CVSSSH2PreferencePage_20;
+ public static String CVSSSH2PreferencePage_21;
+ public static String CVSSSH2PreferencePage_23;
+ public static String CVSSSH2PreferencePage_24;
+ public static String CVSSSH2PreferencePage_25;
+ public static String CVSSSH2PreferencePage_26;
+ public static String CVSSSH2PreferencePage_27;
+ public static String CVSSSH2PreferencePage_3;
+ public static String CVSSSH2PreferencePage_30;
+ public static String CVSSSH2PreferencePage_31;
+ public static String CVSSSH2PreferencePage_32;
+ public static String CVSSSH2PreferencePage_33;
+ public static String CVSSSH2PreferencePage_34;
+ public static String CVSSSH2PreferencePage_35;
+ public static String CVSSSH2PreferencePage_36;
+ public static String CVSSSH2PreferencePage_39;
+ public static String CVSSSH2PreferencePage_4;
+ public static String CVSSSH2PreferencePage_41;
+ public static String CVSSSH2PreferencePage_42;
+ public static String CVSSSH2PreferencePage_43;
+ public static String CVSSSH2PreferencePage_44;
+ public static String CVSSSH2PreferencePage_45;
+ public static String CVSSSH2PreferencePage_47;
+ public static String CVSSSH2PreferencePage_48;
+ public static String CVSSSH2PreferencePage_49;
+ public static String CVSSSH2PreferencePage_5;
+ public static String CVSSSH2PreferencePage_50;
+ public static String CVSSSH2PreferencePage_53;
+ public static String CVSSSH2PreferencePage_55;
+ public static String CVSSSH2PreferencePage_57;
+ public static String CVSSSH2PreferencePage_59;
+ public static String CVSSSH2PreferencePage_99;
+ public static String CVSSSH2PreferencePage_100;
+ public static String CVSSSH2PreferencePage_104;
+ public static String CVSSSH2PreferencePage_105;
+ public static String CVSSSH2PreferencePage_106;
+ public static String CVSSSH2PreferencePage_107;
+ public static String CVSSSH2PreferencePage_108;
+ public static String CVSSSH2PreferencePage_109;
+ public static String CVSSSH2PreferencePage_110;
+ public static String CVSSSH2PreferencePage_111;
+ public static String CVSSSH2ServerConnection_3;
+ public static String CVSSSH2ServerConnection_0;
+ public static String CVSSSH2ServerConnection_1;
+ public static String CVSSSH2PreferencePage_information;
+ public static String CVSSSH2PreferencePage_error;
+ public static String CVSSSH2PreferencePage_confirmation;
+ public static String CVSSSH2PreferencePage_question;
+ public static String CVSSSH2PreferencePage_125;
+ public static String CVSSSH2PreferencePage_126;
+ public static String CVSSSH2PreferencePage_127;
+ public static String CVSSSH2PreferencePage_128;
+ public static String CVSSSH2PreferencePage_129;
+ public static String CVSSSH2PreferencePage_130;
+ public static String CVSSSH2PreferencePage_131;
+ public static String CVSSSH2PreferencePage_132;
+ public static String CVSSSH2PreferencePage_133;
+ public static String CVSSSH2PreferencePage_134;
+ public static String CVSSSH2PreferencePage_135;
+ public static String CVSSSH2PreferencePage_136;
+ 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 CVSSSH2PreferencePage_146;
+ public static String CVSSSH2PreferencePage_147;
+ public static String KeyboardInteractiveDialog_0;
+ public static String KeyboardInteractiveDialog_1;
+ public static String KeyboardInteractiveDialog_2;
+ public static String KeyboardInteractiveDialog_3;
+ public static String KeyboardInteractiveDialog_4;
+ public static String KeyboardInteractiveDialog_6;
+ public static String KeyboradInteractiveDialog_message;
+ public static String KeyboardInteractiveDialog_labelRepository;
- public static String PreferencePage_0;
- public static String PreferencePage_1;
- public static String UserInfoPrompter_0;
- public static String UserInfoPrompter_1;
- public static String UserValidationDialog_0;
- public static String UserValidationDialog_1;
- public static String UserValidationDialog_2;
- public static String UserValidationDialog_4;
- public static String UserValidationDialog_5;
- public static String UserValidationDialog_6;
+ public static String PreferencePage_0;
+ public static String PreferencePage_1;
+ public static String UserInfoPrompter_0;
+ public static String UserInfoPrompter_1;
+ public static String UserValidationDialog_0;
+ public static String UserValidationDialog_1;
+ public static String UserValidationDialog_2;
+ public static String UserValidationDialog_4;
+ public static String UserValidationDialog_5;
+ public static String UserValidationDialog_6;
- public static String UserValidationDialog_required;
- public static String UserValidationDialog_labelUser;
- public static String UserValidationDialog_labelPassword;
- public static String UserValidationDialog_password;
- public static String UserValidationDialog_user;
+ public static String UserValidationDialog_required;
+ public static String UserValidationDialog_labelUser;
+ public static String UserValidationDialog_labelPassword;
+ public static String UserValidationDialog_password;
+ public static String UserValidationDialog_user;
- public static String WorkbenchUserAuthenticator_cancelled;
- public static String WorkbenchUserAuthenticator_1;
- public static String WorkbenchUserAuthenticator_2;
- public static String WorkbenchUserAuthenticator_The_operation_was_canceled_by_the_user_1;
+ public static String WorkbenchUserAuthenticator_cancelled;
+ public static String WorkbenchUserAuthenticator_1;
+ public static String WorkbenchUserAuthenticator_2;
+ public static String WorkbenchUserAuthenticator_The_operation_was_canceled_by_the_user_1;
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/UserValidationDialog.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/UserValidationDialog.java
index 1859876b3..dcef8115a 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/UserValidationDialog.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/UserValidationDialog.java
@@ -62,7 +62,7 @@ public class UserValidationDialog extends TrayDialog {
*/
public UserValidationDialog(Shell parentShell, String location, String defaultName, String message) {
super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
this.defaultUsername = defaultName;
this.domain = location;
this.message = message;
@@ -72,7 +72,7 @@ public class UserValidationDialog extends TrayDialog {
super.configureShell(newShell);
newShell.setText(Messages.UserValidationDialog_0);
// set F1 help
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG);
}
@Override
public void create() {
@@ -153,7 +153,7 @@ public class UserValidationDialog extends TrayDialog {
});
}
- Dialog.applyDialogFont(parent);
+ Dialog.applyDialogFont(parent);
return main;
}
@@ -234,9 +234,9 @@ public class UserValidationDialog extends TrayDialog {
@Override
protected void cancelPressed(){
- password = null;
- username = null;
- super.cancelPressed();
+ password = null;
+ username = null;
+ super.cancelPressed();
}
/**
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/IHelpContextIds.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/IHelpContextIds.java
index d4124076b..efdd1d5fc 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/IHelpContextIds.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/IHelpContextIds.java
@@ -24,10 +24,10 @@ import org.eclipse.jsch.internal.ui.JSchUIPlugin;
*/
public interface IHelpContextIds{
- public static final String PREFIX=JSchUIPlugin.ID+"."; //$NON-NLS-1$
+ public static final String PREFIX=JSchUIPlugin.ID+"."; //$NON-NLS-1$
- public static final String KEYBOARD_INTERACTIVE_DIALOG=PREFIX
- +"keyboard_interactive_dialog_context"; //$NON-NLS-1$
- public static final String USER_VALIDATION_DIALOG=PREFIX
- +"user_validation_dialog_context"; //$NON-NLS-1$
+ public static final String KEYBOARD_INTERACTIVE_DIALOG=PREFIX
+ +"keyboard_interactive_dialog_context"; //$NON-NLS-1$
+ public static final String USER_VALIDATION_DIALOG=PREFIX
+ +"user_validation_dialog_context"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java
index 40a6d82cc..a20b22e0c 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java
@@ -41,282 +41,282 @@ import org.eclipse.ui.PlatformUI;
* @since 1.1
*/
public class KeyboardInteractiveDialog extends TrayDialog{
- // whether or not the user name can be changed
- protected boolean isUsernameMutable=false;
-
- // widgets
- private Text[] texts;
- protected Image keyLockImage;
- protected Button allowCachingButton;
- protected Text usernameField;
-
- protected String defaultUsername;
- protected String comment;
- protected String destination;
- protected String name;
- protected String instruction;
- protected String lang;
- protected String[] prompt;
- protected boolean[] echo;
- private String message;
- private String[] result;
- protected boolean allowCaching=false;
-
- private boolean isPasswordAuth=false;
-
- /**
- * Creates a new KeyboardInteractiveDialog.
- *
- * @param parentShell the parent shell
- * @param comment the comment
- * @param destination the location
- * @param name the name
- * @param userName user name
- * @param instruction the instruction
- * @param prompt the titles for text-fields
- * @param echo '*' should be used or not
- */
- public KeyboardInteractiveDialog(Shell parentShell, String comment,
- String destination, String name, String userName, String instruction, String[] prompt,
- boolean[] echo){
- super(parentShell);
- setShellStyle(getShellStyle()|SWT.RESIZE);
- this.comment=comment;
- this.destination=destination;
- this.name=name;
- this.defaultUsername=userName;
- this.instruction=instruction;
- this.prompt=prompt;
- this.echo=echo;
- this.message=NLS.bind(Messages.KeyboradInteractiveDialog_message,
- new String[] {destination
- +(name!=null&&name.length()>0 ? ": "+name : "")}); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
-
- if(prompt!=null && prompt.length==1 && prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
- isPasswordAuth=true;
- }
-
- }
-
- @Override
+ // whether or not the user name can be changed
+ protected boolean isUsernameMutable=false;
+
+ // widgets
+ private Text[] texts;
+ protected Image keyLockImage;
+ protected Button allowCachingButton;
+ protected Text usernameField;
+
+ protected String defaultUsername;
+ protected String comment;
+ protected String destination;
+ protected String name;
+ protected String instruction;
+ protected String lang;
+ protected String[] prompt;
+ protected boolean[] echo;
+ private String message;
+ private String[] result;
+ protected boolean allowCaching=false;
+
+ private boolean isPasswordAuth=false;
+
+ /**
+ * Creates a new KeyboardInteractiveDialog.
+ *
+ * @param parentShell the parent shell
+ * @param comment the comment
+ * @param destination the location
+ * @param name the name
+ * @param userName user name
+ * @param instruction the instruction
+ * @param prompt the titles for text-fields
+ * @param echo '*' should be used or not
+ */
+ public KeyboardInteractiveDialog(Shell parentShell, String comment,
+ String destination, String name, String userName, String instruction, String[] prompt,
+ boolean[] echo){
+ super(parentShell);
+ setShellStyle(getShellStyle()|SWT.RESIZE);
+ this.comment=comment;
+ this.destination=destination;
+ this.name=name;
+ this.defaultUsername=userName;
+ this.instruction=instruction;
+ this.prompt=prompt;
+ this.echo=echo;
+ this.message=NLS.bind(Messages.KeyboradInteractiveDialog_message,
+ new String[] {destination
+ +(name!=null&&name.length()>0 ? ": "+name : "")}); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
+
+ if(prompt!=null && prompt.length==1 && prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
+ isPasswordAuth=true;
+ }
+
+ }
+
+ @Override
protected void configureShell(Shell newShell){
- super.configureShell(newShell);
- if(isPasswordAuth){
- newShell.setText(Messages.UserValidationDialog_required);
- }
- else{
- newShell.setText(message);
- }
- // set F1 help
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
- IHelpContextIds.KEYBOARD_INTERACTIVE_DIALOG);
- }
-
- @Override
+ super.configureShell(newShell);
+ if(isPasswordAuth){
+ newShell.setText(Messages.UserValidationDialog_required);
+ }
+ else{
+ newShell.setText(message);
+ }
+ // set F1 help
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
+ IHelpContextIds.KEYBOARD_INTERACTIVE_DIALOG);
+ }
+
+ @Override
public void create(){
- super.create();
+ super.create();
- if(isPasswordAuth&&usernameField!=null){
- usernameField.setText(defaultUsername);
- usernameField.setEditable(false);
- }
+ if(isPasswordAuth&&usernameField!=null){
+ usernameField.setText(defaultUsername);
+ usernameField.setEditable(false);
+ }
- if(texts.length>0){
- texts[0].setFocus();
- }
- }
+ if(texts.length>0){
+ texts[0].setFocus();
+ }
+ }
- @Override
+ @Override
protected Control createDialogArea(Composite parent){
- 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;
- main.setLayout(layout);
- main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label imageLabel=new Label(imageComposite, SWT.NONE);
- keyLockImage=JSchUIPlugin.getImageDescriptor(IUIConstants.IMG_KEY_LOCK)
- .createImage();
- imageLabel.setImage(keyLockImage);
- 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);
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- data.widthHint=400;
- messageLabel.setLayoutData(data);
- }
- if(comment!=null){
- Label label=new Label(main, SWT.WRAP);
- if(isUsernameMutable){
- label.setText(NLS.bind(Messages.UserValidationDialog_labelUser,
- new String[] {comment}));
- }
- else{
- label.setText(NLS.bind(Messages.UserValidationDialog_labelPassword,
- (new Object[] {defaultUsername, comment})));
- }
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- data.widthHint=400;
- label.setLayoutData(data);
- }
- if(instruction!=null&&instruction.length()>0){
- Label label=new Label(main, SWT.WRAP);
- label.setText(instruction);
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- data.widthHint=400;
- label.setLayoutData(data);
- }
-
- if(isPasswordAuth){
- createUsernameFields(main);
- }
-
- createPasswordFields(main);
-
- if(isPasswordAuth){
- allowCachingButton=new Button(main, SWT.CHECK);
- allowCachingButton.setText(Messages.UserValidationDialog_6);
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- allowCachingButton.setLayoutData(data);
- allowCachingButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- allowCaching=allowCachingButton.getSelection();
- }
- });
- }
-
- Dialog.applyDialogFont(parent);
-
- return main;
- }
-
- /**
- * Creates the three widgets that represent the user name entry area.
- *
- * @param parent the parent of the widgets
- */
- protected void createUsernameFields(Composite parent){
- new Label(parent, SWT.NONE).setText(Messages.UserValidationDialog_user);
-
- usernameField=new Text(parent, SWT.BORDER);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- usernameField.setLayoutData(data);
- }
-
- /**
- * Creates the widgets that represent the entry area.
- *
- * @param parent the parent of the widgets
- */
- protected void createPasswordFields(Composite parent){
- texts=new Text[prompt.length];
-
- for(int i=0; i<prompt.length; i++){
- new Label(parent, SWT.NONE).setText(prompt[i]);
- int flag=SWT.BORDER;
- if(!echo[i]){
- flag|=SWT.PASSWORD;
- }
- texts[i]=new Text(parent, flag);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- texts[i].setLayoutData(data);
- if(!echo[i]){
- texts[i].setEchoChar('*');
- }
- }
- }
-
- /**
- * Returns the entered values, or null
- * if the user canceled.
- *
- * @return the entered values
- */
- public String[] getResult(){
- return result;
- }
-
- /**
- * 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>
- * The default implementation of this framework method sets
- * this dialog's return code to <code>Window.OK</code>
- * and closes the dialog. Subclasses may override.
- * </p>
- */
- @Override
+ 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;
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label imageLabel=new Label(imageComposite, SWT.NONE);
+ keyLockImage=JSchUIPlugin.getImageDescriptor(IUIConstants.IMG_KEY_LOCK)
+ .createImage();
+ imageLabel.setImage(keyLockImage);
+ 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);
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ data.widthHint=400;
+ messageLabel.setLayoutData(data);
+ }
+ if(comment!=null){
+ Label label=new Label(main, SWT.WRAP);
+ if(isUsernameMutable){
+ label.setText(NLS.bind(Messages.UserValidationDialog_labelUser,
+ new String[] {comment}));
+ }
+ else{
+ label.setText(NLS.bind(Messages.UserValidationDialog_labelPassword,
+ (new Object[] {defaultUsername, comment})));
+ }
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ data.widthHint=400;
+ label.setLayoutData(data);
+ }
+ if(instruction!=null&&instruction.length()>0){
+ Label label=new Label(main, SWT.WRAP);
+ label.setText(instruction);
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ data.widthHint=400;
+ label.setLayoutData(data);
+ }
+
+ if(isPasswordAuth){
+ createUsernameFields(main);
+ }
+
+ createPasswordFields(main);
+
+ if(isPasswordAuth){
+ allowCachingButton=new Button(main, SWT.CHECK);
+ allowCachingButton.setText(Messages.UserValidationDialog_6);
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ allowCachingButton.setLayoutData(data);
+ allowCachingButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ allowCaching=allowCachingButton.getSelection();
+ }
+ });
+ }
+
+ Dialog.applyDialogFont(parent);
+
+ return main;
+ }
+
+ /**
+ * Creates the three widgets that represent the user name entry area.
+ *
+ * @param parent the parent of the widgets
+ */
+ protected void createUsernameFields(Composite parent){
+ new Label(parent, SWT.NONE).setText(Messages.UserValidationDialog_user);
+
+ usernameField=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ usernameField.setLayoutData(data);
+ }
+
+ /**
+ * Creates the widgets that represent the entry area.
+ *
+ * @param parent the parent of the widgets
+ */
+ protected void createPasswordFields(Composite parent){
+ texts=new Text[prompt.length];
+
+ for(int i=0; i<prompt.length; i++){
+ new Label(parent, SWT.NONE).setText(prompt[i]);
+ int flag=SWT.BORDER;
+ if(!echo[i]){
+ flag|=SWT.PASSWORD;
+ }
+ texts[i]=new Text(parent, flag);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ texts[i].setLayoutData(data);
+ if(!echo[i]){
+ texts[i].setEchoChar('*');
+ }
+ }
+ }
+
+ /**
+ * Returns the entered values, or null
+ * if the user canceled.
+ *
+ * @return the entered values
+ */
+ public String[] getResult(){
+ return result;
+ }
+
+ /**
+ * 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>
+ * The default implementation of this framework method sets
+ * this dialog's return code to <code>Window.OK</code>
+ * and closes the dialog. Subclasses may override.
+ * </p>
+ */
+ @Override
protected void okPressed(){
- result=new String[prompt.length];
- for(int i=0; i<texts.length; i++){
- result[i]=texts[i].getText();
- }
- super.okPressed();
- }
-
- /**
- * Sets whether or not the username field should be mutable.
- * This method must be called before create(), otherwise it
- * will be ignored.
- *
- * @param value whether the username is mutable
- */
- public void setUsernameMutable(boolean value){
- isUsernameMutable=value;
- }
-
- /**
- * Notifies that the cancel button of this dialog has been pressed.
- * <p>
- * The default implementation of this framework method sets
- * this dialog's return code to <code>Window.CANCEL</code>
- * and closes the dialog. Subclasses may override.
- * </p>
- */
- @Override
- protected void cancelPressed(){
- result=null;
- super.cancelPressed();
- }
-
- @Override
- public boolean close(){
- if(keyLockImage!=null){
- keyLockImage.dispose();
- }
- return super.close();
- }
+ result=new String[prompt.length];
+ for(int i=0; i<texts.length; i++){
+ result[i]=texts[i].getText();
+ }
+ super.okPressed();
+ }
+
+ /**
+ * Sets whether or not the username field should be mutable.
+ * This method must be called before create(), otherwise it
+ * will be ignored.
+ *
+ * @param value whether the username is mutable
+ */
+ public void setUsernameMutable(boolean value){
+ isUsernameMutable=value;
+ }
+
+ /**
+ * Notifies that the cancel button of this dialog has been pressed.
+ * <p>
+ * The default implementation of this framework method sets
+ * this dialog's return code to <code>Window.CANCEL</code>
+ * and closes the dialog. Subclasses may override.
+ * </p>
+ */
+ @Override
+ protected void cancelPressed(){
+ result=null;
+ super.cancelPressed();
+ }
+
+ @Override
+ public boolean close(){
+ if(keyLockImage!=null){
+ keyLockImage.dispose();
+ }
+ return super.close();
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/UserValidationDialog.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/UserValidationDialog.java
index ea035fb83..f29ad949d 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/UserValidationDialog.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/UserValidationDialog.java
@@ -40,239 +40,239 @@ import org.eclipse.ui.PlatformUI;
* @since 1.1
*/
public class UserValidationDialog extends TrayDialog{
- // widgets
- protected Text usernameField;
- protected Text passwordField;
- protected Button allowCachingButton;
+ // widgets
+ protected Text usernameField;
+ protected Text passwordField;
+ protected Button allowCachingButton;
- protected String comment;
- protected String defaultUsername;
- protected String password=null;
- protected boolean allowCaching=false;
- protected boolean isAllowCaching=false;
- protected Image keyLockImage;
+ protected String comment;
+ protected String defaultUsername;
+ protected String password=null;
+ protected boolean allowCaching=false;
+ protected boolean isAllowCaching=false;
+ protected Image keyLockImage;
- // whether or not the user name can be changed
- protected boolean isUsernameMutable=true;
- protected String username=null;
- protected String message=null;
+ // whether or not the user name can be changed
+ protected boolean isUsernameMutable=true;
+ protected String username=null;
+ protected String message=null;
- /**
- * Creates a new UserValidationDialog.
- *
- * @param parentShell
- * the parent shell
- * @param comment
- * the location
- * @param defaultName
- * the default user name
- * @param message
- * a message to display to the user
- * @param isAllowCaching
- * a flag to show a check box to save password
- */
- public UserValidationDialog(Shell parentShell, String comment,
- String defaultName, String message, boolean isAllowCaching){
- super(parentShell);
- setShellStyle(getShellStyle()|SWT.RESIZE);
- this.defaultUsername=defaultName;
- this.comment=comment;
- this.message=message;
- this.isAllowCaching=isAllowCaching;
- }
+ /**
+ * Creates a new UserValidationDialog.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param comment
+ * the location
+ * @param defaultName
+ * the default user name
+ * @param message
+ * a message to display to the user
+ * @param isAllowCaching
+ * a flag to show a check box to save password
+ */
+ public UserValidationDialog(Shell parentShell, String comment,
+ String defaultName, String message, boolean isAllowCaching){
+ super(parentShell);
+ setShellStyle(getShellStyle()|SWT.RESIZE);
+ this.defaultUsername=defaultName;
+ this.comment=comment;
+ this.message=message;
+ this.isAllowCaching=isAllowCaching;
+ }
@Override
- protected void configureShell(Shell newShell){
- super.configureShell(newShell);
- newShell.setText(Messages.UserValidationDialog_required);
- // set F1 help
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
- IHelpContextIds.USER_VALIDATION_DIALOG);
- }
+ protected void configureShell(Shell newShell){
+ super.configureShell(newShell);
+ newShell.setText(Messages.UserValidationDialog_required);
+ // set F1 help
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
+ IHelpContextIds.USER_VALIDATION_DIALOG);
+ }
- @Override
+ @Override
public void create(){
- super.create();
- // add some default values
- usernameField.setText(defaultUsername);
+ super.create();
+ // add some default values
+ usernameField.setText(defaultUsername);
- if(isUsernameMutable){
- // give focus to user name field
- usernameField.selectAll();
- usernameField.setFocus();
- }
- else{
- usernameField.setEditable(false);
- passwordField.setFocus();
- }
- }
+ if(isUsernameMutable){
+ // give focus to user name field
+ usernameField.selectAll();
+ usernameField.setFocus();
+ }
+ else{
+ usernameField.setEditable(false);
+ passwordField.setFocus();
+ }
+ }
- @Override
+ @Override
protected Control createDialogArea(Composite parent){
- Composite top=new Composite(parent, SWT.NONE);
- GridLayout layout=new GridLayout();
- layout.numColumns=2;
+ Composite top=new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ layout.numColumns=2;
- top.setLayout(layout);
- top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ 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 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;
- main.setLayout(layout);
- main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Composite main=new Composite(top, SWT.NONE);
+ layout=new GridLayout();
+ layout.numColumns=3;
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Label imageLabel=new Label(imageComposite, SWT.NONE);
- keyLockImage=JSchUIPlugin.getImageDescriptor(IUIConstants.IMG_KEY_LOCK)
- .createImage();
- imageLabel.setImage(keyLockImage);
- GridData data=new GridData(GridData.FILL_HORIZONTAL
- |GridData.GRAB_HORIZONTAL);
- imageLabel.setLayoutData(data);
+ Label imageLabel=new Label(imageComposite, SWT.NONE);
+ keyLockImage=JSchUIPlugin.getImageDescriptor(IUIConstants.IMG_KEY_LOCK)
+ .createImage();
+ imageLabel.setImage(keyLockImage);
+ 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);
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- data.widthHint=400;
- messageLabel.setLayoutData(data);
- }
- if(comment!=null){
- Label label=new Label(main, SWT.WRAP);
- if(isUsernameMutable){
- label.setText(NLS.bind(Messages.UserValidationDialog_labelUser,
- new String[] {comment}));
- }
- else{
- label.setText(NLS.bind(Messages.UserValidationDialog_labelPassword,
- (new Object[] {defaultUsername, comment})));
- }
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- data.widthHint=400;
- label.setLayoutData(data);
- }
- createUsernameFields(main);
- createPasswordFields(main);
+ if(message!=null){
+ Label messageLabel=new Label(main, SWT.WRAP);
+ messageLabel.setText(message);
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ data.widthHint=400;
+ messageLabel.setLayoutData(data);
+ }
+ if(comment!=null){
+ Label label=new Label(main, SWT.WRAP);
+ if(isUsernameMutable){
+ label.setText(NLS.bind(Messages.UserValidationDialog_labelUser,
+ new String[] {comment}));
+ }
+ else{
+ label.setText(NLS.bind(Messages.UserValidationDialog_labelPassword,
+ (new Object[] {defaultUsername, comment})));
+ }
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ data.widthHint=400;
+ label.setLayoutData(data);
+ }
+ createUsernameFields(main);
+ createPasswordFields(main);
- if(isAllowCaching){
- allowCachingButton=new Button(main, SWT.CHECK);
- allowCachingButton.setText(Messages.UserValidationDialog_6);
- data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
- data.horizontalSpan=3;
- allowCachingButton.setLayoutData(data);
- allowCachingButton.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- allowCaching=allowCachingButton.getSelection();
- }
- });
- }
+ if(isAllowCaching){
+ allowCachingButton=new Button(main, SWT.CHECK);
+ allowCachingButton.setText(Messages.UserValidationDialog_6);
+ data=new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL);
+ data.horizontalSpan=3;
+ allowCachingButton.setLayoutData(data);
+ allowCachingButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ allowCaching=allowCachingButton.getSelection();
+ }
+ });
+ }
- Dialog.applyDialogFont(parent);
+ Dialog.applyDialogFont(parent);
- return main;
- }
+ return main;
+ }
- /**
- * Creates the three widgets that represent the password entry area.
- *
- * @param parent
- * the parent of the widgets
- */
- protected void createPasswordFields(Composite parent){
- new Label(parent, SWT.NONE).setText(Messages.UserValidationDialog_password);
+ /**
+ * Creates the three widgets that represent the password entry area.
+ *
+ * @param parent
+ * the parent of the widgets
+ */
+ protected void createPasswordFields(Composite parent){
+ new Label(parent, SWT.NONE).setText(Messages.UserValidationDialog_password);
- passwordField=new Text(parent, SWT.BORDER|SWT.PASSWORD);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- passwordField.setLayoutData(data);
- }
+ passwordField=new Text(parent, SWT.BORDER|SWT.PASSWORD);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ passwordField.setLayoutData(data);
+ }
- /**
- * Creates the three widgets that represent the user name entry area.
- *
- * @param parent
- * the parent of the widgets
- */
- protected void createUsernameFields(Composite parent){
- new Label(parent, SWT.NONE).setText(Messages.UserValidationDialog_user);
+ /**
+ * Creates the three widgets that represent the user name entry area.
+ *
+ * @param parent
+ * the parent of the widgets
+ */
+ protected void createUsernameFields(Composite parent){
+ new Label(parent, SWT.NONE).setText(Messages.UserValidationDialog_user);
- usernameField=new Text(parent, SWT.BORDER);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- usernameField.setLayoutData(data);
- }
+ usernameField=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ usernameField.setLayoutData(data);
+ }
- /**
- * Returns the password entered by the user, or null if the user canceled.
- *
- * @return the entered password
- */
- public String getPassword(){
- return password;
- }
+ /**
+ * Returns the password entered by the user, or null if the user canceled.
+ *
+ * @return the entered password
+ */
+ public String getPassword(){
+ return password;
+ }
- /**
- * Returns the username entered by the user, or null if the user canceled.
- *
- * @return the entered username
- */
- public String getUsername(){
- return username;
- }
+ /**
+ * Returns the username entered by the user, or null if the user canceled.
+ *
+ * @return the entered username
+ */
+ 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;
- }
+ /**
+ * 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>
- * The default implementation of this framework method sets this dialog's
- * return code to <code>Window.OK</code> and closes the dialog. Subclasses
- * may override.
- * </p>
- */
- @Override
+ /**
+ * Notifies that the ok button of this dialog has been pressed.
+ * <p>
+ * The default implementation of this framework method sets this dialog's
+ * return code to <code>Window.OK</code> and closes the dialog. Subclasses
+ * may override.
+ * </p>
+ */
+ @Override
protected void okPressed(){
- password=passwordField.getText();
- username=usernameField.getText();
+ password=passwordField.getText();
+ username=usernameField.getText();
- super.okPressed();
- }
+ super.okPressed();
+ }
- /**
- * Sets whether or not the username field should be mutable. This method must
- * be called before create(), otherwise it will be ignored.
- *
- * @param value
- * whether the username is mutable
- */
- public void setUsernameMutable(boolean value){
- isUsernameMutable=value;
- }
+ /**
+ * Sets whether or not the username field should be mutable. This method must
+ * be called before create(), otherwise it will be ignored.
+ *
+ * @param value
+ * whether the username is mutable
+ */
+ public void setUsernameMutable(boolean value){
+ isUsernameMutable=value;
+ }
- @Override
- public boolean close(){
- if(keyLockImage!=null){
- keyLockImage.dispose();
- }
- return super.close();
- }
+ @Override
+ public boolean close(){
+ if(keyLockImage!=null){
+ keyLockImage.dispose();
+ }
+ return super.close();
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/WorkbenchUserAuthenticator.java
index 1276044b2..24672fa49 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/WorkbenchUserAuthenticator.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/WorkbenchUserAuthenticator.java
@@ -36,163 +36,163 @@ import org.eclipse.ui.PlatformUI;
* @since 1.1
*/
public class WorkbenchUserAuthenticator implements IUserAuthenticator{
- /**
- * WorkbenchUserAuthenticator constructor.
- */
- public WorkbenchUserAuthenticator(){
- super();
- }
-
- @Override
+ /**
+ * WorkbenchUserAuthenticator constructor.
+ */
+ public WorkbenchUserAuthenticator(){
+ super();
+ }
+
+ @Override
public void promptForUserInfo(final IJSchLocation location,
- final IUserInfo userinfo, final String message){
-
- // ask the user for a password
- final String[] result=new String[2];
- Display display=Display.getCurrent();
- final boolean allowCaching[]= {false};
- if(display!=null){
- allowCaching[0]=promptForPassword(location, userinfo.getUsername(),
- message, userinfo.isUsernameMutable(), result);
- }
- else{
- // sync exec in default thread
+ final IUserInfo userinfo, final String message){
+
+ // ask the user for a password
+ final String[] result=new String[2];
+ Display display=Display.getCurrent();
+ final boolean allowCaching[]= {false};
+ if(display!=null){
+ allowCaching[0]=promptForPassword(location, userinfo.getUsername(),
+ message, userinfo.isUsernameMutable(), result);
+ }
+ else{
+ // sync exec in default thread
Display.getDefault().syncExec(() -> allowCaching[0] = promptForPassword(location, userinfo.getUsername(),
message, userinfo.isUsernameMutable(), result));
- }
-
- if(result[0]==null){
- throw new OperationCanceledException(
- Messages.WorkbenchUserAuthenticator_cancelled);
- }
-
- if(userinfo.isUsernameMutable()){
- userinfo.setUsername(result[0]);
-
- }
- userinfo.setPassword(result[1]);
-
- if(location!=null){
- if(userinfo.isUsernameMutable()){
- location.setUsername(result[0]);
- }
- location.setPassword(result[1]);
- if(location.getPasswordStore()!=null){
- if(allowCaching[0])
- location.getPasswordStore().update(location);
- else
- location.getPasswordStore().clear(location);
- }
- }
- }
-
- /**
- * Asks the user to enter a password. Places the
- * results in the supplied string[]. result[0] must
- * contain the username, result[1] must contain the password.
- * If the user canceled, both values must be zero.
- *
- * @param location the location to obtain the password for
- * @param username the username
- * @param message a message to display to the user
- * @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
- */
- protected boolean promptForPassword(final IJSchLocation location,
- final String username, final String message, final boolean userMutable,
- final String[] result){
- String comment=location==null ? null : location.getComment();
- UserValidationDialog dialog=new UserValidationDialog(null, comment,
- (username==null) ? "" : username, message, (location!=null && location.getPasswordStore()!=null));//$NON-NLS-1$
- dialog.setUsernameMutable(userMutable);
- dialog.open();
- result[0]=dialog.getUsername();
- result[1]=dialog.getPassword();
- return dialog.getAllowCaching();
- }
-
- /**
- * Asks the user to enter values.
- *
- * @param location the location to obtain the password for
- * @param destination the location
- * @param name the name
- * @param instruction the instruction
- * @param prompt the titles for text fields
- * @param echo '*' should be used or not
- * @return the entered values, or null if user canceled.
- */
- @Override
+ }
+
+ if(result[0]==null){
+ throw new OperationCanceledException(
+ Messages.WorkbenchUserAuthenticator_cancelled);
+ }
+
+ if(userinfo.isUsernameMutable()){
+ userinfo.setUsername(result[0]);
+
+ }
+ userinfo.setPassword(result[1]);
+
+ if(location!=null){
+ if(userinfo.isUsernameMutable()){
+ location.setUsername(result[0]);
+ }
+ location.setPassword(result[1]);
+ if(location.getPasswordStore()!=null){
+ if(allowCaching[0])
+ location.getPasswordStore().update(location);
+ else
+ location.getPasswordStore().clear(location);
+ }
+ }
+ }
+
+ /**
+ * Asks the user to enter a password. Places the
+ * results in the supplied string[]. result[0] must
+ * contain the username, result[1] must contain the password.
+ * If the user canceled, both values must be zero.
+ *
+ * @param location the location to obtain the password for
+ * @param username the username
+ * @param message a message to display to the user
+ * @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
+ */
+ protected boolean promptForPassword(final IJSchLocation location,
+ final String username, final String message, final boolean userMutable,
+ final String[] result){
+ String comment=location==null ? null : location.getComment();
+ UserValidationDialog dialog=new UserValidationDialog(null, comment,
+ (username==null) ? "" : username, message, (location!=null && location.getPasswordStore()!=null));//$NON-NLS-1$
+ dialog.setUsernameMutable(userMutable);
+ dialog.open();
+ result[0]=dialog.getUsername();
+ result[1]=dialog.getPassword();
+ return dialog.getAllowCaching();
+ }
+
+ /**
+ * Asks the user to enter values.
+ *
+ * @param location the location to obtain the password for
+ * @param destination the location
+ * @param name the name
+ * @param instruction the instruction
+ * @param prompt the titles for text fields
+ * @param echo '*' should be used or not
+ * @return the entered values, or null if user canceled.
+ */
+ @Override
public String[] promptForKeyboradInteractive(
- final IJSchLocation location, final String destination,
- final String name, final String instruction, final String[] prompt,
- final boolean[] echo){
- final String[][] result=new String[1][];
- final boolean[] allowCaching=new boolean[1];
- Display display=Display.getCurrent();
- if(display!=null){
- result[0]=_promptForUserInteractive(location, destination, name,
- instruction, prompt, echo, allowCaching);
- }
- else{
- // sync exec in default thread
+ final IJSchLocation location, final String destination,
+ final String name, final String instruction, final String[] prompt,
+ final boolean[] echo){
+ final String[][] result=new String[1][];
+ final boolean[] allowCaching=new boolean[1];
+ Display display=Display.getCurrent();
+ if(display!=null){
+ result[0]=_promptForUserInteractive(location, destination, name,
+ instruction, prompt, echo, allowCaching);
+ }
+ else{
+ // sync exec in default thread
Display.getDefault().syncExec(() -> result[0] = _promptForUserInteractive(location, destination, name,
instruction, prompt, echo, allowCaching));
- }
- if(result[0]!=null && location!=null &&
- prompt!=null && prompt.length==1 && prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
- location.setPassword(result[0][0]);
- if(location.getPasswordStore()!=null){
- if(allowCaching[0])
- location.getPasswordStore().update(location);
- else
- location.getPasswordStore().clear(location);
- }
- }
- return result[0];
- }
-
- protected String[] _promptForUserInteractive(
- final IJSchLocation location, final String destination,
- final String name, final String instruction, final String[] prompt,
- final boolean[] echo, final boolean[] allowCaching){
- String comment=location==null ? null : location.getComment();
- String username=location==null ? "" : location.getUsername(); //$NON-NLS-1$
- KeyboardInteractiveDialog dialog=new KeyboardInteractiveDialog(null,
- comment, destination, name, username, instruction, prompt, echo);
- dialog.setUsernameMutable(false);
- dialog.open();
- String[] _result=dialog.getResult();
- if(_result!=null)
- allowCaching[0]=dialog.getAllowCaching();
- return _result;
- }
-
-
- @Override
+ }
+ if(result[0]!=null && location!=null &&
+ prompt!=null && prompt.length==1 && prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
+ location.setPassword(result[0][0]);
+ if(location.getPasswordStore()!=null){
+ if(allowCaching[0])
+ location.getPasswordStore().update(location);
+ else
+ location.getPasswordStore().clear(location);
+ }
+ }
+ return result[0];
+ }
+
+ protected String[] _promptForUserInteractive(
+ final IJSchLocation location, final String destination,
+ final String name, final String instruction, final String[] prompt,
+ final boolean[] echo, final boolean[] allowCaching){
+ String comment=location==null ? null : location.getComment();
+ String username=location==null ? "" : location.getUsername(); //$NON-NLS-1$
+ KeyboardInteractiveDialog dialog=new KeyboardInteractiveDialog(null,
+ comment, destination, name, username, instruction, prompt, echo);
+ dialog.setUsernameMutable(false);
+ dialog.open();
+ String[] _result=dialog.getResult();
+ if(_result!=null)
+ allowCaching[0]=dialog.getAllowCaching();
+ return _result;
+ }
+
+
+ @Override
public int prompt(IJSchLocation location, final int promptType,
- final String title, final String message, final int[] promptResponses,
- final int defaultResponse){
- final Display display=getStandardDisplay();
- final int[] retval=new int[1];
- final String[] buttons=new String[promptResponses.length];
- for(int i=0; i<promptResponses.length; i++){
- int prompt=promptResponses[i];
- switch(prompt){
- case IUserAuthenticator.OK_ID:
- buttons[i]=IDialogConstants.OK_LABEL;
- break;
- case IUserAuthenticator.CANCEL_ID:
- buttons[i]=IDialogConstants.CANCEL_LABEL;
- break;
- case IUserAuthenticator.NO_ID:
- buttons[i]=IDialogConstants.NO_LABEL;
- break;
- case IUserAuthenticator.YES_ID:
- buttons[i]=IDialogConstants.YES_LABEL;
- break;
- }
- }
+ final String title, final String message, final int[] promptResponses,
+ final int defaultResponse){
+ final Display display=getStandardDisplay();
+ final int[] retval=new int[1];
+ final String[] buttons=new String[promptResponses.length];
+ for(int i=0; i<promptResponses.length; i++){
+ int prompt=promptResponses[i];
+ switch(prompt){
+ case IUserAuthenticator.OK_ID:
+ buttons[i]=IDialogConstants.OK_LABEL;
+ break;
+ case IUserAuthenticator.CANCEL_ID:
+ buttons[i]=IDialogConstants.CANCEL_LABEL;
+ break;
+ case IUserAuthenticator.NO_ID:
+ buttons[i]=IDialogConstants.NO_LABEL;
+ break;
+ case IUserAuthenticator.YES_ID:
+ buttons[i]=IDialogConstants.YES_LABEL;
+ break;
+ }
+ }
display.syncExec(() -> {
Shell shell = null;
@@ -207,35 +207,35 @@ public int prompt(IJSchLocation location, final int promptType,
shell = new Shell(display);
}
final MessageDialog dialog = new MessageDialog(shell, title,
- null, message, promptType, buttons, 1);
- retval[0]=dialog.open();
+ null, message, promptType, buttons, 1);
+ retval[0]=dialog.open();
});
- return retval[0];
- }
+ return retval[0];
+ }
- @Override
+ @Override
public boolean promptForHostKeyChange(final IJSchLocation location){
- final boolean[] openConfirm=new boolean[] {false};
- final Display display=getStandardDisplay();
+ final boolean[] openConfirm=new boolean[] {false};
+ final Display display=getStandardDisplay();
display.syncExec(() -> openConfirm[0] = MessageDialog.openConfirm(null, Messages.WorkbenchUserAuthenticator_1,
NLS.bind(Messages.WorkbenchUserAuthenticator_2, new String[] { location.getHost() })));
- if(!openConfirm[0]){
- throw new OperationCanceledException();
- }
- return openConfirm[0];
- }
-
- /**
- * Returns the standard display to be used. The method first checks, if
- * the thread calling this method has an associated display. If so, this
- * display is returned. Otherwise the method returns the default display.
- * @return standard display
- */
- private Display getStandardDisplay(){
- Display display=Display.getCurrent();
- if(display==null){
- display=Display.getDefault();
- }
- return display;
- }
+ if(!openConfirm[0]){
+ throw new OperationCanceledException();
+ }
+ return openConfirm[0];
+ }
+
+ /**
+ * Returns the standard display to be used. The method first checks, if
+ * the thread calling this method has an associated display. If so, this
+ * display is returned. Otherwise the method returns the default display.
+ * @return standard display
+ */
+ private Display getStandardDisplay(){
+ Display display=Display.getCurrent();
+ if(display==null){
+ display=Display.getDefault();
+ }
+ return display;
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/ExportDialog.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/ExportDialog.java
index b7cb27825..df4c889aa 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/ExportDialog.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/ExportDialog.java
@@ -28,76 +28,76 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
class ExportDialog extends Dialog{
- protected Text field;
- protected String target=null;
- protected String title=null;
- protected String message=null;
+ protected Text field;
+ protected String target=null;
+ protected String title=null;
+ protected String message=null;
- public ExportDialog(Shell parentShell, String title, String message){
- super(parentShell);
- this.title=title;
- this.message=message;
- }
+ public ExportDialog(Shell parentShell, String title, String message){
+ super(parentShell);
+ this.title=title;
+ this.message=message;
+ }
- protected void configureShell(Shell newShell){
- super.configureShell(newShell);
- newShell.setText(title);
- }
+ protected void configureShell(Shell newShell){
+ super.configureShell(newShell);
+ newShell.setText(title);
+ }
- public void create(){
- super.create();
- field.setFocus();
- }
+ public void create(){
+ super.create();
+ field.setFocus();
+ }
- protected Control createDialogArea(Composite parent){
- initializeDialogUnits(parent);
- Composite main=new Composite(parent, SWT.NONE);
- GridLayout layout=new GridLayout();
- layout.numColumns=2;
- layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- main.setLayout(layout);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
+ protected Control createDialogArea(Composite parent){
+ initializeDialogUnits(parent);
+ Composite main=new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ layout.numColumns=2;
+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_BOTH));
- if(message!=null){
- Label messageLabel=new Label(main, SWT.WRAP);
- messageLabel.setText(message);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=2;
- messageLabel.setLayoutData(data);
- }
+ if(message!=null){
+ Label messageLabel=new Label(main, SWT.WRAP);
+ messageLabel.setText(message);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=2;
+ messageLabel.setLayoutData(data);
+ }
- createTargetFields(main);
- Dialog.applyDialogFont(main);
- return main;
- }
+ createTargetFields(main);
+ Dialog.applyDialogFont(main);
+ return main;
+ }
- protected void createTargetFields(Composite parent){
- new Label(parent, SWT.NONE).setText(Messages.CVSSSH2PreferencePage_125);
+ protected void createTargetFields(Composite parent){
+ new Label(parent, SWT.NONE).setText(Messages.CVSSSH2PreferencePage_125);
- field=new Text(parent, SWT.BORDER);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- field.setLayoutData(data);
- }
+ field=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ field.setLayoutData(data);
+ }
- public String getTarget(){
- return target;
- }
+ public String getTarget(){
+ return target;
+ }
- protected void okPressed(){
- String _target=field.getText();
- if(_target==null||_target.length()==0){
- return;
- }
- target=_target;
- super.okPressed();
- }
+ protected void okPressed(){
+ String _target=field.getText();
+ if(_target==null||_target.length()==0){
+ return;
+ }
+ target=_target;
+ super.okPressed();
+ }
- protected void cancelPressed(){
- target=null;
- super.cancelPressed();
- }
+ protected void cancelPressed(){
+ target=null;
+ super.cancelPressed();
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PassphraseDialog.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PassphraseDialog.java
index bd092f433..e30f18d4c 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PassphraseDialog.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PassphraseDialog.java
@@ -28,77 +28,77 @@ import org.eclipse.swt.widgets.Text;
class PassphraseDialog extends Dialog{
- protected Text passphraseField;
- protected String passphrase=null;
- protected String message=null;
+ protected Text passphraseField;
+ protected String passphrase=null;
+ protected String message=null;
- public PassphraseDialog(Shell parentShell, String message){
- super(parentShell);
- this.message=message;
- }
+ public PassphraseDialog(Shell parentShell, String message){
+ super(parentShell);
+ this.message=message;
+ }
- protected void configureShell(Shell newShell){
- super.configureShell(newShell);
- newShell.setText(message);
- }
+ protected void configureShell(Shell newShell){
+ super.configureShell(newShell);
+ newShell.setText(message);
+ }
- public void create(){
- super.create();
- passphraseField.setFocus();
- }
+ public void create(){
+ super.create();
+ passphraseField.setFocus();
+ }
- protected Control createDialogArea(Composite parent){
- initializeDialogUnits(parent);
- Composite main=new Composite(parent, SWT.NONE);
+ protected Control createDialogArea(Composite parent){
+ initializeDialogUnits(parent);
+ Composite main=new Composite(parent, SWT.NONE);
- GridLayout layout=new GridLayout();
- layout.numColumns=3;
- layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- main.setLayout(layout);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout=new GridLayout();
+ layout.numColumns=3;
+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_BOTH));
- if(message!=null){
- Label messageLabel=new Label(main, SWT.WRAP);
- messageLabel.setText(message);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan=3;
- messageLabel.setLayoutData(data);
- }
+ if(message!=null){
+ Label messageLabel=new Label(main, SWT.WRAP);
+ messageLabel.setText(message);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=3;
+ messageLabel.setLayoutData(data);
+ }
- createPassphraseFields(main);
- Dialog.applyDialogFont(main);
- return main;
- }
+ createPassphraseFields(main);
+ Dialog.applyDialogFont(main);
+ return main;
+ }
- protected void createPassphraseFields(Composite parent){
- new Label(parent, SWT.NONE).setText(Messages.CVSSSH2PreferencePage_127);
- passphraseField=new Text(parent, SWT.BORDER);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- passphraseField.setLayoutData(data);
- passphraseField.setEchoChar('*');
+ protected void createPassphraseFields(Composite parent){
+ new Label(parent, SWT.NONE).setText(Messages.CVSSSH2PreferencePage_127);
+ passphraseField=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ passphraseField.setLayoutData(data);
+ passphraseField.setEchoChar('*');
- new Label(parent, SWT.NONE);
- }
+ new Label(parent, SWT.NONE);
+ }
- public String getPassphrase(){
- return passphrase;
- }
+ public String getPassphrase(){
+ return passphrase;
+ }
- protected void okPressed(){
- String _passphrase=passphraseField.getText();
- if(_passphrase==null||_passphrase.length()==0){
- return;
- }
- passphrase=_passphrase;
- super.okPressed();
- }
+ protected void okPressed(){
+ String _passphrase=passphraseField.getText();
+ if(_passphrase==null||_passphrase.length()==0){
+ return;
+ }
+ passphrase=_passphrase;
+ super.okPressed();
+ }
- protected void cancelPressed(){
- passphrase=null;
- super.cancelPressed();
- }
+ protected void cancelPressed(){
+ passphrase=null;
+ super.cancelPressed();
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PixelConverter.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PixelConverter.java
index 73198c8c5..4a6fc150c 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PixelConverter.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PixelConverter.java
@@ -25,12 +25,12 @@ public class PixelConverter {
public PixelConverter(Control control) {
GC gc = new GC(control);
- try {
- gc.setFont(control.getFont());
- fFontMetrics= gc.getFontMetrics();
- } finally {
- gc.dispose();
- }
+ try {
+ gc.setFont(control.getFont());
+ fFontMetrics= gc.getFontMetrics();
+ } finally {
+ gc.dispose();
+ }
}
public int convertHeightInCharsToPixels(int chars) {
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 5685e34c0..6544592a8 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
@@ -86,416 +86,416 @@ import com.jcraft.jsch.SftpATTRS;
import com.jcraft.jsch.SftpException;
public class PreferencePage extends org.eclipse.jface.preference.PreferencePage
- implements IWorkbenchPreferencePage{
-
- private static final String SSH2_PREFERENCE_PAGE_CONTEXT="org.eclipse.jsch.ui.ssh2_preference_page_context"; //$NON-NLS-1$
-
- private Label ssh2HomeLabel;
- private Label privateKeyLabel;
- Text ssh2HomeText;
- Text privateKeyText;
- private Button privateKeyAdd;
-
- private Button ssh2HomeBrowse;
- Button keyGenerateDSA;
- Button keyGenerateRSA;
- private Button keyLoad;
- private Button keyExport;
- Button saveKeyPair;
- private Label keyCommentLabel;
- Text keyCommentText;
- private Label keyFingerPrintLabel;
- Text keyFingerPrintText;
- private Label keyPassphrase1Label;
- Text keyPassphrase1Text;
- private Label keyPassphrase2Label;
- Text keyPassphrase2Text;
- private Label publicKeylabel;
- Text publicKeyText;
- KeyPair kpair=null;
- String kpairComment;
-
- public static final String AUTH_SCHEME="";//$NON-NLS-1$
-
- public PreferencePage(){
- setDescription(Messages.CVSSSH2PreferencePage_18);
- }
-
- @Override
+ implements IWorkbenchPreferencePage{
+
+ private static final String SSH2_PREFERENCE_PAGE_CONTEXT="org.eclipse.jsch.ui.ssh2_preference_page_context"; //$NON-NLS-1$
+
+ private Label ssh2HomeLabel;
+ private Label privateKeyLabel;
+ Text ssh2HomeText;
+ Text privateKeyText;
+ private Button privateKeyAdd;
+
+ private Button ssh2HomeBrowse;
+ Button keyGenerateDSA;
+ Button keyGenerateRSA;
+ private Button keyLoad;
+ private Button keyExport;
+ Button saveKeyPair;
+ private Label keyCommentLabel;
+ Text keyCommentText;
+ private Label keyFingerPrintLabel;
+ Text keyFingerPrintText;
+ private Label keyPassphrase1Label;
+ Text keyPassphrase1Text;
+ private Label keyPassphrase2Label;
+ Text keyPassphrase2Text;
+ private Label publicKeylabel;
+ Text publicKeyText;
+ KeyPair kpair=null;
+ String kpairComment;
+
+ public static final String AUTH_SCHEME="";//$NON-NLS-1$
+
+ public PreferencePage(){
+ setDescription(Messages.CVSSSH2PreferencePage_18);
+ }
+
+ @Override
protected Control createContents(Composite parent){
- Composite container=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- container.setLayout(layout);
- initializeDialogUnits(container);
-
- CTabFolder tabFolder=new CTabFolder(container, SWT.NONE);
- tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- CTabItem tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_19);
- tabItem.setControl(createGeneralPage(tabFolder));
-
- tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_21);
- tabItem.setControl(createKeyManagementPage(tabFolder));
-
- tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_133);
- tabItem.setControl(createHostKeyManagementPage(tabFolder));
-
- tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_137);
- tabItem.setControl(createPreferredAuthenticationPage(tabFolder));
-
- tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_144);
- tabItem.setControl(createPreferredKeyExchangePage(tabFolder));
-
- tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_145);
- tabItem.setControl(createPreferredMACPage(tabFolder));
-
- tabItem=new CTabItem(tabFolder, SWT.NONE);
- tabItem.setText(Messages.CVSSSH2PreferencePage_146);
- tabItem.setControl(createPreferredSSHAgentPage(tabFolder));
- tabFolder.setSelection(0);
- initControls();
-
- Dialog.applyDialogFont(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
- SSH2_PREFERENCE_PAGE_CONTEXT);
- return container;
- }
-
- private Control createGeneralPage(Composite parent){
- Composite group=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- layout.numColumns=3;
- layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- group.setLayout(layout);
- GridData data=new GridData();
- data.horizontalAlignment=GridData.FILL;
- group.setLayoutData(data);
-
- ssh2HomeLabel=new Label(group, SWT.NONE);
- ssh2HomeLabel.setText(Messages.CVSSSH2PreferencePage_23);
-
- ssh2HomeText=new Text(group, SWT.SINGLE|SWT.BORDER);
- ssh2HomeText.setFont(group.getFont());
- GridData gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=1;
- ssh2HomeText.setLayoutData(gd);
-
- ssh2HomeBrowse=new Button(group, SWT.NULL);
- ssh2HomeBrowse.setText(Messages.CVSSSH2PreferencePage_24);
- gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan=1;
- ssh2HomeBrowse.setLayoutData(gd);
-
- createSpacer(group, 3);
-
- privateKeyLabel=new Label(group, SWT.NONE);
- privateKeyLabel.setText(Messages.CVSSSH2PreferencePage_25);
-
- privateKeyText=new Text(group, SWT.SINGLE|SWT.BORDER);
- privateKeyText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=1;
- privateKeyText.setLayoutData(gd);
-
- privateKeyAdd=new Button(group, SWT.NULL);
- privateKeyAdd.setText(Messages.CVSSSH2PreferencePage_26);
- gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan=1;
- privateKeyAdd.setLayoutData(gd);
-
- ssh2HomeBrowse.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- String home=ssh2HomeText.getText();
-
- if(!new File(home).exists()){
- while(true){
- int foo=home.lastIndexOf(java.io.File.separator, home.length());
- if(foo==-1)
- break;
- home=home.substring(0, foo);
- if(new File(home).exists())
- break;
- }
- }
-
- DirectoryDialog dd=new DirectoryDialog(getShell());
- dd.setFilterPath(home);
- dd.setMessage(Messages.CVSSSH2PreferencePage_27);
- String dir=dd.open();
- if(dir==null){ // cancel
- return;
- }
- ssh2HomeText.setText(dir);
- }
- });
-
- privateKeyAdd.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- String home=ssh2HomeText.getText();
-
- FileDialog fd=new FileDialog(getShell(), SWT.OPEN|SWT.MULTI);
- fd.setFilterPath(home);
- Object o=fd.open();
- if(o==null){ // cancel
- return;
- }
- String[] files=fd.getFileNames();
- String keys=privateKeyText.getText();
- String dir=fd.getFilterPath();
- if(dir.equals(home)){
- dir="";} //$NON-NLS-1$
- else{
- dir+=java.io.File.separator;
- }
-
- for(int i=0; i<files.length; i++){
- String foo=files[i];
- if(keys.length()!=0)
- keys=keys+","; //$NON-NLS-1$
- keys=keys+dir+foo;
- }
- privateKeyText.setText(keys);
- }
- });
-
- return group;
- }
-
- private Control createKeyManagementPage(Composite parent){
- int columnSpan=3;
- Composite group=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- layout.numColumns=3;
- layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- group.setLayout(layout);
- GridData gd=new GridData();
- gd.horizontalAlignment=GridData.FILL;
- group.setLayoutData(gd);
-
- keyGenerateDSA=new Button(group, SWT.NULL);
- keyGenerateDSA.setText(Messages.CVSSSH2PreferencePage_131);
- gd=new GridData();
- gd.horizontalSpan=1;
- keyGenerateDSA.setLayoutData(gd);
-
- keyGenerateRSA=new Button(group, SWT.NULL);
- keyGenerateRSA.setText(Messages.CVSSSH2PreferencePage_132);
- gd=new GridData();
- gd.horizontalSpan=1;
- keyGenerateRSA.setLayoutData(gd);
-
- keyLoad=new Button(group, SWT.NULL);
- keyLoad.setText(Messages.CVSSSH2PreferencePage_128);
- gd=new GridData();
- gd.horizontalSpan=1;
- keyLoad.setLayoutData(gd);
-
- publicKeylabel=new Label(group, SWT.NONE);
- publicKeylabel.setText(Messages.CVSSSH2PreferencePage_39);
- gd=new GridData();
- gd.horizontalSpan=columnSpan;
- publicKeylabel.setLayoutData(gd);
-
- publicKeyText=new Text(group, SWT.MULTI|SWT.BORDER|SWT.V_SCROLL|SWT.WRAP|SWT.LEFT_TO_RIGHT);
- publicKeyText.setText(""); //$NON-NLS-1$
- publicKeyText.setEditable(false);
- gd=new GridData();
- gd.horizontalSpan=columnSpan;
- gd.horizontalAlignment=GridData.FILL;
- gd.verticalAlignment=GridData.FILL;
- gd.grabExcessHorizontalSpace=true;
- gd.grabExcessVerticalSpace=true;
- publicKeyText.setLayoutData(gd);
-
- keyFingerPrintLabel=new Label(group, SWT.NONE);
- keyFingerPrintLabel.setText(Messages.CVSSSH2PreferencePage_41);
- keyFingerPrintText=new Text(group, SWT.SINGLE|SWT.BORDER|SWT.LEFT_TO_RIGHT);
- keyFingerPrintText.setFont(group.getFont());
- keyFingerPrintText.setEditable(false);
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- keyFingerPrintText.setLayoutData(gd);
-
- keyCommentLabel=new Label(group, SWT.NONE);
- keyCommentLabel.setText(Messages.CVSSSH2PreferencePage_42);
- keyCommentText=new Text(group, SWT.SINGLE|SWT.BORDER);
- keyCommentText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- keyCommentText.setLayoutData(gd);
+ Composite container=new Composite(parent, SWT.NULL);
+ GridLayout layout=new GridLayout();
+ container.setLayout(layout);
+ initializeDialogUnits(container);
+
+ CTabFolder tabFolder=new CTabFolder(container, SWT.NONE);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ CTabItem tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_19);
+ tabItem.setControl(createGeneralPage(tabFolder));
+
+ tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_21);
+ tabItem.setControl(createKeyManagementPage(tabFolder));
+
+ tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_133);
+ tabItem.setControl(createHostKeyManagementPage(tabFolder));
+
+ tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_137);
+ tabItem.setControl(createPreferredAuthenticationPage(tabFolder));
+
+ tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_144);
+ tabItem.setControl(createPreferredKeyExchangePage(tabFolder));
+
+ tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_145);
+ tabItem.setControl(createPreferredMACPage(tabFolder));
+
+ tabItem=new CTabItem(tabFolder, SWT.NONE);
+ tabItem.setText(Messages.CVSSSH2PreferencePage_146);
+ tabItem.setControl(createPreferredSSHAgentPage(tabFolder));
+ tabFolder.setSelection(0);
+ initControls();
+
+ Dialog.applyDialogFont(parent);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+ SSH2_PREFERENCE_PAGE_CONTEXT);
+ return container;
+ }
+
+ private Control createGeneralPage(Composite parent){
+ Composite group=new Composite(parent, SWT.NULL);
+ GridLayout layout=new GridLayout();
+ layout.numColumns=3;
+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ group.setLayout(layout);
+ GridData data=new GridData();
+ data.horizontalAlignment=GridData.FILL;
+ group.setLayoutData(data);
+
+ ssh2HomeLabel=new Label(group, SWT.NONE);
+ ssh2HomeLabel.setText(Messages.CVSSSH2PreferencePage_23);
+
+ ssh2HomeText=new Text(group, SWT.SINGLE|SWT.BORDER);
+ ssh2HomeText.setFont(group.getFont());
+ GridData gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=1;
+ ssh2HomeText.setLayoutData(gd);
+
+ ssh2HomeBrowse=new Button(group, SWT.NULL);
+ ssh2HomeBrowse.setText(Messages.CVSSSH2PreferencePage_24);
+ gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan=1;
+ ssh2HomeBrowse.setLayoutData(gd);
+
+ createSpacer(group, 3);
+
+ privateKeyLabel=new Label(group, SWT.NONE);
+ privateKeyLabel.setText(Messages.CVSSSH2PreferencePage_25);
+
+ privateKeyText=new Text(group, SWT.SINGLE|SWT.BORDER);
+ privateKeyText.setFont(group.getFont());
+ gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=1;
+ privateKeyText.setLayoutData(gd);
+
+ privateKeyAdd=new Button(group, SWT.NULL);
+ privateKeyAdd.setText(Messages.CVSSSH2PreferencePage_26);
+ gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan=1;
+ privateKeyAdd.setLayoutData(gd);
+
+ ssh2HomeBrowse.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ String home=ssh2HomeText.getText();
+
+ if(!new File(home).exists()){
+ while(true){
+ int foo=home.lastIndexOf(java.io.File.separator, home.length());
+ if(foo==-1)
+ break;
+ home=home.substring(0, foo);
+ if(new File(home).exists())
+ break;
+ }
+ }
+
+ DirectoryDialog dd=new DirectoryDialog(getShell());
+ dd.setFilterPath(home);
+ dd.setMessage(Messages.CVSSSH2PreferencePage_27);
+ String dir=dd.open();
+ if(dir==null){ // cancel
+ return;
+ }
+ ssh2HomeText.setText(dir);
+ }
+ });
+
+ privateKeyAdd.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ String home=ssh2HomeText.getText();
+
+ FileDialog fd=new FileDialog(getShell(), SWT.OPEN|SWT.MULTI);
+ fd.setFilterPath(home);
+ Object o=fd.open();
+ if(o==null){ // cancel
+ return;
+ }
+ String[] files=fd.getFileNames();
+ String keys=privateKeyText.getText();
+ String dir=fd.getFilterPath();
+ if(dir.equals(home)){
+ dir="";} //$NON-NLS-1$
+ else{
+ dir+=java.io.File.separator;
+ }
+
+ for(int i=0; i<files.length; i++){
+ String foo=files[i];
+ if(keys.length()!=0)
+ keys=keys+","; //$NON-NLS-1$
+ keys=keys+dir+foo;
+ }
+ privateKeyText.setText(keys);
+ }
+ });
+
+ return group;
+ }
+
+ private Control createKeyManagementPage(Composite parent){
+ int columnSpan=3;
+ Composite group=new Composite(parent, SWT.NULL);
+ GridLayout layout=new GridLayout();
+ layout.numColumns=3;
+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ group.setLayout(layout);
+ GridData gd=new GridData();
+ gd.horizontalAlignment=GridData.FILL;
+ group.setLayoutData(gd);
+
+ keyGenerateDSA=new Button(group, SWT.NULL);
+ keyGenerateDSA.setText(Messages.CVSSSH2PreferencePage_131);
+ gd=new GridData();
+ gd.horizontalSpan=1;
+ keyGenerateDSA.setLayoutData(gd);
+
+ keyGenerateRSA=new Button(group, SWT.NULL);
+ keyGenerateRSA.setText(Messages.CVSSSH2PreferencePage_132);
+ gd=new GridData();
+ gd.horizontalSpan=1;
+ keyGenerateRSA.setLayoutData(gd);
+
+ keyLoad=new Button(group, SWT.NULL);
+ keyLoad.setText(Messages.CVSSSH2PreferencePage_128);
+ gd=new GridData();
+ gd.horizontalSpan=1;
+ keyLoad.setLayoutData(gd);
+
+ publicKeylabel=new Label(group, SWT.NONE);
+ publicKeylabel.setText(Messages.CVSSSH2PreferencePage_39);
+ gd=new GridData();
+ gd.horizontalSpan=columnSpan;
+ publicKeylabel.setLayoutData(gd);
+
+ publicKeyText=new Text(group, SWT.MULTI|SWT.BORDER|SWT.V_SCROLL|SWT.WRAP|SWT.LEFT_TO_RIGHT);
+ publicKeyText.setText(""); //$NON-NLS-1$
+ publicKeyText.setEditable(false);
+ gd=new GridData();
+ gd.horizontalSpan=columnSpan;
+ gd.horizontalAlignment=GridData.FILL;
+ gd.verticalAlignment=GridData.FILL;
+ gd.grabExcessHorizontalSpace=true;
+ gd.grabExcessVerticalSpace=true;
+ publicKeyText.setLayoutData(gd);
+
+ keyFingerPrintLabel=new Label(group, SWT.NONE);
+ keyFingerPrintLabel.setText(Messages.CVSSSH2PreferencePage_41);
+ keyFingerPrintText=new Text(group, SWT.SINGLE|SWT.BORDER|SWT.LEFT_TO_RIGHT);
+ keyFingerPrintText.setFont(group.getFont());
+ keyFingerPrintText.setEditable(false);
+ gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ keyFingerPrintText.setLayoutData(gd);
+
+ keyCommentLabel=new Label(group, SWT.NONE);
+ keyCommentLabel.setText(Messages.CVSSSH2PreferencePage_42);
+ keyCommentText=new Text(group, SWT.SINGLE|SWT.BORDER);
+ keyCommentText.setFont(group.getFont());
+ gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ keyCommentText.setLayoutData(gd);
keyCommentText.addModifyListener(e -> {
- if(kpair==null)
- return;
- try{
- ByteArrayOutputStream out=new ByteArrayOutputStream();
- kpairComment = keyCommentText.getText();
- kpair.writePublicKey(out, kpairComment);
- out.close();
- publicKeyText.setText(out.toString());
- }
- catch(IOException ee){
- // Ignore
- }
+ if(kpair==null)
+ return;
+ try{
+ ByteArrayOutputStream out=new ByteArrayOutputStream();
+ kpairComment = keyCommentText.getText();
+ kpair.writePublicKey(out, kpairComment);
+ out.close();
+ publicKeyText.setText(out.toString());
+ }
+ catch(IOException ee){
+ // Ignore
+ }
});
- keyPassphrase1Label=new Label(group, SWT.NONE);
- keyPassphrase1Label.setText(Messages.CVSSSH2PreferencePage_43);
- keyPassphrase1Text=new Text(group, SWT.SINGLE|SWT.BORDER);
- keyPassphrase1Text.setFont(group.getFont());
- keyPassphrase1Text.setEchoChar('*');
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- keyPassphrase1Text.setLayoutData(gd);
-
- keyPassphrase2Label=new Label(group, SWT.NONE);
- keyPassphrase2Label.setText(Messages.CVSSSH2PreferencePage_44);
- keyPassphrase2Text=new Text(group, SWT.SINGLE|SWT.BORDER);
- keyPassphrase2Text.setFont(group.getFont());
- keyPassphrase2Text.setEchoChar('*');
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- keyPassphrase2Text.setLayoutData(gd);
+ keyPassphrase1Label=new Label(group, SWT.NONE);
+ keyPassphrase1Label.setText(Messages.CVSSSH2PreferencePage_43);
+ keyPassphrase1Text=new Text(group, SWT.SINGLE|SWT.BORDER);
+ keyPassphrase1Text.setFont(group.getFont());
+ keyPassphrase1Text.setEchoChar('*');
+ gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ keyPassphrase1Text.setLayoutData(gd);
+
+ keyPassphrase2Label=new Label(group, SWT.NONE);
+ keyPassphrase2Label.setText(Messages.CVSSSH2PreferencePage_44);
+ keyPassphrase2Text=new Text(group, SWT.SINGLE|SWT.BORDER);
+ keyPassphrase2Text.setFont(group.getFont());
+ keyPassphrase2Text.setEchoChar('*');
+ gd=new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan=2;
+ keyPassphrase2Text.setLayoutData(gd);
keyPassphrase1Text.addModifyListener(e -> {
- String pass1=keyPassphrase1Text.getText();
- String pass2=keyPassphrase2Text.getText();
- if(kpair!=null&&pass1.equals(pass2)){
- saveKeyPair.setEnabled(true);
- }
- else{
- saveKeyPair.setEnabled(false);
- }
- if(pass2.length()==0){
- setErrorMessage(null);
- return;
- }
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_48);
- }
+ String pass1=keyPassphrase1Text.getText();
+ String pass2=keyPassphrase2Text.getText();
+ if(kpair!=null&&pass1.equals(pass2)){
+ saveKeyPair.setEnabled(true);
+ }
+ else{
+ saveKeyPair.setEnabled(false);
+ }
+ if(pass2.length()==0){
+ setErrorMessage(null);
+ return;
+ }
+ if(pass1.equals(pass2)){
+ setErrorMessage(null);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_48);
+ }
});
keyPassphrase2Text.addModifyListener(e -> {
- String pass1=keyPassphrase1Text.getText();
- String pass2=keyPassphrase2Text.getText();
- if(kpair!=null&&pass1.equals(pass2)){
- saveKeyPair.setEnabled(true);
- }
- else{
- saveKeyPair.setEnabled(false);
- }
- if(pass2.length()<pass1.length()){
- if(pass1.startsWith(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_48);
- }
- return;
- }
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_48);
- }
+ String pass1=keyPassphrase1Text.getText();
+ String pass2=keyPassphrase2Text.getText();
+ if(kpair!=null&&pass1.equals(pass2)){
+ saveKeyPair.setEnabled(true);
+ }
+ else{
+ saveKeyPair.setEnabled(false);
+ }
+ if(pass2.length()<pass1.length()){
+ if(pass1.startsWith(pass2)){
+ setErrorMessage(null);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_48);
+ }
+ return;
+ }
+ if(pass1.equals(pass2)){
+ setErrorMessage(null);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_48);
+ }
});
- keyPassphrase2Text.addFocusListener(new FocusListener(){
- @Override
- public void focusGained(FocusEvent e){
- String pass1=keyPassphrase1Text.getText();
- String pass2=keyPassphrase2Text.getText();
- if(pass2.length()<pass1.length()){
- if(pass1.startsWith(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_48);
- }
- return;
- }
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_48);
- }
- }
-
- @Override
- public void focusLost(FocusEvent e){
- String pass1=keyPassphrase1Text.getText();
- String pass2=keyPassphrase2Text.getText();
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_48);
- }
- }
- });
-
- Composite buttons=new Composite(group, SWT.NONE);
- layout=new GridLayout(2, true);
- layout.marginWidth=0;
- layout.marginHeight=0;
- layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- buttons.setLayout(layout);
- gd=new GridData(GridData.HORIZONTAL_ALIGN_END);
- gd.horizontalSpan=columnSpan;
- buttons.setLayoutData(gd);
-
- keyExport=new Button(buttons, SWT.NULL);
- keyExport.setText(Messages.CVSSSH2PreferencePage_105);
- gd=new GridData(GridData.FILL_BOTH);
- keyExport.setLayoutData(gd);
-
- saveKeyPair=new Button(buttons, SWT.NULL);
- saveKeyPair.setText(Messages.CVSSSH2PreferencePage_45);
- gd=new GridData(GridData.FILL_BOTH);
- saveKeyPair.setLayoutData(gd);
-
- SelectionAdapter keygenadapter=new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- boolean ok=true;
- String _type=""; //$NON-NLS-1$
-
- try{
- int type=0;
- if(e.widget==keyGenerateDSA){
- type=KeyPair.DSA;
- _type=IConstants.DSA;
- }
- else if(e.widget==keyGenerateRSA){
- type=KeyPair.RSA;
- _type=IConstants.RSA;
- }
- else{
- return;
- }
-
- final KeyPair[] _kpair=new KeyPair[1];
- final int __type=type;
- final JSchException[] _e=new JSchException[1];
+ keyPassphrase2Text.addFocusListener(new FocusListener(){
+ @Override
+ public void focusGained(FocusEvent e){
+ String pass1=keyPassphrase1Text.getText();
+ String pass2=keyPassphrase2Text.getText();
+ if(pass2.length()<pass1.length()){
+ if(pass1.startsWith(pass2)){
+ setErrorMessage(null);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_48);
+ }
+ return;
+ }
+ if(pass1.equals(pass2)){
+ setErrorMessage(null);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_48);
+ }
+ }
+
+ @Override
+ public void focusLost(FocusEvent e){
+ String pass1=keyPassphrase1Text.getText();
+ String pass2=keyPassphrase2Text.getText();
+ if(pass1.equals(pass2)){
+ setErrorMessage(null);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_48);
+ }
+ }
+ });
+
+ Composite buttons=new Composite(group, SWT.NONE);
+ layout=new GridLayout(2, true);
+ layout.marginWidth=0;
+ layout.marginHeight=0;
+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ buttons.setLayout(layout);
+ gd=new GridData(GridData.HORIZONTAL_ALIGN_END);
+ gd.horizontalSpan=columnSpan;
+ buttons.setLayoutData(gd);
+
+ keyExport=new Button(buttons, SWT.NULL);
+ keyExport.setText(Messages.CVSSSH2PreferencePage_105);
+ gd=new GridData(GridData.FILL_BOTH);
+ keyExport.setLayoutData(gd);
+
+ saveKeyPair=new Button(buttons, SWT.NULL);
+ saveKeyPair.setText(Messages.CVSSSH2PreferencePage_45);
+ gd=new GridData(GridData.FILL_BOTH);
+ saveKeyPair.setLayoutData(gd);
+
+ SelectionAdapter keygenadapter=new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ boolean ok=true;
+ String _type=""; //$NON-NLS-1$
+
+ try{
+ int type=0;
+ if(e.widget==keyGenerateDSA){
+ type=KeyPair.DSA;
+ _type=IConstants.DSA;
+ }
+ else if(e.widget==keyGenerateRSA){
+ type=KeyPair.RSA;
+ _type=IConstants.RSA;
+ }
+ else{
+ return;
+ }
+
+ final KeyPair[] _kpair=new KeyPair[1];
+ final int __type=type;
+ final JSchException[] _e=new JSchException[1];
BusyIndicator.showWhile(getShell().getDisplay(), () -> {
try {
_kpair[0] = KeyPair.genKeyPair(getJSch(), __type);
@@ -503,148 +503,148 @@ protected Control createContents(Composite parent){
_e[0] = e1;
}
});
- if(_e[0]!=null){
- throw _e[0];
- }
- kpair=_kpair[0];
-
- ByteArrayOutputStream out=new ByteArrayOutputStream();
- kpairComment=_type+"-1024"; //$NON-NLS-1$
- kpair.writePublicKey(out, kpairComment);
- out.close();
- publicKeyText.setText(out.toString());
- keyFingerPrintText.setText(kpair.getFingerPrint());
- keyCommentText.setText(kpairComment);
- keyPassphrase1Text.setText(""); //$NON-NLS-1$
- keyPassphrase2Text.setText(""); //$NON-NLS-1$
- updateControls();
- }
- catch(IOException ee){
- ok=false;
- }
- catch(JSchException ee){
- ok=false;
- }
- if(!ok){
- MessageDialog.openError(getShell(),
- Messages.CVSSSH2PreferencePage_error,
- Messages.CVSSSH2PreferencePage_47);
- }
- }
- };
- keyGenerateDSA.addSelectionListener(keygenadapter);
- keyGenerateRSA.addSelectionListener(keygenadapter);
-
- keyLoad.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- boolean ok=true;
- String home=ssh2HomeText.getText();
- FileDialog fd=new FileDialog(getShell(), SWT.OPEN);
- fd.setFilterPath(home);
- Object o=fd.open();
- if(o==null){ // cancel
- return;
- }
- String pkey=fd.getFileName();
- String pkeyab=(new File(fd.getFilterPath(), pkey)).getAbsolutePath();
- try{
- KeyPair _kpair=KeyPair.load(getJSch(), pkeyab);
- PassphrasePrompt prompt=null;
- while(_kpair.isEncrypted()){
- if(prompt==null){
- prompt=new PassphrasePrompt(NLS.bind(
- Messages.CVSSSH2PreferencePage_126, new String[] {pkey}));
- }
- Display.getDefault().syncExec(prompt);
- String passphrase=prompt.getPassphrase();
- if(passphrase==null)
- break;
- if(_kpair.decrypt(passphrase)){
- break;
- }
- MessageDialog.openError(getShell(),
- Messages.CVSSSH2PreferencePage_error, NLS.bind(
- Messages.CVSSSH2PreferencePage_129, new String[] {pkey}));
- }
- if(_kpair.isEncrypted()){
- return;
- }
- kpair=_kpair;
- String _type=(kpair.getKeyType()==KeyPair.DSA) ? IConstants.DSA
- : IConstants.RSA;
- kpairComment=_type+"-1024"; //$NON-NLS-1$
-
- // TODO Bug 351094 The comment should be from kpair object,
- // but the JSch API does not provided such a method.
- // In the version 0.1.45, JSch will support such a method,
- // and the following code should be replaced with it at that time.
- java.io.FileInputStream fis=null;
- try{
- java.io.File f=new java.io.File(pkeyab+".pub"); //$NON-NLS-1$
- int i=0;
- fis=new java.io.FileInputStream(f);
- byte[] buf=new byte[(int)f.length()];
- while(i<buf.length){
- int j=fis.read(buf, i, buf.length-i);
- if(j<=0)
- break;
- i+=j;
- }
- String pubkey=new String(buf);
- if(pubkey.indexOf(' ')>0
- &&pubkey.indexOf(' ', pubkey.indexOf(' ')+1)>0){
- int j=pubkey.indexOf(' ', pubkey.indexOf(' ')+1)+1;
- kpairComment=pubkey.substring(j);
- if(kpairComment.indexOf('\n')>0){
- kpairComment=kpairComment.substring(0,
- kpairComment.indexOf('\n'));
- }
- }
- }
- catch(IOException ioe){
- // ignore if public-key does not exist.
- }
- finally{
- if(fis!=null)
- fis.close();
- }
-
- ByteArrayOutputStream out=new ByteArrayOutputStream();
-
- kpair.writePublicKey(out, kpairComment);
- out.close();
- publicKeyText.setText(out.toString());
- keyFingerPrintText.setText(kpair.getFingerPrint());
- keyCommentText.setText(kpairComment);
- keyPassphrase1Text.setText(""); //$NON-NLS-1$
- keyPassphrase2Text.setText(""); //$NON-NLS-1$
- updateControls();
- }
- catch(IOException ee){
- ok=false;
- }
- catch(JSchException ee){
- ok=false;
- }
- if(!ok){
- MessageDialog.openError(getShell(),
- Messages.CVSSSH2PreferencePage_error,
- Messages.CVSSSH2PreferencePage_130);
- }
- }
- });
-
- keyExport.addSelectionListener(new SelectionAdapter(){
- @Override
- public void widgetSelected(SelectionEvent e){
- if(kpair==null)
- return;
+ if(_e[0]!=null){
+ throw _e[0];
+ }
+ kpair=_kpair[0];
+
+ ByteArrayOutputStream out=new ByteArrayOutputStream();
+ kpairComment=_type+"-1024"; //$NON-NLS-1$
+ kpair.writePublicKey(out, kpairComment);
+ out.close();
+ publicKeyText.setText(out.toString());
+ keyFingerPrintText.setText(kpair.getFingerPrint());
+ keyCommentText.setText(kpairComment);
+ keyPassphrase1Text.setText(""); //$NON-NLS-1$
+ keyPassphrase2Text.setText(""); //$NON-NLS-1$
+ updateControls();
+ }
+ catch(IOException ee){
+ ok=false;
+ }
+ catch(JSchException ee){
+ ok=false;
+ }
+ if(!ok){
+ MessageDialog.openError(getShell(),
+ Messages.CVSSSH2PreferencePage_error,
+ Messages.CVSSSH2PreferencePage_47);
+ }
+ }
+ };
+ keyGenerateDSA.addSelectionListener(keygenadapter);
+ keyGenerateRSA.addSelectionListener(keygenadapter);
+
+ keyLoad.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ boolean ok=true;
+ String home=ssh2HomeText.getText();
+ FileDialog fd=new FileDialog(getShell(), SWT.OPEN);
+ fd.setFilterPath(home);
+ Object o=fd.open();
+ if(o==null){ // cancel
+ return;
+ }
+ String pkey=fd.getFileName();
+ String pkeyab=(new File(fd.getFilterPath(), pkey)).getAbsolutePath();
+ try{
+ KeyPair _kpair=KeyPair.load(getJSch(), pkeyab);
+ PassphrasePrompt prompt=null;
+ while(_kpair.isEncrypted()){
+ if(prompt==null){
+ prompt=new PassphrasePrompt(NLS.bind(
+ Messages.CVSSSH2PreferencePage_126, new String[] {pkey}));
+ }
+ Display.getDefault().syncExec(prompt);
+ String passphrase=prompt.getPassphrase();
+ if(passphrase==null)
+ break;
+ if(_kpair.decrypt(passphrase)){
+ break;
+ }
+ MessageDialog.openError(getShell(),
+ Messages.CVSSSH2PreferencePage_error, NLS.bind(
+ Messages.CVSSSH2PreferencePage_129, new String[] {pkey}));
+ }
+ if(_kpair.isEncrypted()){
+ return;
+ }
+ kpair=_kpair;
+ String _type=(kpair.getKeyType()==KeyPair.DSA) ? IConstants.DSA
+ : IConstants.RSA;
+ kpairComment=_type+"-1024"; //$NON-NLS-1$
+
+ // TODO Bug 351094 The comment should be from kpair object,
+ // but the JSch API does not provided such a method.
+ // In the version 0.1.45, JSch will support such a method,
+ // and the following code should be replaced with it at that time.
+ java.io.FileInputStream fis=null;
+ try{
+ java.io.File f=new java.io.File(pkeyab+".pub"); //$NON-NLS-1$
+ int i=0;
+ fis=new java.io.FileInputStream(f);
+ byte[] buf=new byte[(int)f.length()];
+ while(i<buf.length){
+ int j=fis.read(buf, i, buf.length-i);
+ if(j<=0)
+ break;
+ i+=j;
+ }
+ String pubkey=new String(buf);
+ if(pubkey.indexOf(' ')>0
+ &&pubkey.indexOf(' ', pubkey.indexOf(' ')+1)>0){
+ int j=pubkey.indexOf(' ', pubkey.indexOf(' ')+1)+1;
+ kpairComment=pubkey.substring(j);
+ if(kpairComment.indexOf('\n')>0){
+ kpairComment=kpairComment.substring(0,
+ kpairComment.indexOf('\n'));
+ }
+ }
+ }
+ catch(IOException ioe){
+ // ignore if public-key does not exist.
+ }
+ finally{
+ if(fis!=null)
+ fis.close();
+ }
+
+ ByteArrayOutputStream out=new ByteArrayOutputStream();
+
+ kpair.writePublicKey(out, kpairComment);
+ out.close();
+ publicKeyText.setText(out.toString());
+ keyFingerPrintText.setText(kpair.getFingerPrint());
+ keyCommentText.setText(kpairComment);
+ keyPassphrase1Text.setText(""); //$NON-NLS-1$
+ keyPassphrase2Text.setText(""); //$NON-NLS-1$
+ updateControls();
+ }
+ catch(IOException ee){
+ ok=false;
+ }
+ catch(JSchException ee){
+ ok=false;
+ }
+ if(!ok){
+ MessageDialog.openError(getShell(),
+ Messages.CVSSSH2PreferencePage_error,
+ Messages.CVSSSH2PreferencePage_130);
+ }
+ }
+ });
+
+ keyExport.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ if(kpair==null)
+ return;
- setErrorMessage(null);
+ setErrorMessage(null);
- final String[] target=new String[1];
- final String title=Messages.CVSSSH2PreferencePage_106;
+ final String[] target=new String[1];
+ final String title=Messages.CVSSSH2PreferencePage_106;
final String message = Messages.CVSSSH2PreferencePage_107;
Display.getDefault().syncExec(() -> {
Display display = Display.getCurrent();
@@ -657,1043 +657,1043 @@ protected Control createContents(Composite parent){
if (target[0] == null) {
return;
}
- String user=""; //$NON-NLS-1$
- String host=""; //$NON-NLS-1$
- int port=22;
-
- if(target[0].indexOf('@')>0){
- user=target[0].substring(0, target[0].indexOf('@'));
- host=target[0].substring(target[0].indexOf('@')+1);
- }
- if(host.indexOf(':')>0){
- try{
- port=Integer.parseInt(host.substring(host.indexOf(':')+1));
- }
- catch(NumberFormatException ee){
- port=-1;
- }
- host=host.substring(0, host.indexOf(':'));
- }
-
- if(user.length()==0||host.length()==0||port==-1){
- setErrorMessage(NLS.bind(Messages.CVSSSH2PreferencePage_108,
- new String[] {target[0]}));
- return;
- }
-
- String options=""; //$NON-NLS-1$
- try{
- ByteArrayOutputStream bos=new ByteArrayOutputStream();
- if(options.length()!=0){
- try{
- bos.write((options+" ").getBytes());} //$NON-NLS-1$
- catch(IOException eeee){
- // Ignore
- }
- }
- kpair.writePublicKey(bos, kpairComment);
- bos.close();
- export_via_sftp(user, host, port, /* ".ssh/authorized_keys", //$NON-NLS-1$ */
- bos.toByteArray());
- }
- catch(IOException ee){
- // Ignore
- }
- catch(JSchException ee){
- setErrorMessage(Messages.CVSSSH2PreferencePage_111);
- }
- }
- });
-
- saveKeyPair.addSelectionListener(new SelectionAdapter(){
- @Override
+ String user=""; //$NON-NLS-1$
+ String host=""; //$NON-NLS-1$
+ int port=22;
+
+ if(target[0].indexOf('@')>0){
+ user=target[0].substring(0, target[0].indexOf('@'));
+ host=target[0].substring(target[0].indexOf('@')+1);
+ }
+ if(host.indexOf(':')>0){
+ try{
+ port=Integer.parseInt(host.substring(host.indexOf(':')+1));
+ }
+ catch(NumberFormatException ee){
+ port=-1;
+ }
+ host=host.substring(0, host.indexOf(':'));
+ }
+
+ if(user.length()==0||host.length()==0||port==-1){
+ setErrorMessage(NLS.bind(Messages.CVSSSH2PreferencePage_108,
+ new String[] {target[0]}));
+ return;
+ }
+
+ String options=""; //$NON-NLS-1$
+ try{
+ ByteArrayOutputStream bos=new ByteArrayOutputStream();
+ if(options.length()!=0){
+ try{
+ bos.write((options+" ").getBytes());} //$NON-NLS-1$
+ catch(IOException eeee){
+ // Ignore
+ }
+ }
+ kpair.writePublicKey(bos, kpairComment);
+ bos.close();
+ export_via_sftp(user, host, port, /* ".ssh/authorized_keys", //$NON-NLS-1$ */
+ bos.toByteArray());
+ }
+ catch(IOException ee){
+ // Ignore
+ }
+ catch(JSchException ee){
+ setErrorMessage(Messages.CVSSSH2PreferencePage_111);
+ }
+ }
+ });
+
+ saveKeyPair.addSelectionListener(new SelectionAdapter(){
+ @Override
public void widgetSelected(SelectionEvent e){
- if(kpair==null)
- return;
-
- String pass=keyPassphrase1Text.getText();
- /*
- * if(!pass.equals(keyPassphrase2Text.getText())){
- * setErrorMessage(Policy.bind("CVSSSH2PreferencePage.48"));
- * //$NON-NLS-1$ return; }
- */
- if(pass.length()==0){
- if(!MessageDialog.openConfirm(getShell(),
- Messages.CVSSSH2PreferencePage_confirmation,
- Messages.CVSSSH2PreferencePage_49)){
- return;
- }
- }
-
- kpair.setPassphrase(pass);
-
- String home=ssh2HomeText.getText();
-
- File _home=new File(home);
-
- if(!_home.exists()){
- if(!MessageDialog.openConfirm(getShell(),
- Messages.CVSSSH2PreferencePage_confirmation, NLS.bind(
- Messages.CVSSSH2PreferencePage_50, new String[] {home}))){
- return;
- }
- if(!_home.mkdirs()){
- setErrorMessage(Messages.CVSSSH2PreferencePage_100+home);
- return;
- }
- }
-
- FileDialog fd=new FileDialog(getShell(), SWT.SAVE);
- fd.setFilterPath(home);
- String file=(kpair.getKeyType()==KeyPair.RSA) ? "id_rsa" : "id_dsa"; //$NON-NLS-1$ //$NON-NLS-2$
- fd.setFileName(file);
- file=fd.open();
- if(file==null){ // cancel
- return;
- }
-
- if(new File(file).exists()){
- if(!MessageDialog.openConfirm(getShell(),
- Messages.CVSSSH2PreferencePage_confirmation, //
- NLS.bind(Messages.CVSSSH2PreferencePage_53, new String[] {file}))){
- return;
- }
- }
-
- boolean ok=true;
- try{
- kpair.writePrivateKey(file);
- kpair.writePublicKey(file+".pub", kpairComment); //$NON-NLS-1$
- }
- catch(Exception ee){
- ok=false;
- }
-
- if(ok){
- MessageDialog.openInformation(getShell(),
- Messages.CVSSSH2PreferencePage_information,
- Messages.CVSSSH2PreferencePage_55+"\n"+ //$NON-NLS-1$
- Messages.CVSSSH2PreferencePage_57+file+"\n"+ //$NON-NLS-1$
- Messages.CVSSSH2PreferencePage_59+file+".pub"); //$NON-NLS-1$
- }
- else{
- return;
- }
-
- // The generated key should be added to privateKeyText.
-
- String dir=fd.getFilterPath();
- File mypkey=new java.io.File(dir, fd.getFileName());
- String pkeys=privateKeyText.getText();
-
- // Check if the generated key has been included in pkeys?
- String[] pkeysa=pkeys.split(","); //$NON-NLS-1$
- for(int i=0; i<pkeysa.length; i++){
- File pkey=new java.io.File(pkeysa[i]);
- if(!pkey.isAbsolute()){
- pkey=new java.io.File(home, pkeysa[i]);
- }
- if(pkey.equals(mypkey))
- return;
- }
-
- if(dir.equals(home)){
- dir="";} //$NON-NLS-1$
- else{
- dir+=java.io.File.separator;
- }
- if(pkeys.length()>0)
- pkeys+=","; //$NON-NLS-1$
- pkeys=pkeys+dir+fd.getFileName();
- privateKeyText.setText(pkeys);
- }
- });
-
- return group;
- }
-
- private TableViewer viewer;
- private Button removeHostKeyButton;
-
- Table preferedAuthMethodTable;
- Table preferedSSHAgentTable;
- 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{
- @Override
- public String getColumnText(Object element, int columnIndex){
- HostKey entry=(HostKey)element;
- switch(columnIndex){
- case 0:
- return entry.getHost();
- case 1:
- return entry.getType();
- case 2:
- return entry.getFingerPrint(getJSch());
- default:
- return null;
- }
- }
-
- @Override
- public Image getColumnImage(Object element, int columnIndex){
- return null;
- }
- }
-
- private Control createHostKeyManagementPage(Composite parent){
- Composite group=new Composite(parent, SWT.NULL);
- 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;
- group.setLayout(layout);
- GridData gd=new GridData();
- gd.horizontalAlignment=GridData.FILL;
- gd.verticalAlignment=GridData.FILL;
- group.setLayoutData(gd);
-
- Label label=new Label(group, SWT.NONE);
- label.setText(Messages.CVSSSH2PreferencePage_139);
- gd=new GridData();
- gd.horizontalSpan=2;
- label.setLayoutData(gd);
-
- viewer=new TableViewer(group, 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);
- 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);
+ if(kpair==null)
+ return;
+
+ String pass=keyPassphrase1Text.getText();
+ /*
+ * if(!pass.equals(keyPassphrase2Text.getText())){
+ * setErrorMessage(Policy.bind("CVSSSH2PreferencePage.48"));
+ * //$NON-NLS-1$ return; }
+ */
+ if(pass.length()==0){
+ if(!MessageDialog.openConfirm(getShell(),
+ Messages.CVSSSH2PreferencePage_confirmation,
+ Messages.CVSSSH2PreferencePage_49)){
+ return;
+ }
+ }
+
+ kpair.setPassphrase(pass);
+
+ String home=ssh2HomeText.getText();
+
+ File _home=new File(home);
+
+ if(!_home.exists()){
+ if(!MessageDialog.openConfirm(getShell(),
+ Messages.CVSSSH2PreferencePage_confirmation, NLS.bind(
+ Messages.CVSSSH2PreferencePage_50, new String[] {home}))){
+ return;
+ }
+ if(!_home.mkdirs()){
+ setErrorMessage(Messages.CVSSSH2PreferencePage_100+home);
+ return;
+ }
+ }
+
+ FileDialog fd=new FileDialog(getShell(), SWT.SAVE);
+ fd.setFilterPath(home);
+ String file=(kpair.getKeyType()==KeyPair.RSA) ? "id_rsa" : "id_dsa"; //$NON-NLS-1$ //$NON-NLS-2$
+ fd.setFileName(file);
+ file=fd.open();
+ if(file==null){ // cancel
+ return;
+ }
+
+ if(new File(file).exists()){
+ if(!MessageDialog.openConfirm(getShell(),
+ Messages.CVSSSH2PreferencePage_confirmation, //
+ NLS.bind(Messages.CVSSSH2PreferencePage_53, new String[] {file}))){
+ return;
+ }
+ }
+
+ boolean ok=true;
+ try{
+ kpair.writePrivateKey(file);
+ kpair.writePublicKey(file+".pub", kpairComment); //$NON-NLS-1$
+ }
+ catch(Exception ee){
+ ok=false;
+ }
+
+ if(ok){
+ MessageDialog.openInformation(getShell(),
+ Messages.CVSSSH2PreferencePage_information,
+ Messages.CVSSSH2PreferencePage_55+"\n"+ //$NON-NLS-1$
+ Messages.CVSSSH2PreferencePage_57+file+"\n"+ //$NON-NLS-1$
+ Messages.CVSSSH2PreferencePage_59+file+".pub"); //$NON-NLS-1$
+ }
+ else{
+ return;
+ }
+
+ // The generated key should be added to privateKeyText.
+
+ String dir=fd.getFilterPath();
+ File mypkey=new java.io.File(dir, fd.getFileName());
+ String pkeys=privateKeyText.getText();
+
+ // Check if the generated key has been included in pkeys?
+ String[] pkeysa=pkeys.split(","); //$NON-NLS-1$
+ for(int i=0; i<pkeysa.length; i++){
+ File pkey=new java.io.File(pkeysa[i]);
+ if(!pkey.isAbsolute()){
+ pkey=new java.io.File(home, pkeysa[i]);
+ }
+ if(pkey.equals(mypkey))
+ return;
+ }
+
+ if(dir.equals(home)){
+ dir="";} //$NON-NLS-1$
+ else{
+ dir+=java.io.File.separator;
+ }
+ if(pkeys.length()>0)
+ pkeys+=","; //$NON-NLS-1$
+ pkeys=pkeys+dir+fd.getFileName();
+ privateKeyText.setText(pkeys);
+ }
+ });
+
+ return group;
+ }
+
+ private TableViewer viewer;
+ private Button removeHostKeyButton;
+
+ Table preferedAuthMethodTable;
+ Table preferedSSHAgentTable;
+ 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{
+ @Override
+ public String getColumnText(Object element, int columnIndex){
+ HostKey entry=(HostKey)element;
+ switch(columnIndex){
+ case 0:
+ return entry.getHost();
+ case 1:
+ return entry.getType();
+ case 2:
+ return entry.getFingerPrint(getJSch());
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public Image getColumnImage(Object element, int columnIndex){
+ return null;
+ }
+ }
+
+ private Control createHostKeyManagementPage(Composite parent){
+ Composite group=new Composite(parent, SWT.NULL);
+ 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;
+ group.setLayout(layout);
+ GridData gd=new GridData();
+ gd.horizontalAlignment=GridData.FILL;
+ gd.verticalAlignment=GridData.FILL;
+ group.setLayoutData(gd);
+
+ Label label=new Label(group, SWT.NONE);
+ label.setText(Messages.CVSSSH2PreferencePage_139);
+ gd=new GridData();
+ gd.horizontalSpan=2;
+ label.setLayoutData(gd);
+
+ viewer=new TableViewer(group, 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);
+ 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, e -> handleSelection());
- // Create the table columns
- new TableColumn(table, SWT.NULL);
- new TableColumn(table, SWT.NULL);
- new TableColumn(table, SWT.NULL);
- TableColumn[] columns=table.getColumns();
- columns[0].setText(Messages.CVSSSH2PreferencePage_134);
- columns[1].setText(Messages.CVSSSH2PreferencePage_135);
- columns[2].setText(Messages.CVSSSH2PreferencePage_136);
- viewer.setColumnProperties(new String[] {
- Messages.CVSSSH2PreferencePage_134, //
- Messages.CVSSSH2PreferencePage_135, //
- Messages.CVSSSH2PreferencePage_136});
- viewer.setLabelProvider(new TableLabelProvider());
- viewer.setContentProvider(new IStructuredContentProvider(){
- @Override
- public void dispose(){
- // nothing to do
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput){
- // nothing to do
- }
-
- @Override
- public Object[] getElements(Object inputElement){
- if(inputElement==null)
- return null;
- return (Object[])inputElement;
- }
- });
- TableLayout tl=new TableLayout();
- tl.addColumnData(new ColumnWeightData(30));
- tl.addColumnData(new ColumnWeightData(20));
- tl.addColumnData(new ColumnWeightData(70));
- table.setLayout(tl);
-
- Composite buttons=new Composite(group, SWT.NULL);
- buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- layout=new GridLayout();
- layout.marginHeight=0;
- layout.marginWidth=0;
- buttons.setLayout(layout);
-
- removeHostKeyButton=new Button(buttons, SWT.PUSH);
- removeHostKeyButton.setText(Messages.CVSSSH2PreferencePage_138);
- int buttonWidth=SWTUtils
- .calculateControlSize(SWTUtils.createDialogPixelConverter(parent),
- new Button[] {removeHostKeyButton});
- removeHostKeyButton.setLayoutData(SWTUtils.createGridData(buttonWidth,
- SWT.DEFAULT, SWT.END, SWT.CENTER, false, false));
- removeHostKeyButton.setEnabled(false);
+ // Create the table columns
+ new TableColumn(table, SWT.NULL);
+ new TableColumn(table, SWT.NULL);
+ new TableColumn(table, SWT.NULL);
+ TableColumn[] columns=table.getColumns();
+ columns[0].setText(Messages.CVSSSH2PreferencePage_134);
+ columns[1].setText(Messages.CVSSSH2PreferencePage_135);
+ columns[2].setText(Messages.CVSSSH2PreferencePage_136);
+ viewer.setColumnProperties(new String[] {
+ Messages.CVSSSH2PreferencePage_134, //
+ Messages.CVSSSH2PreferencePage_135, //
+ Messages.CVSSSH2PreferencePage_136});
+ viewer.setLabelProvider(new TableLabelProvider());
+ viewer.setContentProvider(new IStructuredContentProvider(){
+ @Override
+ public void dispose(){
+ // nothing to do
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput){
+ // nothing to do
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement){
+ if(inputElement==null)
+ return null;
+ return (Object[])inputElement;
+ }
+ });
+ TableLayout tl=new TableLayout();
+ tl.addColumnData(new ColumnWeightData(30));
+ tl.addColumnData(new ColumnWeightData(20));
+ tl.addColumnData(new ColumnWeightData(70));
+ table.setLayout(tl);
+
+ Composite buttons=new Composite(group, SWT.NULL);
+ buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ layout=new GridLayout();
+ layout.marginHeight=0;
+ layout.marginWidth=0;
+ buttons.setLayout(layout);
+
+ removeHostKeyButton=new Button(buttons, SWT.PUSH);
+ removeHostKeyButton.setText(Messages.CVSSSH2PreferencePage_138);
+ int buttonWidth=SWTUtils
+ .calculateControlSize(SWTUtils.createDialogPixelConverter(parent),
+ new Button[] {removeHostKeyButton});
+ removeHostKeyButton.setLayoutData(SWTUtils.createGridData(buttonWidth,
+ SWT.DEFAULT, SWT.END, SWT.CENTER, false, false));
+ removeHostKeyButton.setEnabled(false);
removeHostKeyButton.addListener(SWT.Selection, e -> removeHostKey());
- Dialog.applyDialogFont(parent);
-
- // JSchSession.loadKnownHosts(JSchContext.getDefaultContext().getJSch());
- JSchCorePlugin.getPlugin().loadKnownHosts();
- HostKeyRepository hkr=getJSch().getHostKeyRepository();
- viewer.setInput(hkr.getHostKey());
- handleSelection();
-
- return group;
- }
-
- private Control createPreferredAuthenticationPage(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_4);
-
- preferedAuthMethodTable=new Table(root, SWT.CHECK | SWT.BORDER);
- GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true);
- layoutData.verticalSpan = 3;
- preferedAuthMethodTable.setLayoutData(layoutData);
- layoutData.minimumHeight = 150;
- layoutData.minimumWidth = 200;
- populateAuthMethods();
-
- up=new Button(root, SWT.PUSH);
- up.setText(Messages.CVSSSH2PreferencePage_2);
- up.setEnabled(false);
- setButtonLayoutData(up);
-
- down=new Button(root, SWT.PUSH);
- down.setText(Messages.CVSSSH2PreferencePage_3);
- down.setEnabled(false);
- setButtonLayoutData(down);
-
- preferedAuthMethodTable.addSelectionListener(new SelectionAdapter(){
-
- @Override
- public void widgetSelected(SelectionEvent e){
- boolean anySelected = false;
- for(int i = 0; i < preferedAuthMethodTable.getItemCount(); i++){
- anySelected |= preferedAuthMethodTable.getItem(i).getChecked();
- }
-
- if(anySelected){
- setErrorMessage(null);
- setValid(true);
- }
- else{
- setErrorMessage(Messages.CVSSSH2PreferencePage_5);
- setValid(false);
- }
- up.setEnabled(preferedAuthMethodTable.getSelectionIndex()>0);
- down
- .setEnabled(preferedAuthMethodTable.getSelectionIndex()<preferedAuthMethodTable
- .getItemCount()-1);
- }
-
- });
- up.addSelectionListener(new SelectionAdapter(){
-
- @Override
- public void widgetSelected(SelectionEvent e){
- int selectedIndex=preferedAuthMethodTable.getSelectionIndex();
- if(selectedIndex == 1){ //this is the last possible swap
- up.setEnabled(false);
- }
- down.setEnabled(true);
- TableItem sourceItem = preferedAuthMethodTable.getItem(selectedIndex);
- TableItem targetItem = preferedAuthMethodTable.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);
-
- preferedAuthMethodTable.setSelection(targetItem);
- }
- });
-
- down.addSelectionListener(new SelectionAdapter(){
-
- @Override
- public void widgetSelected(SelectionEvent e){
- int selectedIndex=preferedAuthMethodTable.getSelectionIndex();
- if(selectedIndex == preferedAuthMethodTable.getItemCount()-2){ //this is the last possible swap
- down.setEnabled(false);
- }
- up.setEnabled(true);
- TableItem sourceItem = preferedAuthMethodTable.getItem(selectedIndex);
- TableItem targetItem = preferedAuthMethodTable.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);
-
- preferedAuthMethodTable.setSelection(targetItem);
- }
- });
-
- return root;
- }
-
- private void populateAuthMethods(){
- preferedAuthMethodTable.removeAll();
- String[] methods = Utils.getEnabledPreferredAuthMethods().split(","); //$NON-NLS-1$
+ Dialog.applyDialogFont(parent);
+
+ // JSchSession.loadKnownHosts(JSchContext.getDefaultContext().getJSch());
+ JSchCorePlugin.getPlugin().loadKnownHosts();
+ HostKeyRepository hkr=getJSch().getHostKeyRepository();
+ viewer.setInput(hkr.getHostKey());
+ handleSelection();
+
+ return group;
+ }
+
+ private Control createPreferredAuthenticationPage(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_4);
+
+ preferedAuthMethodTable=new Table(root, SWT.CHECK | SWT.BORDER);
+ GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true);
+ layoutData.verticalSpan = 3;
+ preferedAuthMethodTable.setLayoutData(layoutData);
+ layoutData.minimumHeight = 150;
+ layoutData.minimumWidth = 200;
+ populateAuthMethods();
+
+ up=new Button(root, SWT.PUSH);
+ up.setText(Messages.CVSSSH2PreferencePage_2);
+ up.setEnabled(false);
+ setButtonLayoutData(up);
+
+ down=new Button(root, SWT.PUSH);
+ down.setText(Messages.CVSSSH2PreferencePage_3);
+ down.setEnabled(false);
+ setButtonLayoutData(down);
+
+ preferedAuthMethodTable.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ boolean anySelected = false;
+ for(int i = 0; i < preferedAuthMethodTable.getItemCount(); i++){
+ anySelected |= preferedAuthMethodTable.getItem(i).getChecked();
+ }
+
+ if(anySelected){
+ setErrorMessage(null);
+ setValid(true);
+ }
+ else{
+ setErrorMessage(Messages.CVSSSH2PreferencePage_5);
+ setValid(false);
+ }
+ up.setEnabled(preferedAuthMethodTable.getSelectionIndex()>0);
+ down
+ .setEnabled(preferedAuthMethodTable.getSelectionIndex()<preferedAuthMethodTable
+ .getItemCount()-1);
+ }
+
+ });
+ up.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ int selectedIndex=preferedAuthMethodTable.getSelectionIndex();
+ if(selectedIndex == 1){ //this is the last possible swap
+ up.setEnabled(false);
+ }
+ down.setEnabled(true);
+ TableItem sourceItem = preferedAuthMethodTable.getItem(selectedIndex);
+ TableItem targetItem = preferedAuthMethodTable.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);
+
+ preferedAuthMethodTable.setSelection(targetItem);
+ }
+ });
+
+ down.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e){
+ int selectedIndex=preferedAuthMethodTable.getSelectionIndex();
+ if(selectedIndex == preferedAuthMethodTable.getItemCount()-2){ //this is the last possible swap
+ down.setEnabled(false);
+ }
+ up.setEnabled(true);
+ TableItem sourceItem = preferedAuthMethodTable.getItem(selectedIndex);
+ TableItem targetItem = preferedAuthMethodTable.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);
+
+ preferedAuthMethodTable.setSelection(targetItem);
+ }
+ });
+
+ return root;
+ }
+
+ private void populateAuthMethods(){
+ preferedAuthMethodTable.removeAll();
+ String[] methods = Utils.getEnabledPreferredAuthMethods().split(","); //$NON-NLS-1$
Set<String> smethods = new HashSet<>(Arrays.asList(methods));
- String[] order = Utils.getMethodsOrder().split(","); //$NON-NLS-1$
-
- for(int i=0; i<order.length; i++){
- TableItem tableItem= new TableItem(preferedAuthMethodTable, SWT.NONE);
- tableItem.setText(0, order[i]);
- if(smethods.contains(order[i])){
- tableItem.setChecked(true);
- }
- }
- }
-
- 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(){
-
- @Override
- 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(){
-
- @Override
- 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(){
-
- @Override
- 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<String> 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(){
-
- @Override
- 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(){
-
- @Override
- 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(){
-
- @Override
- 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 Control createPreferredSSHAgentPage(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_147);
-
- preferedSSHAgentTable=new Table(root, SWT.CHECK | SWT.BORDER);
- GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true);
- layoutData.verticalSpan = 3;
- preferedSSHAgentTable.setLayoutData(layoutData);
- layoutData.minimumHeight = 150;
- layoutData.minimumWidth = 200;
- populateSSHAgents();
- return root;
- }
-
- private void populateSSHAgents(){
- preferedSSHAgentTable.removeAll();
- String[] methods = Utils.getAvailableSSHAgents().split(","); //$NON-NLS-1$
- String[] selected = Utils.getSelectedSSHAgent().split(","); //$NON-NLS-1$
-
- for(int i=0; i<methods.length; i++){
- if(methods[i].length()==0)
- continue;
- TableItem tableItem= new TableItem(preferedSSHAgentTable, SWT.NONE);
- tableItem.setText(0, methods[i]);
- for(int j=0; j<selected.length; j++){
- if(selected[j].equals(methods[i])){
- tableItem.setChecked(true);
- break;
- }
- }
- }
- }
-
- private void populateMACMethods(){
- preferedMACMethodTable.removeAll();
- String[] methods = Utils.getEnabledPreferredMACMethods().split(","); //$NON-NLS-1$
- Set<String> 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);
- }
-
- void removeHostKey(){
- IStructuredSelection selection=viewer.getStructuredSelection();
- HostKeyRepository hkr=getJSch().getHostKeyRepository();
- for(Iterator<?> iterator=selection.iterator(); iterator.hasNext();){
- HostKey hostkey=(HostKey)iterator.next();
- hkr.remove(hostkey.getHost(), hostkey.getType());
- viewer.remove(hostkey);
- }
- }
-
- void export_via_sftp(String user, String host, int port, byte[] pkey) throws JSchException{
- try{
-
- int timeout = 60000;
- IJSchService service = JSchUIPlugin.getPlugin().getJSchService();
- if (service == null) {
- MessageDialog.openInformation(getShell(), Messages.PreferencePage_0, Messages.PreferencePage_1);
- return;
- }
-
- IJSchLocation location=service.getLocation(user, host, port);
- // We hope that prompts for jsch are given by IJSchService, so "null" should be passed.
- Session session = service.createSession(location, null);
- session.setTimeout(timeout);
- try {
- service.connect(session, timeout, new NullProgressMonitor());
- if(session.getServerVersion().indexOf("OpenSSH")==-1){ //$NON-NLS-1$
- setErrorMessage(Messages.CVSSSH2PreferencePage_110);
- return;
- }
- Channel channel=session.openChannel("sftp"); //$NON-NLS-1$
- channel.connect();
- ChannelSftp c=(ChannelSftp)channel;
-
- SftpATTRS attr=null;
-
- try{
- attr=c.stat(".ssh");} //$NON-NLS-1$
- catch(SftpException ee){
- // Ignore
- }
- if(attr==null){
- try{
- c.mkdir(".ssh");} //$NON-NLS-1$
- catch(SftpException ee){
- setErrorMessage(ee.getMessage());
- return;
- }
- }
- try{
- c.cd(".ssh");} //$NON-NLS-1$
- catch(SftpException ee){
- setErrorMessage(ee.getMessage());
- return;
- }
-
- try{
- ByteArrayInputStream bis=new ByteArrayInputStream(pkey);
- c.put(bis, "authorized_keys", null, ChannelSftp.APPEND); //$NON-NLS-1$
- bis.close();
- checkPermission(c, "authorized_keys"); //$NON-NLS-1$
- checkPermission(c, "."); // .ssh //$NON-NLS-1$
- c.cd(".."); //$NON-NLS-1$
- checkPermission(c, "."); // home directory //$NON-NLS-1$
- }
- catch(SftpException ee){
- // setErrorMessage(debug+ee.message);
- }
-
- MessageDialog.openInformation(getShell(),
- Messages.CVSSSH2PreferencePage_information,
- NLS.bind(Messages.CVSSSH2PreferencePage_109, (user
- +"@"+host+(port==22 ? "" : ":"+port)+":~/.ssh/authorized_keys"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- c.quit();
- c.disconnect();
- } finally {
- session.disconnect();
- }
- } catch(IOException eee){
- setErrorMessage(eee.toString());
- }
- }
-
- private void checkPermission(ChannelSftp c, String path) throws SftpException{
- SftpATTRS attr=c.stat(path);
- int permissions=attr.getPermissions();
- if((permissions&00022)!=0){
- permissions&=~00022;
- c.chmod(permissions, path);
- }
- }
-
- void updateControls(){
- boolean enable=(kpair!=null);
- publicKeylabel.setEnabled(enable);
- publicKeyText.setEnabled(enable);
- keyFingerPrintLabel.setEnabled(enable);
- keyFingerPrintText.setEnabled(enable);
- keyCommentLabel.setEnabled(enable);
- keyCommentText.setEnabled(enable);
- keyPassphrase1Label.setEnabled(enable);
- keyPassphrase1Text.setEnabled(enable);
- keyPassphrase2Label.setEnabled(enable);
- keyPassphrase2Text.setEnabled(enable);
- 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);
- }
-
- @Override
+ String[] order = Utils.getMethodsOrder().split(","); //$NON-NLS-1$
+
+ for(int i=0; i<order.length; i++){
+ TableItem tableItem= new TableItem(preferedAuthMethodTable, SWT.NONE);
+ tableItem.setText(0, order[i]);
+ if(smethods.contains(order[i])){
+ tableItem.setChecked(true);
+ }
+ }
+ }
+
+ 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(){
+
+ @Override
+ 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(){
+
+ @Override
+ 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(){
+
+ @Override
+ 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<String> 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(){
+
+ @Override
+ 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(){
+
+ @Override
+ 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(){
+
+ @Override
+ 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 Control createPreferredSSHAgentPage(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_147);
+
+ preferedSSHAgentTable=new Table(root, SWT.CHECK | SWT.BORDER);
+ GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true);
+ layoutData.verticalSpan = 3;
+ preferedSSHAgentTable.setLayoutData(layoutData);
+ layoutData.minimumHeight = 150;
+ layoutData.minimumWidth = 200;
+ populateSSHAgents();
+ return root;
+ }
+
+ private void populateSSHAgents(){
+ preferedSSHAgentTable.removeAll();
+ String[] methods = Utils.getAvailableSSHAgents().split(","); //$NON-NLS-1$
+ String[] selected = Utils.getSelectedSSHAgent().split(","); //$NON-NLS-1$
+
+ for(int i=0; i<methods.length; i++){
+ if(methods[i].length()==0)
+ continue;
+ TableItem tableItem= new TableItem(preferedSSHAgentTable, SWT.NONE);
+ tableItem.setText(0, methods[i]);
+ for(int j=0; j<selected.length; j++){
+ if(selected[j].equals(methods[i])){
+ tableItem.setChecked(true);
+ break;
+ }
+ }
+ }
+ }
+
+ private void populateMACMethods(){
+ preferedMACMethodTable.removeAll();
+ String[] methods = Utils.getEnabledPreferredMACMethods().split(","); //$NON-NLS-1$
+ Set<String> 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);
+ }
+
+ void removeHostKey(){
+ IStructuredSelection selection=viewer.getStructuredSelection();
+ HostKeyRepository hkr=getJSch().getHostKeyRepository();
+ for(Iterator<?> iterator=selection.iterator(); iterator.hasNext();){
+ HostKey hostkey=(HostKey)iterator.next();
+ hkr.remove(hostkey.getHost(), hostkey.getType());
+ viewer.remove(hostkey);
+ }
+ }
+
+ void export_via_sftp(String user, String host, int port, byte[] pkey) throws JSchException{
+ try{
+
+ int timeout = 60000;
+ IJSchService service = JSchUIPlugin.getPlugin().getJSchService();
+ if (service == null) {
+ MessageDialog.openInformation(getShell(), Messages.PreferencePage_0, Messages.PreferencePage_1);
+ return;
+ }
+
+ IJSchLocation location=service.getLocation(user, host, port);
+ // We hope that prompts for jsch are given by IJSchService, so "null" should be passed.
+ Session session = service.createSession(location, null);
+ session.setTimeout(timeout);
+ try {
+ service.connect(session, timeout, new NullProgressMonitor());
+ if(session.getServerVersion().indexOf("OpenSSH")==-1){ //$NON-NLS-1$
+ setErrorMessage(Messages.CVSSSH2PreferencePage_110);
+ return;
+ }
+ Channel channel=session.openChannel("sftp"); //$NON-NLS-1$
+ channel.connect();
+ ChannelSftp c=(ChannelSftp)channel;
+
+ SftpATTRS attr=null;
+
+ try{
+ attr=c.stat(".ssh");} //$NON-NLS-1$
+ catch(SftpException ee){
+ // Ignore
+ }
+ if(attr==null){
+ try{
+ c.mkdir(".ssh");} //$NON-NLS-1$
+ catch(SftpException ee){
+ setErrorMessage(ee.getMessage());
+ return;
+ }
+ }
+ try{
+ c.cd(".ssh");} //$NON-NLS-1$
+ catch(SftpException ee){
+ setErrorMessage(ee.getMessage());
+ return;
+ }
+
+ try{
+ ByteArrayInputStream bis=new ByteArrayInputStream(pkey);
+ c.put(bis, "authorized_keys", null, ChannelSftp.APPEND); //$NON-NLS-1$
+ bis.close();
+ checkPermission(c, "authorized_keys"); //$NON-NLS-1$
+ checkPermission(c, "."); // .ssh //$NON-NLS-1$
+ c.cd(".."); //$NON-NLS-1$
+ checkPermission(c, "."); // home directory //$NON-NLS-1$
+ }
+ catch(SftpException ee){
+ // setErrorMessage(debug+ee.message);
+ }
+
+ MessageDialog.openInformation(getShell(),
+ Messages.CVSSSH2PreferencePage_information,
+ NLS.bind(Messages.CVSSSH2PreferencePage_109, (user
+ +"@"+host+(port==22 ? "" : ":"+port)+":~/.ssh/authorized_keys"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ c.quit();
+ c.disconnect();
+ } finally {
+ session.disconnect();
+ }
+ } catch(IOException eee){
+ setErrorMessage(eee.toString());
+ }
+ }
+
+ private void checkPermission(ChannelSftp c, String path) throws SftpException{
+ SftpATTRS attr=c.stat(path);
+ int permissions=attr.getPermissions();
+ if((permissions&00022)!=0){
+ permissions&=~00022;
+ c.chmod(permissions, path);
+ }
+ }
+
+ void updateControls(){
+ boolean enable=(kpair!=null);
+ publicKeylabel.setEnabled(enable);
+ publicKeyText.setEnabled(enable);
+ keyFingerPrintLabel.setEnabled(enable);
+ keyFingerPrintText.setEnabled(enable);
+ keyCommentLabel.setEnabled(enable);
+ keyCommentText.setEnabled(enable);
+ keyPassphrase1Label.setEnabled(enable);
+ keyPassphrase1Text.setEnabled(enable);
+ keyPassphrase2Label.setEnabled(enable);
+ keyPassphrase2Text.setEnabled(enable);
+ 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);
+ }
+
+ @Override
public void init(IWorkbench workbench){
- // super.init(workbench);
- // initControls();
- }
-
- public void initialize(){
- initControls();
- }
-
- private void initControls(){
- Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences();
- ssh2HomeText.setText(preferences
- .getString(org.eclipse.jsch.internal.core.IConstants.KEY_SSH2HOME));
- privateKeyText.setText(preferences
- .getString(org.eclipse.jsch.internal.core.IConstants.KEY_PRIVATEKEY));
- updateControls();
- }
-
- @Override
+ // super.init(workbench);
+ // initControls();
+ }
+
+ public void initialize(){
+ initControls();
+ }
+
+ private void initControls(){
+ Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences();
+ ssh2HomeText.setText(preferences
+ .getString(org.eclipse.jsch.internal.core.IConstants.KEY_SSH2HOME));
+ privateKeyText.setText(preferences
+ .getString(org.eclipse.jsch.internal.core.IConstants.KEY_PRIVATEKEY));
+ updateControls();
+ }
+
+ @Override
public boolean performOk(){
- boolean result=super.performOk();
- storeAuthenticationMethodSettings();
- storeSSHAgentSettings();
- storeKeyExchangeMethodSettings();
- storeMACMethodSettings();
-
- if(result){
- setErrorMessage(null);
- String home=ssh2HomeText.getText();
- File _home=new File(home);
- if(!_home.exists()){
- if(MessageDialog.openQuestion(getShell(),
- Messages.CVSSSH2PreferencePage_question, NLS.bind(
- Messages.CVSSSH2PreferencePage_99, new String[] {home}))){
- if(!(_home.mkdirs())){
- setErrorMessage(Messages.CVSSSH2PreferencePage_100+home);
- return false;
- }
- }
- }
-
- Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences();
- preferences.setValue(
- org.eclipse.jsch.internal.core.IConstants.KEY_SSH2HOME, home);
- preferences.setValue(
- org.eclipse.jsch.internal.core.IConstants.KEY_PRIVATEKEY,
- privateKeyText.getText());
- }
- JSchCorePlugin.getPlugin().setNeedToLoadKnownHosts(true);
- JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
- JSchCorePlugin.getPlugin().setIdentityRepository();
- JSchCorePlugin.getPlugin().savePluginPreferences();
- return result;
- }
-
- private void storeAuthenticationMethodSettings(){
- String selected = null;
- String order = null;
- for(int i = 0; i < preferedAuthMethodTable.getItemCount(); i++){
- TableItem item=preferedAuthMethodTable.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.setEnabledPreferredAuthMethods(selected, order);
- }
-
- private void storeSSHAgentSettings(){
- String selected = ""; //$NON-NLS-1$
- for(int i = 0; i < preferedSSHAgentTable.getItemCount(); i++){
- TableItem item=preferedSSHAgentTable.getItem(i);
- if(item.getChecked()){
- if(selected.length()==0){
- selected=item.getText();
- }
- else{
- selected+=","+item.getText(); //$NON-NLS-1$
- }
- }
- }
- Utils.setSelectedSSHAgents(selected);
- }
-
- 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);
- }
-
- @Override
+ boolean result=super.performOk();
+ storeAuthenticationMethodSettings();
+ storeSSHAgentSettings();
+ storeKeyExchangeMethodSettings();
+ storeMACMethodSettings();
+
+ if(result){
+ setErrorMessage(null);
+ String home=ssh2HomeText.getText();
+ File _home=new File(home);
+ if(!_home.exists()){
+ if(MessageDialog.openQuestion(getShell(),
+ Messages.CVSSSH2PreferencePage_question, NLS.bind(
+ Messages.CVSSSH2PreferencePage_99, new String[] {home}))){
+ if(!(_home.mkdirs())){
+ setErrorMessage(Messages.CVSSSH2PreferencePage_100+home);
+ return false;
+ }
+ }
+ }
+
+ Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences();
+ preferences.setValue(
+ org.eclipse.jsch.internal.core.IConstants.KEY_SSH2HOME, home);
+ preferences.setValue(
+ org.eclipse.jsch.internal.core.IConstants.KEY_PRIVATEKEY,
+ privateKeyText.getText());
+ }
+ JSchCorePlugin.getPlugin().setNeedToLoadKnownHosts(true);
+ JSchCorePlugin.getPlugin().setNeedToLoadKeys(true);
+ JSchCorePlugin.getPlugin().setIdentityRepository();
+ JSchCorePlugin.getPlugin().savePluginPreferences();
+ return result;
+ }
+
+ private void storeAuthenticationMethodSettings(){
+ String selected = null;
+ String order = null;
+ for(int i = 0; i < preferedAuthMethodTable.getItemCount(); i++){
+ TableItem item=preferedAuthMethodTable.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.setEnabledPreferredAuthMethods(selected, order);
+ }
+
+ private void storeSSHAgentSettings(){
+ String selected = ""; //$NON-NLS-1$
+ for(int i = 0; i < preferedSSHAgentTable.getItemCount(); i++){
+ TableItem item=preferedSSHAgentTable.getItem(i);
+ if(item.getChecked()){
+ if(selected.length()==0){
+ selected=item.getText();
+ }
+ else{
+ selected+=","+item.getText(); //$NON-NLS-1$
+ }
+ }
+ }
+ Utils.setSelectedSSHAgents(selected);
+ }
+
+ 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);
+ }
+
+ @Override
public void performApply(){
- performOk();
- }
+ performOk();
+ }
- @Override
+ @Override
protected void performDefaults(){
- super.performDefaults();
- Utils.setEnabledPreferredAuthMethods(Utils.getDefaultAuthMethods(), Utils
- .getDefaultAuthMethods());
- Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences();
- ssh2HomeText
- .setText(preferences
- .getDefaultString(org.eclipse.jsch.internal.core.IConstants.KEY_SSH2HOME));
- privateKeyText
- .setText(preferences
- .getDefaultString(org.eclipse.jsch.internal.core.IConstants.KEY_PRIVATEKEY));
- updateControls();
- }
-
- protected void createSpacer(Composite composite, int columnSpan){
- Label label=new Label(composite, SWT.NONE);
- GridData gd=new GridData();
- gd.horizontalSpan=columnSpan;
- label.setLayoutData(gd);
- }
-
- JSch getJSch(){
- return JSchCorePlugin.getPlugin().getJSch();
- }
-
- class PassphrasePrompt implements Runnable{
- private String message;
- private String passphrase;
-
- PassphrasePrompt(String message){
- this.message=message;
- }
-
- @Override
- public void run(){
- Display display=Display.getCurrent();
- Shell shell=new Shell(display);
- PassphraseDialog dialog=new PassphraseDialog(shell, message);
- dialog.open();
- shell.dispose();
- passphrase=dialog.getPassphrase();
- }
-
- public String getPassphrase(){
- return passphrase;
- }
- }
+ super.performDefaults();
+ Utils.setEnabledPreferredAuthMethods(Utils.getDefaultAuthMethods(), Utils
+ .getDefaultAuthMethods());
+ Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences();
+ ssh2HomeText
+ .setText(preferences
+ .getDefaultString(org.eclipse.jsch.internal.core.IConstants.KEY_SSH2HOME));
+ privateKeyText
+ .setText(preferences
+ .getDefaultString(org.eclipse.jsch.internal.core.IConstants.KEY_PRIVATEKEY));
+ updateControls();
+ }
+
+ protected void createSpacer(Composite composite, int columnSpan){
+ Label label=new Label(composite, SWT.NONE);
+ GridData gd=new GridData();
+ gd.horizontalSpan=columnSpan;
+ label.setLayoutData(gd);
+ }
+
+ JSch getJSch(){
+ return JSchCorePlugin.getPlugin().getJSch();
+ }
+
+ class PassphrasePrompt implements Runnable{
+ private String message;
+ private String passphrase;
+
+ PassphrasePrompt(String message){
+ this.message=message;
+ }
+
+ @Override
+ public void run(){
+ Display display=Display.getCurrent();
+ Shell shell=new Shell(display);
+ PassphraseDialog dialog=new PassphraseDialog(shell, message);
+ dialog.open();
+ shell.dispose();
+ passphrase=dialog.getPassphrase();
+ }
+
+ public String getPassphrase(){
+ return passphrase;
+ }
+ }
}
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/SWTUtils.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/SWTUtils.java
index 8a5ace145..8523a9c16 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/SWTUtils.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/SWTUtils.java
@@ -31,96 +31,96 @@ public class SWTUtils {
public static final int MARGINS_DIALOG= 1;
public static PreferenceLinkArea createPreferenceLink(IWorkbenchPreferenceContainer container, Composite parent, String pageId, String text) {
- final PreferenceLinkArea area = new PreferenceLinkArea(parent, SWT.NONE, pageId, text, container, null);
- return area;
- }
-
- public static GridData createGridData(int width, int height, boolean hFill, boolean vFill) {
- return createGridData(width, height, hFill ? SWT.FILL : SWT.BEGINNING, vFill ? SWT.FILL : SWT.CENTER, hFill, vFill);
- }
-
- public static GridData createGridData(int width, int height, int hAlign, int vAlign, boolean hGrab, boolean vGrab) {
- final GridData gd= new GridData(hAlign, vAlign, hGrab, vGrab);
- gd.widthHint= width;
- gd.heightHint= height;
- return gd;
- }
-
- public static GridData createHFillGridData() {
- return createHFillGridData(1);
- }
-
- public static GridData createHFillGridData(int span) {
- final GridData gd= createGridData(0, SWT.DEFAULT, SWT.FILL, SWT.CENTER, true, false);
- gd.horizontalSpan= span;
- return gd;
- }
-
- public static Composite createHFillComposite(Composite parent, int margins) {
- return createHFillComposite(parent, margins, 1);
- }
-
- public static Composite createHFillComposite(Composite parent, int margins, int columns) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- composite.setLayoutData(createHFillGridData());
- composite.setLayout(createGridLayout(columns, new PixelConverter(parent), margins));
- return composite;
- }
-
- public static Composite createHVFillComposite(Composite parent, int margins) {
- return createHVFillComposite(parent, margins, 1);
- }
-
- public static Composite createHVFillComposite(Composite parent, int margins, int columns) {
- final Composite composite= new Composite(parent, SWT.NONE);
- composite.setFont(parent.getFont());
- composite.setLayoutData(createHVFillGridData());
- composite.setLayout(createGridLayout(columns, new PixelConverter(parent), margins));
- return composite;
- }
-
-
- public static Group createHFillGroup(Composite parent, String text, int margins) {
- return createHFillGroup(parent, text, margins, 1);
- }
-
- public static Group createHFillGroup(Composite parent, String text, int margins, int rows) {
- final Group group= new Group(parent, SWT.NONE);
- group.setFont(parent.getFont());
- group.setLayoutData(createHFillGridData());
- if (text != null)
- group.setText(text);
- group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
- return group;
- }
-
- public static Group createHVFillGroup(Composite parent, String text, int margins) {
- return createHVFillGroup(parent, text, margins, 1);
- }
-
- public static Group createHVFillGroup(Composite parent, String text, int margins, int rows) {
- final Group group= new Group(parent, SWT.NONE);
- group.setFont(parent.getFont());
- group.setLayoutData(createHVFillGridData());
- if (text != null)
- group.setText(text);
- group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
- return group;
- }
-
- public static GridData createHVFillGridData() {
- return createHVFillGridData(1);
- }
-
- public static GridData createHVFillGridData(int span) {
- final GridData gd= createGridData(0, 0, true, true);
- gd.horizontalSpan= span;
- return gd;
- }
-
-
- /**
+ final PreferenceLinkArea area = new PreferenceLinkArea(parent, SWT.NONE, pageId, text, container, null);
+ return area;
+ }
+
+ public static GridData createGridData(int width, int height, boolean hFill, boolean vFill) {
+ return createGridData(width, height, hFill ? SWT.FILL : SWT.BEGINNING, vFill ? SWT.FILL : SWT.CENTER, hFill, vFill);
+ }
+
+ public static GridData createGridData(int width, int height, int hAlign, int vAlign, boolean hGrab, boolean vGrab) {
+ final GridData gd= new GridData(hAlign, vAlign, hGrab, vGrab);
+ gd.widthHint= width;
+ gd.heightHint= height;
+ return gd;
+ }
+
+ public static GridData createHFillGridData() {
+ return createHFillGridData(1);
+ }
+
+ public static GridData createHFillGridData(int span) {
+ final GridData gd= createGridData(0, SWT.DEFAULT, SWT.FILL, SWT.CENTER, true, false);
+ gd.horizontalSpan= span;
+ return gd;
+ }
+
+ public static Composite createHFillComposite(Composite parent, int margins) {
+ return createHFillComposite(parent, margins, 1);
+ }
+
+ public static Composite createHFillComposite(Composite parent, int margins, int columns) {
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+ composite.setLayoutData(createHFillGridData());
+ composite.setLayout(createGridLayout(columns, new PixelConverter(parent), margins));
+ return composite;
+ }
+
+ public static Composite createHVFillComposite(Composite parent, int margins) {
+ return createHVFillComposite(parent, margins, 1);
+ }
+
+ public static Composite createHVFillComposite(Composite parent, int margins, int columns) {
+ final Composite composite= new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+ composite.setLayoutData(createHVFillGridData());
+ composite.setLayout(createGridLayout(columns, new PixelConverter(parent), margins));
+ return composite;
+ }
+
+
+ public static Group createHFillGroup(Composite parent, String text, int margins) {
+ return createHFillGroup(parent, text, margins, 1);
+ }
+
+ public static Group createHFillGroup(Composite parent, String text, int margins, int rows) {
+ final Group group= new Group(parent, SWT.NONE);
+ group.setFont(parent.getFont());
+ group.setLayoutData(createHFillGridData());
+ if (text != null)
+ group.setText(text);
+ group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
+ return group;
+ }
+
+ public static Group createHVFillGroup(Composite parent, String text, int margins) {
+ return createHVFillGroup(parent, text, margins, 1);
+ }
+
+ public static Group createHVFillGroup(Composite parent, String text, int margins, int rows) {
+ final Group group= new Group(parent, SWT.NONE);
+ group.setFont(parent.getFont());
+ group.setLayoutData(createHVFillGridData());
+ if (text != null)
+ group.setText(text);
+ group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
+ return group;
+ }
+
+ public static GridData createHVFillGridData() {
+ return createHVFillGridData(1);
+ }
+
+ public static GridData createHVFillGridData(int span) {
+ final GridData gd= createGridData(0, 0, true, true);
+ gd.horizontalSpan= span;
+ return gd;
+ }
+
+
+ /**
* Create a grid layout with the specified number of columns and the
* standard spacings.
*
@@ -133,96 +133,96 @@ public class SWTUtils {
* <code>MARGINS_NONE</code> or <code>MARGINS_DIALOG</code>.
* @return the grid layout
*/
- public static GridLayout createGridLayout(int numColumns, PixelConverter converter, int margins) {
- Assert.isTrue(margins == MARGINS_DEFAULT || margins == MARGINS_NONE || margins == MARGINS_DIALOG);
-
- final GridLayout layout= new GridLayout(numColumns, false);
- layout.horizontalSpacing= converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- layout.verticalSpacing= converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
-
- switch (margins) {
- case MARGINS_NONE:
- layout.marginLeft= layout.marginRight= 0;
- layout.marginTop= layout.marginBottom= 0;
- break;
- case MARGINS_DIALOG:
- layout.marginLeft= layout.marginRight= converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.marginTop= layout.marginBottom= converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- break;
- case MARGINS_DEFAULT:
- layout.marginLeft= layout.marginRight= layout.marginWidth;
- layout.marginTop= layout.marginBottom= layout.marginHeight;
- }
- layout.marginWidth= layout.marginHeight= 0;
- return layout;
- }
-
-
- public static Label createLabel(Composite parent, String message) {
- return createLabel(parent, message, 1);
- }
-
- public static Label createLabel(Composite parent, String message, int span) {
- final Label label= new Label(parent, SWT.WRAP);
- if (message != null)
- label.setText(message);
- label.setLayoutData(createHFillGridData(span));
- return label;
- }
-
- public static Button createCheckBox(Composite parent, String message) {
- return createCheckBox(parent, message, 1);
- }
-
- public static Button createCheckBox(Composite parent, String message, int span) {
- final Button button= new Button(parent, SWT.CHECK);
- button.setText(message);
- button.setLayoutData(createHFillGridData(span));
- return button;
- }
-
- public static Button createRadioButton(Composite parent, String message) {
- return createRadioButton(parent, message, 1);
- }
-
- public static Button createRadioButton(Composite parent, String message, int span) {
- final Button button= new Button(parent, SWT.RADIO);
- button.setText(message);
- button.setLayoutData(createHFillGridData(span));
- return button;
- }
-
-
- public static Text createText(Composite parent) {
- return createText(parent, 1);
- }
-
- public static Text createText(Composite parent, int span) {
- final Text text= new Text(parent, SWT.SINGLE | SWT.BORDER);
- text.setLayoutData(createHFillGridData(span));
- return text;
- }
-
-
- public static Control createPlaceholder(Composite parent, int heightInChars, int span) {
- Assert.isTrue(heightInChars > 0);
- final Control placeHolder= new Composite(parent, SWT.NONE);
- final GridData gd= new GridData(SWT.BEGINNING, SWT.TOP, false, false);
- gd.heightHint= new PixelConverter(parent).convertHeightInCharsToPixels(heightInChars);
- gd.horizontalSpan= span;
- placeHolder.setLayoutData(gd);
- return placeHolder;
- }
-
-
- public static Control createPlaceholder(Composite parent, int heightInChars) {
- return createPlaceholder(parent, heightInChars, 1);
- }
-
- public static PixelConverter createDialogPixelConverter(Control control) {
- Dialog.applyDialogFont(control);
- return new PixelConverter(control);
- }
+ public static GridLayout createGridLayout(int numColumns, PixelConverter converter, int margins) {
+ Assert.isTrue(margins == MARGINS_DEFAULT || margins == MARGINS_NONE || margins == MARGINS_DIALOG);
+
+ final GridLayout layout= new GridLayout(numColumns, false);
+ layout.horizontalSpacing= converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.verticalSpacing= converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+
+ switch (margins) {
+ case MARGINS_NONE:
+ layout.marginLeft= layout.marginRight= 0;
+ layout.marginTop= layout.marginBottom= 0;
+ break;
+ case MARGINS_DIALOG:
+ layout.marginLeft= layout.marginRight= converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginTop= layout.marginBottom= converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ break;
+ case MARGINS_DEFAULT:
+ layout.marginLeft= layout.marginRight= layout.marginWidth;
+ layout.marginTop= layout.marginBottom= layout.marginHeight;
+ }
+ layout.marginWidth= layout.marginHeight= 0;
+ return layout;
+ }
+
+
+ public static Label createLabel(Composite parent, String message) {
+ return createLabel(parent, message, 1);
+ }
+
+ public static Label createLabel(Composite parent, String message, int span) {
+ final Label label= new Label(parent, SWT.WRAP);
+ if (message != null)
+ label.setText(message);
+ label.setLayoutData(createHFillGridData(span));
+ return label;
+ }
+
+ public static Button createCheckBox(Composite parent, String message) {
+ return createCheckBox(parent, message, 1);
+ }
+
+ public static Button createCheckBox(Composite parent, String message, int span) {
+ final Button button= new Button(parent, SWT.CHECK);
+ button.setText(message);
+ button.setLayoutData(createHFillGridData(span));
+ return button;
+ }
+
+ public static Button createRadioButton(Composite parent, String message) {
+ return createRadioButton(parent, message, 1);
+ }
+
+ public static Button createRadioButton(Composite parent, String message, int span) {
+ final Button button= new Button(parent, SWT.RADIO);
+ button.setText(message);
+ button.setLayoutData(createHFillGridData(span));
+ return button;
+ }
+
+
+ public static Text createText(Composite parent) {
+ return createText(parent, 1);
+ }
+
+ public static Text createText(Composite parent, int span) {
+ final Text text= new Text(parent, SWT.SINGLE | SWT.BORDER);
+ text.setLayoutData(createHFillGridData(span));
+ return text;
+ }
+
+
+ public static Control createPlaceholder(Composite parent, int heightInChars, int span) {
+ Assert.isTrue(heightInChars > 0);
+ final Control placeHolder= new Composite(parent, SWT.NONE);
+ final GridData gd= new GridData(SWT.BEGINNING, SWT.TOP, false, false);
+ gd.heightHint= new PixelConverter(parent).convertHeightInCharsToPixels(heightInChars);
+ gd.horizontalSpan= span;
+ placeHolder.setLayoutData(gd);
+ return placeHolder;
+ }
+
+
+ public static Control createPlaceholder(Composite parent, int heightInChars) {
+ return createPlaceholder(parent, heightInChars, 1);
+ }
+
+ public static PixelConverter createDialogPixelConverter(Control control) {
+ Dialog.applyDialogFont(control);
+ return new PixelConverter(control);
+ }
public static int calculateControlSize(PixelConverter converter, Control [] controls) {
return calculateControlSize(converter, controls, 0, controls.length - 1);
diff --git a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/ui/UserInfoPrompter.java b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/ui/UserInfoPrompter.java
index 85791a697..c22515f2c 100644
--- a/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/ui/UserInfoPrompter.java
+++ b/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/ui/UserInfoPrompter.java
@@ -40,227 +40,227 @@ import com.jcraft.jsch.UserInfo;
*/
public class UserInfoPrompter implements UserInfo, UIKeyboardInteractive{
- private String passphrase;
- private String password;
- private final Session session;
- private int attemptCount;
+ private String passphrase;
+ private String password;
+ private final Session session;
+ private int attemptCount;
- /**
- * Create a prompter for the given session. This constructor will associate
- * this prompter with the session using {@link Session#setUserInfo(UserInfo)}.
- *
- * @param session
- * the session
- */
- public UserInfoPrompter(Session session){
- super();
- this.session=session;
- session.setUserInfo(this);
- }
+ /**
+ * Create a prompter for the given session. This constructor will associate
+ * this prompter with the session using {@link Session#setUserInfo(UserInfo)}.
+ *
+ * @param session
+ * the session
+ */
+ public UserInfoPrompter(Session session){
+ super();
+ this.session=session;
+ session.setUserInfo(this);
+ }
- /**
- * Return the session to which this prompter is assigned.
- *
- * @return the session to which this prompter is assigned
- */
- public Session getSession(){
- return session;
- }
+ /**
+ * Return the session to which this prompter is assigned.
+ *
+ * @return the session to which this prompter is assigned
+ */
+ public Session getSession(){
+ return session;
+ }
- @Override
+ @Override
public String getPassphrase(){
- return passphrase;
- }
+ return passphrase;
+ }
- @Override
+ @Override
public String getPassword(){
- return password;
- }
+ return password;
+ }
- /**
- * Set the pass phrase to be used when connecting the session. Return
- * <code>null</code> if the pass phrase is not known.
- *
- * @param passphrase
- * the pass phrase to be used when connecting the session or
- * <code>null</code>
- */
- public void setPassphrase(String passphrase){
- this.passphrase=passphrase;
- }
+ /**
+ * Set the pass phrase to be used when connecting the session. Return
+ * <code>null</code> if the pass phrase is not known.
+ *
+ * @param passphrase
+ * the pass phrase to be used when connecting the session or
+ * <code>null</code>
+ */
+ public void setPassphrase(String passphrase){
+ this.passphrase=passphrase;
+ }
- /**
- * Set the password to be used when connecting the session. Return
- * <code>null</code> if the password is not known.
- *
- * @param password
- * the password to be used when connecting the session or
- * <code>null</code>
- */
- public void setPassword(String password){
- this.password=password;
- }
+ /**
+ * Set the password to be used when connecting the session. Return
+ * <code>null</code> if the password is not known.
+ *
+ * @param password
+ * the password to be used when connecting the session or
+ * <code>null</code>
+ */
+ public void setPassword(String password){
+ this.password=password;
+ }
- @Override
+ @Override
public boolean promptPassphrase(String message){
- String _passphrase=promptSecret(message);
- if(_passphrase!=null){
- setPassphrase(_passphrase);
- }
- return _passphrase!=null;
- }
+ String _passphrase=promptSecret(message);
+ if(_passphrase!=null){
+ setPassphrase(_passphrase);
+ }
+ return _passphrase!=null;
+ }
- @Override
+ @Override
public boolean promptPassword(String message){
- String _password=promptSecret(message);
- if(_password!=null){
- setPassword(_password);
- }
- return _password!=null;
- }
+ String _password=promptSecret(message);
+ if(_password!=null){
+ setPassword(_password);
+ }
+ return _password!=null;
+ }
- private String promptSecret(final String message){
- // ask the user for a password
- final String[] result=new String[1];
- Display display=Display.getCurrent();
- if(display!=null){
- result[0]=promptForPassword(message);
- }
- else{
- // sync exec in default thread
+ private String promptSecret(final String message){
+ // ask the user for a password
+ final String[] result=new String[1];
+ Display display=Display.getCurrent();
+ if(display!=null){
+ result[0]=promptForPassword(message);
+ }
+ else{
+ // sync exec in default thread
Display.getDefault().syncExec(() -> result[0] = promptForPassword(message));
- }
+ }
- if(result[0]==null){
- throw new OperationCanceledException();
- }
- return result[0];
- }
+ if(result[0]==null){
+ throw new OperationCanceledException();
+ }
+ return result[0];
+ }
- /* package */String promptForPassword(final String message){
- String username=getSession().getUserName();
- UserValidationDialog dialog=new UserValidationDialog(null, null,
- (username==null) ? "" : username, message); //$NON-NLS-1$
- dialog.setUsernameMutable(false);
- dialog.open();
- return dialog.getPassword();
- }
+ /* package */String promptForPassword(final String message){
+ String username=getSession().getUserName();
+ UserValidationDialog dialog=new UserValidationDialog(null, null,
+ (username==null) ? "" : username, message); //$NON-NLS-1$
+ dialog.setUsernameMutable(false);
+ dialog.open();
+ return dialog.getPassword();
+ }
- @Override
+ @Override
public String[] promptKeyboardInteractive(String destination, String name,
- String instruction, String[] prompt, boolean[] echo){
- if(prompt.length==0){
- // No need to prompt, just return an empty String array
- return new String[0];
- }
- try{
- if(attemptCount==0&&password!=null&&prompt.length==1
- &&prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
- // Return the provided password the first time but always prompt on
- // subsequent tries
- attemptCount++;
- return new String[] {password};
- }
- String[] result=promptForKeyboradInteractiveInUI(destination, name,
- instruction, prompt, echo);
- if(result==null)
- return null; // canceled
- if(result.length==1&&prompt.length==1
- &&prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
- password=result[0];
- }
- attemptCount++;
- return result;
- }
- catch(OperationCanceledException e){
- return null;
- }
- }
+ String instruction, String[] prompt, boolean[] echo){
+ if(prompt.length==0){
+ // No need to prompt, just return an empty String array
+ return new String[0];
+ }
+ try{
+ if(attemptCount==0&&password!=null&&prompt.length==1
+ &&prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
+ // Return the provided password the first time but always prompt on
+ // subsequent tries
+ attemptCount++;
+ return new String[] {password};
+ }
+ String[] result=promptForKeyboradInteractiveInUI(destination, name,
+ instruction, prompt, echo);
+ if(result==null)
+ return null; // canceled
+ if(result.length==1&&prompt.length==1
+ &&prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
+ password=result[0];
+ }
+ attemptCount++;
+ return result;
+ }
+ catch(OperationCanceledException e){
+ return null;
+ }
+ }
- private String[] promptForKeyboradInteractiveInUI(final String destination,
- final String name, final String instruction, final String[] prompt,
- final boolean[] echo){
- final String[][] result=new String[1][];
- Display display=Display.getCurrent();
- if(display!=null){
- result[0]=internalPromptForUserInteractive(destination, name,
- instruction, prompt, echo);
- }
- else{
- // sync exec in default thread
+ private String[] promptForKeyboradInteractiveInUI(final String destination,
+ final String name, final String instruction, final String[] prompt,
+ final boolean[] echo){
+ final String[][] result=new String[1][];
+ Display display=Display.getCurrent();
+ if(display!=null){
+ result[0]=internalPromptForUserInteractive(destination, name,
+ instruction, prompt, echo);
+ }
+ else{
+ // sync exec in default thread
Display.getDefault().syncExec(
() -> result[0] = internalPromptForUserInteractive(destination, name, instruction, prompt, echo));
- }
- return result[0];
- }
+ }
+ return result[0];
+ }
- /* package */ String[] internalPromptForUserInteractive(String destination,
- String name, String instruction, String[] prompt, boolean[] echo){
- String domain=null;
- String userName=getSession().getUserName();
- KeyboardInteractiveDialog dialog=new KeyboardInteractiveDialog(null,
- domain, destination, name, userName, instruction, prompt, echo);
- dialog.open();
- String[] _result=dialog.getResult();
- return _result;
- }
+ /* package */ String[] internalPromptForUserInteractive(String destination,
+ String name, String instruction, String[] prompt, boolean[] echo){
+ String domain=null;
+ String userName=getSession().getUserName();
+ KeyboardInteractiveDialog dialog=new KeyboardInteractiveDialog(null,
+ domain, destination, name, userName, instruction, prompt, echo);
+ dialog.open();
+ String[] _result=dialog.getResult();
+ return _result;
+ }
- @Override
+ @Override
public boolean promptYesNo(String question){
- int prompt=prompt(MessageDialog.QUESTION, Messages.UserInfoPrompter_0,
- question, new int[] {IDialogConstants.YES_ID, IDialogConstants.NO_ID},
- 0 // yes
- // the
- // default
- );
- return prompt==0;
- }
+ int prompt=prompt(MessageDialog.QUESTION, Messages.UserInfoPrompter_0,
+ question, new int[] {IDialogConstants.YES_ID, IDialogConstants.NO_ID},
+ 0 // yes
+ // the
+ // default
+ );
+ return prompt==0;
+ }
- @Override
+ @Override
public void showMessage(String message){
- prompt(MessageDialog.INFORMATION, Messages.UserInfoPrompter_1, message,
- new int[] {IDialogConstants.OK_ID}, 0);
- }
+ prompt(MessageDialog.INFORMATION, Messages.UserInfoPrompter_1, message,
+ new int[] {IDialogConstants.OK_ID}, 0);
+ }
- private int prompt(final int promptType, final String title,
- final String message, final int[] promptResponses,
- final int defaultResponse){
- final Display display=getStandardDisplay();
- final int[] retval=new int[1];
- final String[] buttons=new String[promptResponses.length];
- for(int i=0; i<promptResponses.length; i++){
- int prompt=promptResponses[i];
- switch(prompt){
- case IDialogConstants.OK_ID:
- buttons[i]=IDialogConstants.OK_LABEL;
- break;
- case IDialogConstants.CANCEL_ID:
- buttons[i]=IDialogConstants.CANCEL_LABEL;
- break;
- case IDialogConstants.NO_ID:
- buttons[i]=IDialogConstants.NO_LABEL;
- break;
- case IDialogConstants.YES_ID:
- buttons[i]=IDialogConstants.YES_LABEL;
- break;
- }
- }
+ private int prompt(final int promptType, final String title,
+ final String message, final int[] promptResponses,
+ final int defaultResponse){
+ final Display display=getStandardDisplay();
+ final int[] retval=new int[1];
+ final String[] buttons=new String[promptResponses.length];
+ for(int i=0; i<promptResponses.length; i++){
+ int prompt=promptResponses[i];
+ switch(prompt){
+ case IDialogConstants.OK_ID:
+ buttons[i]=IDialogConstants.OK_LABEL;
+ break;
+ case IDialogConstants.CANCEL_ID:
+ buttons[i]=IDialogConstants.CANCEL_LABEL;
+ break;
+ case IDialogConstants.NO_ID:
+ buttons[i]=IDialogConstants.NO_LABEL;
+ break;
+ case IDialogConstants.YES_ID:
+ buttons[i]=IDialogConstants.YES_LABEL;
+ break;
+ }
+ }
display.syncExec(() -> {
- final MessageDialog dialog=new MessageDialog(new Shell(display), title,
- null /* title image */, message, promptType, buttons,
- defaultResponse);
- retval[0]=dialog.open();
+ final MessageDialog dialog=new MessageDialog(new Shell(display), title,
+ null /* title image */, message, promptType, buttons,
+ defaultResponse);
+ retval[0]=dialog.open();
});
- return retval[0];
- }
+ return retval[0];
+ }
- private Display getStandardDisplay(){
- Display display=Display.getCurrent();
- if(display==null){
- display=Display.getDefault();
- }
- return display;
- }
+ private Display getStandardDisplay(){
+ Display display=Display.getCurrent();
+ if(display==null){
+ display=Display.getDefault();
+ }
+ return display;
+ }
}

Back to the top