Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryamanaka2003-11-21 02:52:58 -0500
committeryamanaka2003-11-21 02:52:58 -0500
commite163ae5d7848fc21eb227580274a61850e7b73cc (patch)
treebd5b4738e0a2027edbe1518844b3c674baf0118b
parentb44db246a41a185cbb00115934d3ce04c7b55ebe (diff)
downloadeclipse.platform.team-e163ae5d7848fc21eb227580274a61850e7b73cc.tar.gz
eclipse.platform.team-e163ae5d7848fc21eb227580274a61850e7b73cc.tar.xz
eclipse.platform.team-e163ae5d7848fc21eb227580274a61850e7b73cc.zip
The keyboard-interactive authentication is supported.
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/JSchSession.java58
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/KeyboardInteractiveDialog.java126
2 files changed, 183 insertions, 1 deletions
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/JSchSession.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/JSchSession.java
index c4a332486..5af5ccb3d 100644
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/JSchSession.java
+++ b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/JSchSession.java
@@ -127,7 +127,7 @@ class JSchSession{
}
}
- private static class MyUserInfo implements UserInfo{
+ private static class MyUserInfo implements UserInfo, UIKeyboardInteractive{
private String username;
private String password;
private String passphrase;
@@ -167,6 +167,23 @@ class JSchSession{
}
});
}
+ public String[] promptKeyboardInteractive(String destination,
+ String name,
+ String instruction,
+ String lang,
+ String[] prompt,
+ boolean[] echo){
+ KeyboardInteractivePrompt _prompt=new KeyboardInteractivePrompt(destination,
+ name,
+ instruction,
+ lang,
+ prompt,
+ echo);
+ Display.getDefault().syncExec(_prompt);
+ String[] result=_prompt.getResult();
+ return result;
+ }
+
private class YesNoPrompt implements Runnable{
private String prompt;
private int result;
@@ -219,6 +236,45 @@ class JSchSession{
return passphrase;
}
}
+ private class KeyboardInteractivePrompt implements Runnable{
+ private String destination;
+ private String name;
+ private String instruction;
+ private String lang;
+ private String[] prompt;
+ private boolean[] echo;
+ private String[] result;
+ KeyboardInteractivePrompt(String destination,
+ String name,
+ String instruction,
+ String lang,
+ String[] prompt,
+ boolean[] echo){
+ this.destination=destination;
+ this.name=name;
+ this.instruction=instruction;
+ this.lang=lang;
+ this.prompt=prompt;
+ this.echo=echo;
+ }
+ public void run(){
+ Display display=Display.getCurrent();
+ Shell shell=new Shell(display);
+ KeyboardInteractiveDialog dialog=new KeyboardInteractiveDialog(shell,
+ destination,
+ name,
+ instruction,
+ lang,
+ prompt,
+ echo);
+ dialog.open();
+ shell.dispose();
+ result=dialog.getResult();
+ }
+ public String[] getResult(){
+ return result;
+ }
+ }
}
static void shutdown(){
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/KeyboardInteractiveDialog.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/KeyboardInteractiveDialog.java
new file mode 100644
index 000000000..7d91b362c
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/KeyboardInteractiveDialog.java
@@ -0,0 +1,126 @@
+/* -*-mode:java; c-basic-offset:2; -*- */
+/**********************************************************************
+Copyright (c) 2003, Atsuhiko Yamanaka, JCraft,Inc. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation.
+**********************************************************************/
+package org.eclipse.team.cvs.ssh2;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.help.WorkbenchHelp;
+
+public class KeyboardInteractiveDialog extends Dialog {
+
+ private Text[] texts;
+ protected String destination;
+ protected String name;
+ protected String instruction;
+ protected String lang;
+ protected String[] prompt;
+ protected boolean[] echo;
+ private String message;
+ private String[] result;
+
+ public KeyboardInteractiveDialog(Shell parentShell,
+ String destination,
+ String name,
+ String instruction,
+ String lang,
+ String[] prompt,
+ boolean[] echo){
+ super(parentShell);
+ this.destination=destination;
+ this.name=name;
+ this.instruction=instruction;
+ this.lang=lang;
+ this.prompt=prompt;
+ this.echo=echo;
+ this.message="Keyboard Interactive for "+destination+(name!=null && name.length()>0 ? ": "+name : "");
+ }
+
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(message);
+ }
+
+ public void create() {
+ super.create();
+ if(texts.length>0){
+ texts[0].setFocus();
+ }
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite main=new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ layout.numColumns=3;
+ 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 (instruction!=null && instruction.length()>0) {
+ Label messageLabel=new Label(main, SWT.WRAP);
+ messageLabel.setText(instruction);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=3;
+ messageLabel.setLayoutData(data);
+ }
+ createPasswordFields(main);
+ return main;
+ }
+
+ 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]);
+ texts[i]=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ texts[i].setLayoutData(data);
+
+ if(!echo[i]){
+ texts[i].setEchoChar('*');
+ }
+ new Label(parent, SWT.NONE);
+ }
+
+ }
+
+ public String[] getResult() {
+ return result;
+ }
+
+ protected void okPressed() {
+ result=new String[prompt.length];
+ for(int i=0; i<texts.length; i++){
+ result[i]=texts[i].getText();
+ }
+ super.okPressed();
+ }
+
+ protected void cancelPressed() {
+ result=null;
+ super.cancelPressed();
+ }
+}

Back to the top