Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs')
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java34
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java80
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java1350
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java175
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java39
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java361
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java26
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java142
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java73
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties105
10 files changed, 0 insertions, 2385 deletions
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java
deleted file mode 100644
index afbafa5a3..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Method.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*-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.internal.ccvs.ssh2;
-
-import org.eclipse.team.internal.ccvs.core.*;
-
-/**
- * SSH2 will hijack the 'extssh' method and use the SSH2 protocol instead
- * of SSH1. If the server doesn't support SSH2, the server connection method
- * will try connecting with SSH1.
- *
- * @since 3.0
- */
-public class CVSSSH2Method implements IConnectionMethod {
-
- public String getName() {
- return "extssh"; //$NON-NLS-1$
- }
-
- public IServerConnection createConnection(ICVSRepositoryLocation root, String password) {
- return new CVSSSH2ServerConnection(root, password);
- }
-
- public void disconnect(ICVSRepositoryLocation location) {
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java
deleted file mode 100644
index 7caa88bba..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*-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.internal.ccvs.ssh2;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-public class CVSSSH2Plugin extends AbstractUIPlugin {
-
- public static String ID = "org.eclipse.team.cvs.ssh2"; //$NON-NLS-1$
- private static CVSSSH2Plugin plugin;
-
- static String SSH_HOME_DEFAULT = null;
- static {
- String ssh_dir_name = ".ssh"; //$NON-NLS-1$
-
- // Windows doesn't like files or directories starting with a dot.
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- ssh_dir_name = "ssh"; //$NON-NLS-1$
- }
- SSH_HOME_DEFAULT = System.getProperty("user.home"); //$NON-NLS-1$
- if (SSH_HOME_DEFAULT != null) {
- SSH_HOME_DEFAULT = SSH_HOME_DEFAULT + java.io.File.separator + ssh_dir_name;
- } else {
-
- }
- }
-
- public CVSSSH2Plugin() {
- super();
- plugin = this;
- }
-
- public static CVSSSH2Plugin getPlugin() {
- return plugin;
- }
-
- public void stop(BundleContext context) throws Exception {
- try {
- JSchSession.shutdown();
- } finally {
- super.stop(context);
- }
- }
-
- public static CVSSSH2Plugin getDefault() {
- return plugin;
- }
-
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- private void initializeDefaultPreferences() {
- IPreferenceStore store = getPreferenceStore();
- store.setDefault(ISSHContants.KEY_SSH2HOME, SSH_HOME_DEFAULT);
- store.setDefault(ISSHContants.KEY_PRIVATEKEY, ISSHContants.PRIVATE_KEYS_DEFAULT);
- store.setDefault(ISSHContants.KEY_PROXY_TYPE, ISSHContants.HTTP);
- store.setDefault(ISSHContants.KEY_PROXY_PORT, ISSHContants.HTTP_DEFAULT_PORT);
- store.setDefault(ISSHContants.KEY_PROXY_AUTH, "false"); //$NON-NLS-1$
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- Policy.localize("org.eclipse.team.internal.ccvs.ssh2.messages"); //$NON-NLS-1$
- initializeDefaultPreferences();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java
deleted file mode 100644
index e74d163bf..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java
+++ /dev/null
@@ -1,1350 +0,0 @@
-/* -*-mode:java; c-basic-offset:2; -*- */
-/**********************************************************************
-Copyright (c) 2003,2004 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.internal.ccvs.ssh2;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.dialogs.*;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.TableEditor;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import com.jcraft.jsch.*;
-
-public class CVSSSH2PreferencePage extends PreferencePage
- implements IWorkbenchPreferencePage {
-
-// private DirectoryFieldEditor ssh2homeEditor;
-
- private Label ssh2HomeLabel;
- private Label proxyTypeLabel;
- private Label proxyHostLabel;
- private Label proxyPortLabel;
- private Label proxyUserLabel;
- private Label proxyPassLabel;
- private Label privateKeyLabel;
- private Combo proxyTypeCombo;
- private Text ssh2HomeText;
- private Text proxyHostText;
- private Text proxyPortText;
- private Text proxyUserText;
- private Text proxyPassText;
- private Text privateKeyText;
- private Button enableProxy;
- private Button enableAuth;
- private Button privateKeyAdd;
- private boolean useProxy;
- private boolean useAuth;
-
- private Button ssh2HomeBrowse;
- private Button keyGenerateDSA;
- private Button keyGenerateRSA;
- private Button keyLoad;
- private Button keyExport;
- private Button saveKeyPair;
- private Label keyCommentLabel;
- private Text keyCommentText;
- private Label keyFingerPrintLabel;
- private Text keyFingerPrintText;
- private Label keyPassphrase1Label;
- private Text keyPassphrase1Text;
- private Label keyPassphrase2Label;
- private Text keyPassphrase2Text;
- private Label publicKeylabel;
- private Text publicKeyText;
- private KeyPair kpair=null;
- private String kpairComment;
-
- public static final String AUTH_SCHEME = "";//$NON-NLS-1$
- public static final URL FAKE_URL;
-
- static {
- URL temp = null;
- try{
- temp = new URL("http://org.eclipse.team.cvs.ssh2");//$NON-NLS-1$
- }catch (MalformedURLException e){}
- FAKE_URL = temp;
- }
-
- public CVSSSH2PreferencePage() {
-// super(GRID);
- IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore();
- setPreferenceStore(store);
- setDescription(Policy.bind("CVSSSH2PreferencePage.18")); //$NON-NLS-1$
- }
-
- protected Control createContents(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- initializeDialogUnits(container);
-
- TabFolder tabFolder = new TabFolder(container, SWT.NONE);
- tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
- tabItem.setText(Policy.bind("CVSSSH2PreferencePage.19")); //$NON-NLS-1$
- tabItem.setControl(createGeneralPage(tabFolder));
-
- tabItem = new TabItem(tabFolder, SWT.NONE);
- tabItem.setText(Policy.bind("CVSSSH2PreferencePage.20")); //$NON-NLS-1$
- tabItem.setControl(createProxyPage(tabFolder));
-
- tabItem = new TabItem(tabFolder, SWT.NONE);
- tabItem.setText(Policy.bind("CVSSSH2PreferencePage.21")); //$NON-NLS-1$
- tabItem.setControl(createKeyManagementPage(tabFolder));
-
- tabItem = new TabItem(tabFolder, SWT.NONE);
- tabItem.setText(Policy.bind("CVSSSH2PreferencePage.133")); //$NON-NLS-1$
- tabItem.setControl(createHostKeyManagementPage(tabFolder));
-
- initControls();
-
- Dialog.applyDialogFont(parent);
- return container;
- }
-
- private Control createGeneralPage(Composite parent) {
- Composite group=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- layout.numColumns=3;
- group.setLayout(layout);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- group.setLayoutData(data);
-
- createSpacer(group, 3);
-
- ssh2HomeLabel=new Label(group, SWT.NONE);
- ssh2HomeLabel.setText(Policy.bind("CVSSSH2PreferencePage.23")); //$NON-NLS-1$
-
- 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(Policy.bind("CVSSSH2PreferencePage.24")); //$NON-NLS-1$
- gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan=1;
- ssh2HomeBrowse.setLayoutData(gd);
-
- createSpacer(group, 3);
-
- privateKeyLabel=new Label(group, SWT.NONE);
- privateKeyLabel.setText(Policy.bind("CVSSSH2PreferencePage.25")); //$NON-NLS-1$
-
- 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(Policy.bind("CVSSSH2PreferencePage.26")); //$NON-NLS-1$
- gd=new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan=1;
- privateKeyAdd.setLayoutData(gd);
-
- ssh2HomeBrowse.addSelectionListener(new SelectionAdapter(){
- 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(Policy.bind("CVSSSH2PreferencePage.27")); //$NON-NLS-1$
- String dir=dd.open();
- if(dir==null){ // cancel
- return;
- }
- ssh2HomeText.setText(dir);
- }
- });
-
- privateKeyAdd.addSelectionListener(new SelectionAdapter(){
- 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 createProxyPage(Composite parent) {
- Composite group=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- layout.numColumns=3;
- group.setLayout(layout);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- group.setLayoutData(data);
-
- enableProxy=new Button(group, SWT.CHECK);
- enableProxy.setText(Policy.bind("CVSSSH2PreferencePage.30")); //$NON-NLS-1$
- GridData gd=new GridData();
- gd.horizontalSpan=3;
- enableProxy.setLayoutData(gd);
-
- proxyTypeLabel=new Label(group, SWT.NONE);
- proxyTypeLabel.setText(Policy.bind("CVSSSH2PreferencePage.31")); //$NON-NLS-1$
- proxyTypeCombo=new Combo(group, SWT.READ_ONLY);
- proxyTypeCombo.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- proxyTypeCombo.setLayoutData(gd);
- proxyTypeCombo.addModifyListener(new ModifyListener () {
- public void modifyText(ModifyEvent e){
- if(proxyPortText==null) return;
- Combo combo=(Combo)(e.getSource());
- String foo=combo.getText();
- if(foo.equals(ISSHContants.HTTP)){
- proxyPortText.setText(ISSHContants.HTTP_DEFAULT_PORT);
- }
- else if(foo.equals(ISSHContants.SOCKS5)){
- proxyPortText.setText(ISSHContants.SOCKS5_DEFAULT_PORT);
- }
- }
- });
- proxyTypeCombo.add(ISSHContants.HTTP);
- proxyTypeCombo.add(ISSHContants.SOCKS5);
- proxyTypeCombo.select(0);
-
- proxyHostLabel=new Label(group, SWT.NONE);
- proxyHostLabel.setText(Policy.bind("CVSSSH2PreferencePage.32")); //$NON-NLS-1$
-
- proxyHostText=new Text(group, SWT.SINGLE | SWT.BORDER);
- proxyHostText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- proxyHostText.setLayoutData(gd);
-
- proxyPortLabel=new Label(group, SWT.NONE);
- proxyPortLabel.setText(Policy.bind("CVSSSH2PreferencePage.33")); //$NON-NLS-1$
-
- proxyPortText=new Text(group, SWT.SINGLE | SWT.BORDER);
- proxyPortText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- proxyPortText.setLayoutData(gd);
-
- proxyPortText.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent e){
- if(isValidPort(proxyPortText.getText())){
- setErrorMessage(null);
- }
- }
- });
-
-
- createSpacer(group, 3);
-
- enableAuth=new Button(group, SWT.CHECK);
- enableAuth.setText(Policy.bind("CVSSSH2PreferencePage.34")); //$NON-NLS-1$
- gd=new GridData();
- gd.horizontalSpan=3;
- enableAuth.setLayoutData(gd);
-
- proxyUserLabel=new Label(group, SWT.NONE);
- proxyUserLabel.setText(Policy.bind("CVSSSH2PreferencePage.35")); //$NON-NLS-1$
-
- proxyUserText=new Text(group, SWT.SINGLE | SWT.BORDER);
- proxyUserText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- proxyUserText.setLayoutData(gd);
-
- proxyPassLabel=new Label(group, SWT.NONE);
- proxyPassLabel.setText(Policy.bind("CVSSSH2PreferencePage.36")); //$NON-NLS-1$
-
- proxyPassText=new Text(group, SWT.SINGLE | SWT.BORDER);
- proxyPassText.setFont(group.getFont());
- gd=new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan=2;
- proxyPassText.setLayoutData(gd);
-
- // performDefaults();
-
- enableProxy.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- updateControls();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- enableAuth.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- updateControls();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- return group;
- }
- private Control createKeyManagementPage(Composite parent) {
- int columnSpan=3;
- Composite group=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- layout.numColumns=3;
- group.setLayout(layout);
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- group.setLayoutData(gd);
-
- keyGenerateDSA=new Button(group, SWT.NULL);
- keyGenerateDSA.setText(Policy.bind("CVSSSH2PreferencePage.131")); //$NON-NLS-1$
- gd=new GridData();
- gd.horizontalSpan=1;
- keyGenerateDSA.setLayoutData(gd);
-
- keyGenerateRSA=new Button(group, SWT.NULL);
- keyGenerateRSA.setText(Policy.bind("CVSSSH2PreferencePage.132")); //$NON-NLS-1$
- gd=new GridData();
- gd.horizontalSpan=1;
- keyGenerateRSA.setLayoutData(gd);
-
- keyLoad=new Button(group, SWT.NULL);
- keyLoad.setText(Policy.bind("CVSSSH2PreferencePage.128")); //$NON-NLS-1$
- gd=new GridData();
- gd.horizontalSpan=1;
- keyLoad.setLayoutData(gd);
-
- publicKeylabel=new Label(group, SWT.NONE);
- publicKeylabel.setText(Policy.bind("CVSSSH2PreferencePage.39")); //$NON-NLS-1$
- gd=new GridData();
- gd.horizontalSpan=columnSpan;
- publicKeylabel.setLayoutData(gd);
-
- publicKeyText=new Text(group,SWT.MULTI|SWT.BORDER|SWT.V_SCROLL|SWT.WRAP);
- 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);
-
- keyExport=new Button(group, SWT.NULL);
- keyExport.setText(Policy.bind("CVSSSH2PreferencePage.105")); //$NON-NLS-1$
- gd=new GridData(GridData.HORIZONTAL_ALIGN_END);
- gd.horizontalSpan=columnSpan;
- keyExport.setLayoutData(gd);
-
- keyFingerPrintLabel=new Label(group, SWT.NONE);
- keyFingerPrintLabel.setText(Policy.bind("CVSSSH2PreferencePage.41")); //$NON-NLS-1$
- keyFingerPrintText=new Text(group, SWT.SINGLE | SWT.BORDER);
- 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(Policy.bind("CVSSSH2PreferencePage.42")); //$NON-NLS-1$
- 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(new ModifyListener(){
- public void modifyText(ModifyEvent e){
- if(kpair==null)return;
- try{
- ByteArrayOutputStream out=new ByteArrayOutputStream();
- kpair.writePublicKey(out, keyCommentText.getText());
- out.close();
- publicKeyText.setText(out.toString());
- }
- catch(IOException ee){}
- }});
-
- keyPassphrase1Label=new Label(group, SWT.NONE);
- keyPassphrase1Label.setText(Policy.bind("CVSSSH2PreferencePage.43")); //$NON-NLS-1$
- 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(Policy.bind("CVSSSH2PreferencePage.44")); //$NON-NLS-1$
- 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(new ModifyListener(){
- public void modifyText(ModifyEvent 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(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$
- }
- }
- });
-
- keyPassphrase2Text.addModifyListener(new ModifyListener(){
- public void modifyText(ModifyEvent 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(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$
- }
- return;
- }
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$
- }
- }
- });
-
- keyPassphrase2Text.addFocusListener(new FocusListener(){
- 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(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$
- }
- return;
- }
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$
- }
- }
- public void focusLost(FocusEvent e){
- String pass1=keyPassphrase1Text.getText();
- String pass2=keyPassphrase2Text.getText();
- if(pass1.equals(pass2)){
- setErrorMessage(null);
- }
- else{
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.48")); //$NON-NLS-1$
- }
- }
- });
-
- saveKeyPair=new Button(group, SWT.NULL);
- saveKeyPair.setText(Policy.bind("CVSSSH2PreferencePage.45")); //$NON-NLS-1$
- gd=new GridData(GridData.HORIZONTAL_ALIGN_END);
- gd.horizontalSpan=columnSpan;
- saveKeyPair.setLayoutData(gd);
-
- SelectionAdapter keygenadapter=new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e){
- JSch jsch=JSchSession.getJSch();
- boolean ok=true;
- String _type=""; //$NON-NLS-1$
-
- try{
- int type=0;
- if(e.widget==keyGenerateDSA){
- type=KeyPair.DSA;
- _type=ISSHContants.DSA;
- }
- else if(e.widget==keyGenerateRSA){
- type=KeyPair.RSA;
- _type=ISSHContants.RSA;
- }
- else{
- return;
- }
-
- final KeyPair[] _kpair=new KeyPair[1];
- final JSch _jsch=jsch;
- final int __type=type;
- final JSchException[] _e=new JSchException[1];
- BusyIndicator.showWhile(getShell().getDisplay(),
- new Runnable(){
- public void run(){
- try{
- _kpair[0]=KeyPair.genKeyPair(_jsch, __type);
- }catch(JSchException e){
- _e[0]=e;
- }
- }}
- );
- 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(),
- Policy.bind("CVSSSH2PreferencePage.error"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.47")); //$NON-NLS-1$
- }
- }
- };
- keyGenerateDSA.addSelectionListener(keygenadapter);
- keyGenerateRSA.addSelectionListener(keygenadapter);
-
- keyLoad.addSelectionListener(new SelectionAdapter(){
- 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{
- JSch jsch=JSchSession.getJSch();
- KeyPair _kpair=KeyPair.load(jsch, pkeyab);
- PassphrasePrompt prompt=null;
- while(_kpair.isEncrypted()){
- if(prompt==null){
- prompt=new PassphrasePrompt(Policy.bind("CVSSSH2PreferencePage.126", pkey)); //$NON-NLS-1$
- }
- Display.getDefault().syncExec(prompt);
- String passphrase=prompt.getPassphrase();
- if(passphrase==null) break;
- if(_kpair.decrypt(passphrase)){
- break;
- }
- MessageDialog.openError(getShell(),
- Policy.bind("CVSSSH2PreferencePage.error"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.129", pkey)); //$NON-NLS-1$
- }
- if(_kpair.isEncrypted()){
- return;
- }
- kpair=_kpair;
- String _type=(kpair.getKeyType()==KeyPair.DSA)?ISSHContants.DSA:ISSHContants.RSA;
- 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(),
- Policy.bind("CVSSSH2PreferencePage.error"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.130")); //$NON-NLS-1$
- }
- }
- });
-
- keyExport.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e){
- if(kpair==null)return;
-
- setErrorMessage(null);
-
- final String[] target=new String[1];
- final String title=Policy.bind("CVSSSH2PreferencePage.106"); //$NON-NLS-1$
- final String message=Policy.bind("CVSSSH2PreferencePage.107"); //$NON-NLS-1$
- Display.getDefault().syncExec(new Runnable(){
- public void run(){
- Display display=Display.getCurrent();
- Shell shell=new Shell(display);
- ExportDialog dialog=new ExportDialog(shell, title, message);
- dialog.open();
- shell.dispose();
- target[0]=dialog.getTarget();
- }});
- 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(Policy.bind("CVSSSH2PreferencePage.108", target[0])); //$NON-NLS-1$
- 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){}
- }
- kpair.writePublicKey(bos, kpairComment);
- bos.close();
- export_via_sftp(user, host, port,
- ".ssh/authorized_keys", //$NON-NLS-1$
- bos.toByteArray());
- }
- catch(IOException ee){
- }
- catch(JSchException ee){
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.111")); //$NON-NLS-1$
- }
- }});
-
- saveKeyPair.addSelectionListener(new SelectionAdapter(){
- 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(),
- Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.49") //$NON-NLS-1$
- )){
- return ;
- }
- }
-
- kpair.setPassphrase(pass);
-
- IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore();
- String home=ssh2HomeText.getText();
-
- File _home=new File(home);
-
- if(!_home.exists()){
- if(!MessageDialog.openConfirm(getShell(),
- Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.50",home) //$NON-NLS-1$
- )){
- return ;
- }
- if(!_home.mkdirs()){
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100")+home); //$NON-NLS-1$
- 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(),
- Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.53", file) //$NON-NLS-1$
- )){
- 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(),
- Policy.bind("CVSSSH2PreferencePage.information"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.55")+ //$NON-NLS-1$
- "\n"+ //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.57")+file+ //$NON-NLS-1$
- "\n"+ //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.59")+ //$NON-NLS-1$
- file+
- ".pub"); //$NON-NLS-1$
- }
- }
- });
-
- return group;
- }
-
- private TableViewer viewer;
- private Button addHostKeyButton;
- private Button removeHostKeyButton;
- class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
- 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(JSchSession.getJSch());
- default:
- return null;
- }
- }
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- };
-
- private Control createHostKeyManagementPage(Composite parent) {
- int columnSpan=3;
- Composite group=new Composite(parent, SWT.NULL);
- GridLayout layout=new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- 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(Policy.bind("CVSSSH2PreferencePage.139")); //$NON-NLS-1$
- 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, new Listener() {
- public void handleEvent(Event 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(Policy.bind("CVSSSH2PreferencePage.134")); //$NON-NLS-1$
- columns[1].setText(Policy.bind("CVSSSH2PreferencePage.135")); //$NON-NLS-1$
- columns[2].setText(Policy.bind("CVSSSH2PreferencePage.136")); //$NON-NLS-1$
- viewer.setColumnProperties(new String[] {
- Policy.bind("CVSSSH2PreferencePage.134"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.135"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.136")}); //$NON-NLS-1$
- viewer.setLabelProvider(new TableLabelProvider());
- viewer.setContentProvider(new IStructuredContentProvider() {
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- public Object[] getElements(Object inputElement) {
- if (inputElement == null) return null;
- return (Object[])inputElement;
- }
- });
- TableLayout tl = new TableLayout();
- tl.addColumnData(new ColumnWeightData(20));
- tl.addColumnData(new ColumnWeightData(10));
- 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);
-
- addHostKeyButton = new Button(buttons, SWT.PUSH);
- addHostKeyButton.setText(Policy.bind("CVSSSH2PreferencePage.137")); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- gd.widthHint = Math.max(widthHint, addHostKeyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- addHostKeyButton.setLayoutData(gd);
- addHostKeyButton.setEnabled(false);
- addHostKeyButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- //addHostKey();
- }
- });
- removeHostKeyButton = new Button(buttons, SWT.PUSH);
- removeHostKeyButton.setText(Policy.bind("CVSSSH2PreferencePage.138")); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
- widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- gd.widthHint = Math.max(widthHint, addHostKeyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
- removeHostKeyButton.setLayoutData(gd);
- removeHostKeyButton.setEnabled(false);
- removeHostKeyButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- removeHostKey();
- }
- });
-
- Dialog.applyDialogFont(parent);
-
- JSchSession.loadKnownHosts();
- HostKeyRepository hkr=JSchSession.getJSch().getHostKeyRepository();
- viewer.setInput(hkr.getHostKey());
- handleSelection();
-
- return group;
- }
-
- private void handleSelection() {
- boolean empty = viewer.getSelection().isEmpty();
- removeHostKeyButton.setEnabled(!empty);
- }
- private void removeHostKey(){
- JSch jsch=JSchSession.getJSch();
- IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
- HostKeyRepository hkr=JSchSession.getJSch().getHostKeyRepository();
- for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
- HostKey hostkey = (HostKey) iterator.next();
- hkr.remove(hostkey.getHost(), hostkey.getType());
- viewer.remove(hostkey);
- }
- }
- private void export_via_sftp(String user, String host, int port, String target, byte[] pkey) throws JSchException{
- try{
-
- /*
- int i=0;
- String authorized_keys=target;
- String dir="";
- String separator="/";
- i=target.lastIndexOf("/");
- if(i<0){
- i=target.lastIndexOf("\\");
- if(i>=0){ separator="\\"; }
- }
- else{
- }
- if(i>=0){
- authorized_keys=target.substring(i+1);
- dir=target.substring(0, i+1);
- }
- */
-
- IProgressMonitor pm=new org.eclipse.core.runtime.NullProgressMonitor();
- Session session=JSchSession.getSession(null, user, "", host, port, new JSchSession.ResponsiveSocketFacory(pm)); //$NON-NLS-1$
- if(session.getServerVersion().indexOf("OpenSSH")==-1){ //$NON-NLS-1$
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.110")); //$NON-NLS-1$
- return;
- }
- Channel channel=session.openChannel("sftp"); //$NON-NLS-1$
- channel.connect();
- ChannelSftp c=(ChannelSftp)channel;
-
- String pwd=c.pwd();
- SftpATTRS attr=null;
-
- try{ attr=c.stat(".ssh"); } //$NON-NLS-1$
- catch(SftpException ee){ }
- if(attr==null){
- try{ c.mkdir(".ssh"); } //$NON-NLS-1$
- catch(SftpException ee){
- setErrorMessage(ee.message);
- return;
- }
- }
- try{ c.cd(".ssh"); } //$NON-NLS-1$
- catch(SftpException ee){
- setErrorMessage(ee.message);
- 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(),
- Policy.bind("CVSSSH2PreferencePage.information"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.109")+ //$NON-NLS-1$
- (user+"@"+host+(port==22 ? "" : ":"+port)+":~/.ssh/authorized_keys")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- c.disconnect();
- //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);
- }
- }
- private void updateControls() {
- boolean enable=enableProxy.getSelection();
- proxyTypeLabel.setEnabled(enable);
- proxyTypeCombo.setEnabled(enable);
- proxyPortLabel.setEnabled(enable);
- proxyPortText.setEnabled(enable);
- proxyHostLabel.setEnabled(enable);
- proxyHostText.setEnabled(enable);
-
- enableAuth.setEnabled(enable);
- enable&=enableAuth.getSelection();
- proxyUserLabel.setEnabled(enable);
- proxyUserText.setEnabled(enable);
- proxyPassLabel.setEnabled(enable);
- proxyPassText.setEnabled(enable);
-
- 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);
- }
-
- public void init(IWorkbench workbench) {
-// super.init(workbench);
-// initControls();
- }
-
- public void initialize() {
- initControls();
- }
-
- private void initControls(){
- IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore();
- ssh2HomeText.setText(store.getString(ISSHContants.KEY_SSH2HOME));
- privateKeyText.setText(store.getString(ISSHContants.KEY_PRIVATEKEY));
- useProxy=store.getString(ISSHContants.KEY_PROXY).equals("true"); //$NON-NLS-1$
- enableProxy.setSelection(useProxy);
- proxyHostText.setText(store.getString(ISSHContants.KEY_PROXY_HOST));
- proxyTypeCombo.select(store.getString(ISSHContants.KEY_PROXY_TYPE).equals(ISSHContants.HTTP)?0:1);
- proxyPortText.setText(store.getString(ISSHContants.KEY_PROXY_PORT));
- useAuth=store.getString(ISSHContants.KEY_PROXY_AUTH).equals("true"); //$NON-NLS-1$
- enableAuth.setSelection(useAuth);
-
- Map map = Platform.getAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME); //$NON-NLS-1$
- if(map!=null){
- String username=(String) map.get(ISSHContants.KEY_PROXY_USER);
- if(username!=null) proxyUserText.setText(username);
- String password=(String) map.get(ISSHContants.KEY_PROXY_PASS);
- if(password!=null) proxyPassText.setText(password);
- }
-
- proxyPassText.setEchoChar('*');
- updateControls();
- }
- public boolean performOk() {
- boolean result = super.performOk();
- if (result) {
- setErrorMessage(null);
- String home = ssh2HomeText.getText();
- File _home = new File(home);
- if (!_home.exists()) {
- if (MessageDialog.openQuestion(getShell(), Policy.bind("CVSSSH2PreferencePage.question"), //$NON-NLS-1$
- Policy.bind("CVSSSH2PreferencePage.99", home) //$NON-NLS-1$
- )) {
- if (!(_home.mkdirs())) {
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100") + home); //$NON-NLS-1$
- return false;
- }
- }
- }
- if (enableProxy.getSelection() && !isValidPort(proxyPortText.getText())) {
- return false;
- }
- IPreferenceStore store = CVSSSH2Plugin.getDefault().getPreferenceStore();
- store.setValue(ISSHContants.KEY_SSH2HOME, home);
- store.setValue(ISSHContants.KEY_PRIVATEKEY, privateKeyText.getText());
- store.setValue(ISSHContants.KEY_PROXY, enableProxy.getSelection());
- store.setValue(ISSHContants.KEY_PROXY_TYPE, proxyTypeCombo.getText());
- store.setValue(ISSHContants.KEY_PROXY_HOST, proxyHostText.getText());
- store.setValue(ISSHContants.KEY_PROXY_PORT, proxyPortText.getText());
- store.setValue(ISSHContants.KEY_PROXY_AUTH, enableAuth.getSelection());
-
- // Store proxy username and password in the keyring file for now. This is
- // not ultra secure, but at least it will be saved between sessions.
- Map map = Platform.getAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME); //$NON-NLS-1$
- if (map == null)
- map = new java.util.HashMap(10);
- map.put(ISSHContants.KEY_PROXY_USER, proxyUserText.getText());
- map.put(ISSHContants.KEY_PROXY_PASS, proxyPassText.getText());
- try {
- Platform.addAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME, map); //$NON-NLS-1$
- } catch (CoreException e) {
- Util.logError("Cannot save ssh2 proxy authentication information to keyring file", e); //$NON-NLS-1$
- }
- }
- CVSSSH2Plugin.getDefault().savePluginPreferences();
- return result;
- }
-
- private boolean isValidPort(String port){
- int i=-1;
- try {
- i=Integer.parseInt(port);
- }
- catch (NumberFormatException ee) {
-// setErrorMessage(Policy.bind("CVSSSH2PreferencePage.103")); //$NON-NLS-1$
-// return false;
- }
- if((i < 0) || (i > 65535)){
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.104")); //$NON-NLS-1$
- return false;
- }
- return true;
- }
-
- public void performApply() {
- performOk();
- }
-
- protected void performDefaults(){
- super.performDefaults();
- enableProxy.setSelection(false);
- proxyHostText.setText(""); //$NON-NLS-1$
- proxyPortText.setText(ISSHContants.HTTP_DEFAULT_PORT);
- proxyTypeCombo.select(0);
- enableAuth.setSelection(false);
- proxyUserText.setText(""); //$NON-NLS-1$
- proxyPassText.setText(""); //$NON-NLS-1$
- 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);
- }
-}
-
-class ExportDialog extends Dialog {
- 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;
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(title);
- }
-
- public void create() {
- super.create();
- field.setFocus();
- }
-
- protected Control createDialogArea(Composite parent) {
-
- parent = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- parent.setLayout(layout);
- parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite main=new Composite(parent, SWT.NONE);
- 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);
- }
-
- createTargetFields(main);
- Dialog.applyDialogFont(main);
- return main;
- }
-
- protected void createTargetFields(Composite parent) {
- new Label(parent, SWT.NONE).setText(Policy.bind("CVSSSH2PreferencePage.125")); //$NON-NLS-1$
-
- field=new Text(parent, SWT.BORDER);
- GridData data=new GridData(GridData.FILL_HORIZONTAL);
- data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
- data.horizontalSpan=2;
- field.setLayoutData(data);
- }
-
- 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 cancelPressed() {
- target=null;
- super.cancelPressed();
- }
-}
-
-class PassphrasePrompt implements Runnable{
- private String message;
- private String passphrase;
- PassphrasePrompt(String message){
- this.message=message;
- }
- 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;
- }
-}
-
-class PassphraseDialog extends Dialog {
- protected Text passphraseField;
- protected String passphrase = null;
- protected String message = null;
-
- public PassphraseDialog(Shell parentShell, String message) {
- super(parentShell);
- this.message = message;
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(message);
- }
-
- public void create() {
- super.create();
- passphraseField.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);
- }
-
- createPassphraseFields(main);
- return main;
- }
-
- protected void createPassphraseFields(Composite parent) {
- new Label(parent, SWT.NONE).setText(Policy.bind("CVSSSH2PreferencePage.127")); //$NON-NLS-1$
- 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);
- }
-
- 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 cancelPressed() {
- passphrase=null;
- super.cancelPressed();
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java
deleted file mode 100644
index ea787fba3..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -*-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.internal.ccvs.ssh2;
-import java.io.*;
-import java.net.NoRouteToHostException;
-import java.net.UnknownHostException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
-import org.eclipse.team.internal.ccvs.ssh.SSHServerConnection;
-import org.eclipse.team.internal.core.streams.*;
-
-import com.jcraft.jsch.*;
-
-/**
- * SSH2 connection method. Has the property of defaulting to SSH1 if the server
- * doesn't support SSH2.
- */
-public class CVSSSH2ServerConnection implements IServerConnection {
- private static final String COMMAND = "cvs server"; //$NON-NLS-1$
- private ICVSRepositoryLocation location;
- private String password;
- private InputStream inputStream;
- private OutputStream outputStream;
- private Session session;
- private Channel channel;
- private IServerConnection ssh1;
-
- protected CVSSSH2ServerConnection(ICVSRepositoryLocation location, String password) {
- this.location = location;
- this.password = password;
- }
- public void close() throws IOException {
- if (ssh1 != null) {
- ssh1.close();
- ssh1 = null;
- return;
- }
- try {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException e) {
- // Ignore I/O Exception on close
- }
- }
- } finally {
- try {
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException e) {
- // Ignore I/O Exception on close
- }
- }
- } finally {
- if (channel != null)
- channel.disconnect();
- }
- }
- }
- public InputStream getInputStream() {
- if (ssh1 != null) {
- return ssh1.getInputStream();
- }
- return inputStream;
- }
- public OutputStream getOutputStream() {
- if (ssh1 != null) {
- return ssh1.getOutputStream();
- }
- return outputStream;
- }
- public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
- if (ssh1 != null) {
- ssh1.open(monitor);
- return;
- }
- monitor.subTask(Policy.bind("CVSSSH2ServerConnection.open", location.getHost())); //$NON-NLS-1$
- monitor.worked(1);
- internalOpen(monitor);
- }
- /**
- * @param monitor
- * @throws IOException
- * @throws CVSAuthenticationException
- */
- private void internalOpen(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
- try {
- String hostname = location.getHost();
- String username = location.getUsername();
- int port = location.getPort();
- if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT)
- port = 0;
- int retry = 1;
- OutputStream channel_out;
- InputStream channel_in;
- while (true) {
- session = JSchSession.getSession(location, username, password, hostname, port, new JSchSession.ResponsiveSocketFacory(monitor));
- channel = session.openChannel("exec"); //$NON-NLS-1$
- ((ChannelExec) channel).setCommand(COMMAND);
- channel_out = channel.getOutputStream();
- channel_in = channel.getInputStream();
- try {
- channel.connect();
- } catch (JSchException ee) {
- retry--;
- if(retry<0){
- throw new CVSAuthenticationException(Policy.bind("CVSSSH2ServerConnection.3"), CVSAuthenticationException.NO_RETRY); //$NON-NLS-1$
- }
- if(session.isConnected()){
- session.disconnect();
- }
- continue;
- }
- break;
- }
- int timeout = location.getTimeout();
- inputStream = new PollingInputStream(new TimeoutInputStream(new FilterInputStream(channel_in) {
- public void close() throws IOException {
- // Don't close the underlying stream as it belongs to the session
- }
- },
- 8192 /*bufferSize*/, 1000 /*readTimeout*/, -1 /*closeTimeout*/, true /* growWhenFull */), timeout > 0 ? timeout : 1, monitor);
- outputStream = new PollingOutputStream(new TimeoutOutputStream(new FilterOutputStream(channel_out) {
- public void close() throws IOException {
- // Don't close the underlying stream as it belongs to the session
- }
- },
- 8192 /*buffersize*/, 1000 /*writeTimeout*/, 1000 /*closeTimeout*/), timeout > 0 ? timeout : 1, monitor);
- } catch (JSchException e) {
- if (e.toString().indexOf("invalid server's version string") == -1) { //$NON-NLS-1$
- String message = e.getMessage();
- if (message.equals("Auth fail")) { //$NON-NLS-1$
- message = Policy.bind("CVSSSH2ServerConnection.0"); //$NON-NLS-1$
- // Could possibly retry below but wont just in case
- } else if (message.startsWith("Session.connect: ")) { //$NON-NLS-1$
- // Jsh has messages formatted like "Session.connect: java.net.NoRouteToHostException: ..."
- // Strip of the exception and try to convert it to a more meaningfull string
- int start = message.indexOf(": ") + 1; //$NON-NLS-1$
- if (start != -1) {
- int end = message.indexOf(": ", start); //$NON-NLS-1$
- if (end != -1) {
- String exception = message.substring(start, end).trim();
- if (exception.indexOf("NoRouteToHostException") != -1) { //$NON-NLS-1$
- message = Policy.bind("CVSSSH2ServerConnection.1", location.getHost()); //$NON-NLS-1$
- throw new NoRouteToHostException(message);
- } else if (exception.indexOf("java.net.UnknownHostException") != -1) { //$NON-NLS-1$
- throw new UnknownHostException(location.getHost());
- } else {
- message = message.substring(end + 1).trim();
- }
- }
- }
- }
- throw new CVSAuthenticationException(message, CVSAuthenticationException.NO_RETRY);
- }
- ssh1 = new SSHServerConnection(location, password);
- if (ssh1 == null) {
- throw new CVSAuthenticationException(e.toString(), CVSAuthenticationException.NO_RETRY);
- }
- ssh1.open(monitor);
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java
deleted file mode 100644
index 771ad006d..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/ISSHContants.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ssh2;
-
-
-/**
- * Defines the constants used by the SSH2 Plugin
- */
-public interface ISSHContants {
-
- public static String KEY_PROXY="CVSSSH2PreferencePage.PROXY"; //$NON-NLS-1$
- public static String KEY_PROXY_TYPE="CVSSSH2PreferencePage.PROXY_TYPE"; //$NON-NLS-1$
- public static String KEY_PROXY_HOST="CVSSSH2PreferencePage.PROXY_HOST"; //$NON-NLS-1$
- public static String KEY_PROXY_PORT="CVSSSH2PreferencePage.PROXY_PORT"; //$NON-NLS-1$
- public static String KEY_PROXY_AUTH="CVSSSH2PreferencePage.PROXY_AUTH"; //$NON-NLS-1$
- public static String KEY_PROXY_USER="CVSSSH2PreferencePage.PROXY_USER"; //$NON-NLS-1$
- public static String KEY_PROXY_PASS="CVSSSH2PreferencePage.PROXY_PASS"; //$NON-NLS-1$
- public static String KEY_SSH2HOME="CVSSSH2PreferencePage.SSH2HOME"; //$NON-NLS-1$
- public static String KEY_KEYFILE="CVSSSH2PreferencePage.KEYFILE"; //$NON-NLS-1$
- public static String KEY_PRIVATEKEY="CVSSSH2PreferencePage.PRIVATEKEY"; //$NON-NLS-1$
-
- static String SOCKS5="SOCKS5"; //$NON-NLS-1$
- static String HTTP="HTTP"; //$NON-NLS-1$
- static String HTTP_DEFAULT_PORT="80"; //$NON-NLS-1$
- static String SOCKS5_DEFAULT_PORT="1080"; //$NON-NLS-1$
- static String PRIVATE_KEYS_DEFAULT="id_dsa,id_rsa"; //$NON-NLS-1$
-
- static String DSA="DSA"; //$NON-NLS-1$
- static String RSA="RSA"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java
deleted file mode 100644
index b9077da96..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/* -*-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.internal.ccvs.ssh2;
-
-import java.io.*;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-import com.jcraft.jsch.*;
-
-class JSchSession {
- private static final int SSH_DEFAULT_PORT = 22;
- private static JSch jsch=new JSch();
- private static java.util.Hashtable pool = new java.util.Hashtable();
-
- private static String current_ssh_home = null;
-
- public static class SimpleSocketFactory implements SocketFactory {
- InputStream in = null;
- OutputStream out = null;
- public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
- Socket socket = null;
- socket = new Socket(host, port);
- return socket;
- }
- public InputStream getInputStream(Socket socket) throws IOException {
- if (in == null)
- in = socket.getInputStream();
- return in;
- }
- public OutputStream getOutputStream(Socket socket) throws IOException {
- if (out == null)
- out = socket.getOutputStream();
- return out;
- }
- }
-
- public static class ResponsiveSocketFacory extends SimpleSocketFactory {
- private IProgressMonitor monitor;
- public ResponsiveSocketFacory(IProgressMonitor monitor) {
- this.monitor = monitor;
- }
- public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
- Socket socket = null;
- socket = Util.createSocket(host, port, monitor);
- // Null out the monitor so we don't hold onto anything
- // (i.e. the SSH2 session will keep a handle to the socket factory around
- monitor = new NullProgressMonitor();
- // Set the socket timeout
- socket.setSoTimeout(CVSProviderPlugin.getPlugin().getTimeout() * 1000);
- return socket;
- }
- }
-
- /**
- * User information delegates to the IUserAuthenticator. This allows
- * headless access to the connection method.
- */
- private static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
- private String username;
- private String password;
- private String passphrase;
- private ICVSRepositoryLocation location;
- private IUserAuthenticator authenticator;
- private int attemptCount;
- private boolean passwordChanged;
-
- MyUserInfo(String username, String password, ICVSRepositoryLocation location) {
- this.location = location;
- this.username = username;
- this.password = password;
- ICVSRepositoryLocation _location=location;
- if(_location==null){
- String dummy=":extssh:dummy@dummy:/"; //$NON-NLS-1$
- try{
- _location=CVSRepositoryLocation.fromString(dummy);
- }
- catch(CVSException e){
- }
- }
- authenticator = _location.getUserAuthenticator();
-
- }
- public String getPassword() {
- return password;
- }
- public String getPassphrase() {
- return passphrase;
- }
- public boolean promptYesNo(String str) {
- int prompt = authenticator.prompt(
- location,
- IUserAuthenticator.QUESTION,
- Policy.bind("JSchSession.5"), //$NON-NLS-1$
- str,
- new int[] {IUserAuthenticator.YES_ID, IUserAuthenticator.NO_ID},
- 0 //yes the default
- );
- return prompt == 0;
- }
- private String promptSecret(String message, boolean includeLocation) throws CVSException{
- final String[] _password = new String[1];
- IUserInfo info = new IUserInfo() {
- public String getUsername() {
- return username;
- }
- public boolean isUsernameMutable() {
- return false;
- }
- public void setPassword(String password) {
- _password[0] = password;
- }
- public void setUsername(String username) {
- }
- };
- try{
- authenticator.promptForUserInfo(includeLocation ? location : null, info, message);
- }
- catch(OperationCanceledException e){
- _password[0]=null;
- }
- return _password[0];
- }
- public boolean promptPassphrase(String message) {
- try{
- String _passphrase=promptSecret(message, false);
- if(_passphrase!=null){
- passphrase=_passphrase;
- }
- return _passphrase!=null;
- }
- catch(CVSException e){
- return false;
- }
- }
- public boolean promptPassword(String message) {
- try{
- String _password=promptSecret(message, true);
- if(_password!=null){
- password=_password;
- // Cache the password with the repository location on the memory.
- if(location!=null)
- ((CVSRepositoryLocation)location).setPassword(password);
- }
- return _password!=null;
- }
- catch(CVSException e){
- return false;
- }
- }
- public void showMessage(String message) {
- authenticator.prompt(
- location,
- IUserAuthenticator.INFORMATION,
- Policy.bind("JSchSession.5"), //$NON-NLS-1$
- message,
- new int[] {IUserAuthenticator.OK_ID},
- IUserAuthenticator.OK_ID
- );
- }
- 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=
- authenticator.promptForKeyboradInteractive(location,
- destination,
- name,
- instruction,
- prompt,
- echo);
- if (result.length == 1 && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
- password = result[0];
- passwordChanged = true;
- }
- attemptCount++;
- return result;
- }
- catch(OperationCanceledException e){
- return null;
- }
- catch(CVSException e){
- return null;
- }
- }
-
- /**
- * Callback to indicate that a connection is about to be attempted
- */
- public void aboutToConnect() {
- attemptCount = 0;
- passwordChanged = false;
- }
-
- /**
- * Callback to indicate that a connection was made
- */
- public void connectionMade() {
- attemptCount = 0;
- if (passwordChanged && password != null) {
- // We were prompted for and returned a password so record it with the location
- location.setPassword(password);
- }
- }
- }
-
- static Session getSession(ICVSRepositoryLocation location, String username, String password, String hostname, int port, SocketFactory socketFactory) throws JSchException {
- if (port == 0)
- port = SSH_DEFAULT_PORT;
-
- IPreferenceStore store = CVSSSH2Plugin.getDefault().getPreferenceStore();
- String ssh_home = store.getString(ISSHContants.KEY_SSH2HOME);
-
- if (current_ssh_home == null ||
- !current_ssh_home.equals(ssh_home)) {
- current_ssh_home = ssh_home;
- if (ssh_home.length() == 0)
- ssh_home = CVSSSH2Plugin.SSH_HOME_DEFAULT;
-
- try {
- loadKnownHosts();
-
- java.io.File file;
- String pkeys=store.getString(ISSHContants.KEY_PRIVATEKEY);
- String[] pkey=pkeys.split(","); //$NON-NLS-1$
- for(int i=0; i<pkey.length;i++){
- file = new java.io.File(ssh_home, pkey[i]);
- if (file.exists())
- jsch.addIdentity(file.getPath());
- }
- } catch (Exception e) {
- }
- }
-
- String key = username + "@" + hostname + ":" + port; //$NON-NLS-1$ //$NON-NLS-2$
-
- try {
- Session session = (Session) pool.get(key);
- if (session != null && !session.isConnected()) {
- pool.remove(key);
- session = null;
- }
-
- if (session == null) {
- session = jsch.getSession(username, hostname, port);
-
- boolean useProxy = store.getString(ISSHContants.KEY_PROXY).equals("true"); //$NON-NLS-1$
- if (useProxy) {
- String _type = store.getString(ISSHContants.KEY_PROXY_TYPE);
- String _host = store.getString(ISSHContants.KEY_PROXY_HOST);
- String _port = store.getString(ISSHContants.KEY_PROXY_PORT);
-
- boolean useAuth = store.getString(ISSHContants.KEY_PROXY_AUTH).equals("true"); //$NON-NLS-1$
- String _user = ""; //$NON-NLS-1$
- String _pass = ""; //$NON-NLS-1$
-
- // Retrieve username and password from keyring.
- Map map = Platform.getAuthorizationInfo(CVSSSH2PreferencePage.FAKE_URL, "proxy", CVSSSH2PreferencePage.AUTH_SCHEME); //$NON-NLS-1$
- if(map!=null){
- _user=(String) map.get(ISSHContants.KEY_PROXY_USER);
- _pass=(String) map.get(ISSHContants.KEY_PROXY_PASS);
- }
-
- Proxy proxy = null;
- String proxyhost = _host + ":" + _port; //$NON-NLS-1$
- if (_type.equals(ISSHContants.HTTP)) {
- proxy = new ProxyHTTP(proxyhost);
- if (useAuth) {
- ((ProxyHTTP) proxy).setUserPasswd(_user, _pass);
- }
- } else if (_type.equals(ISSHContants.SOCKS5)) {
- proxy = new ProxySOCKS5(proxyhost);
- if (useAuth) {
- ((ProxySOCKS5) proxy).setUserPasswd(_user, _pass);
- }
- } else {
- proxy = null;
- }
- if (proxy != null) {
- session.setProxy(proxy);
- }
- }
-
- session.setPassword(password);
-
- MyUserInfo ui = new MyUserInfo(username, password, location);
- session.setUserInfo(ui);
- session.setSocketFactory(socketFactory);
-
- ui.aboutToConnect();
- session.connect();
- ui.connectionMade();
- pool.put(key, session);
- }
- return session;
- } catch (JSchException e) {
- pool.remove(key);
- if(e.toString().indexOf("Auth cancel")!=-1){ //$NON-NLS-1$
- throw new OperationCanceledException(""); //$NON-NLS-1$
- }
- throw e;
- }
- }
-
- static void loadKnownHosts(){
- IPreferenceStore store = CVSSSH2Plugin.getDefault().getPreferenceStore();
- String ssh_home = store.getString(ISSHContants.KEY_SSH2HOME);
-
- if (ssh_home.length() == 0)
- ssh_home = CVSSSH2Plugin.SSH_HOME_DEFAULT;
-
- try {
- java.io.File file;
- file=new java.io.File(ssh_home, "known_hosts"); //$NON-NLS-1$
- jsch.setKnownHosts(file.getPath());
- } catch (Exception e) {
- }
- }
-
- static void shutdown() {
- if (jsch != null && pool.size() > 0) {
- for (Enumeration e = pool.elements(); e.hasMoreElements(); ) {
- Session session = (Session) (e.nextElement());
- try {
- session.disconnect();
- } catch (Exception ee) {
- }
- }
- pool.clear();
- }
- }
- static JSch getJSch(){
- return jsch;
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java
deleted file mode 100644
index 54d4baf6d..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2Method.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -*-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.internal.ccvs.ssh2;
-
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
-import org.eclipse.team.internal.ccvs.core.IServerConnection;
-
-public class PServerSSH2Method implements IConnectionMethod {
- public String getName() {
- return "pserverssh2"; //$NON-NLS-1$
- }
- public IServerConnection createConnection(ICVSRepositoryLocation root, String password) {
- return new PServerSSH2ServerConnection(root, password);
- }
- public void disconnect(ICVSRepositoryLocation location) {
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java
deleted file mode 100644
index 066bda254..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/PServerSSH2ServerConnection.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/* -*-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.internal.ccvs.ssh2;
-
-import java.io.*;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.*;
-import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
-
-import com.jcraft.jsch.*;
-
-public class PServerSSH2ServerConnection implements IServerConnection {
-
- private ICVSRepositoryLocation location;
- private String password;
- private Session session;
- private static int localport = 2403;
- private IServerConnection psc = null;
-
- protected PServerSSH2ServerConnection(ICVSRepositoryLocation location, String password) {
- this.location = location;
- this.password = password;
- }
-
- public void close() throws IOException {
- psc.close();
- }
-
- public InputStream getInputStream() {
- return psc.getInputStream();
- }
- public OutputStream getOutputStream() {
- return psc.getOutputStream();
- }
-
- public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException {
- monitor.subTask("PServerSSH2ServerConnection.open"); //$NON-NLS-1$
- monitor.worked(1);
- String cvs_root = location.getRootDirectory();
- int cvs_port = location.getPort();
- if (cvs_port == 0)
- cvs_port = 2401;
- String cvs_host = location.getHost();
- String ssh_host = cvs_host;
- String ssh_user = location.getUsername();
-
- String host = cvs_host;
- if (host.indexOf('@') != -1) {
- cvs_host = host.substring(host.lastIndexOf('@') + 1);
- host = host.substring(0, host.lastIndexOf('@'));
- if (host.indexOf('@') != -1) {
- ssh_host = host.substring(host.lastIndexOf('@') + 1);
- if (ssh_host.length() == 0)
- ssh_host = cvs_host;
- ssh_user = host.substring(0, host.lastIndexOf('@'));
- } else {
- ssh_host = host;
- }
- }
-
- int ssh_port = 0;
- if (ssh_host.indexOf('#') != -1) {
- try {
- ssh_port = Integer.parseInt(ssh_host.substring(ssh_host.lastIndexOf('#') + 1));
- ssh_host = ssh_host.substring(0, ssh_host.lastIndexOf('#'));
- } catch (Exception e) {
- }
- }
-
- int lport = cvs_port;
- String rhost = (cvs_host.equals(ssh_host) ? "localhost" : cvs_host); //$NON-NLS-1$
- int rport = cvs_port;
-
- // ssh -L lport:rhost:rport ssh_user@ssh_host
- int retry = 1;
- while (true) {
- try {
- session = JSchSession.getSession(location, ssh_user, "", ssh_host, ssh_port, new JSchSession.ResponsiveSocketFacory(monitor)); //$NON-NLS-1$
- String[] list = session.getPortForwardingL();
- String name = ":" + rhost + ":" + rport; //$NON-NLS-1$ //$NON-NLS-2$
- boolean done = false;
- for (int i = 0; i < list.length; i++) {
- if (list[i].endsWith(name)) {
- try {
- String foo = list[i].substring(0, list[i].indexOf(':'));
- lport = Integer.parseInt(foo);
- } catch (Exception ee) {
- }
- done = true;
- break;
- }
- }
- if (!done) {
- lport = localport++;
- session.setPortForwardingL(lport, rhost, rport);
- }
- } catch (JSchException ee) {
- retry--;
- if(retry<0){
- throw new CVSAuthenticationException(Policy.bind("CVSSSH2ServerConnection.3"), CVSAuthenticationException.NO_RETRY); //$NON-NLS-1$
- }
- if(session.isConnected()){
- session.disconnect();
- }
- continue;
- }
- break;
- }
- // password for location will be over-written in JSchSession ;-<
- ((CVSRepositoryLocation)location).setPassword(password);
-
- // CVSROOT=":pserver:localhost:"+lport+""cvs_root
- try {
- Properties prop = new Properties();
- prop.put("connection", "pserver"); //$NON-NLS-1$ //$NON-NLS-2$
- prop.put("user", location.getUsername()); //$NON-NLS-1$
- prop.put("password", password); //$NON-NLS-1$
- prop.put("host", "localhost"); //$NON-NLS-1$ //$NON-NLS-2$
- prop.put("port", Integer.toString(lport)); //$NON-NLS-1$
- prop.put("root", cvs_root); //$NON-NLS-1$
-
- CVSRepositoryLocation cvsrl = CVSRepositoryLocation.fromProperties(prop);
-
- IConnectionMethod method = cvsrl.getMethod();
- psc = method.createConnection(cvsrl, password);
- } catch (Exception e) {
- throw new CVSAuthenticationException(e.toString(), CVSAuthenticationException.NO_RETRY);
- }
- psc.open(monitor);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java
deleted file mode 100644
index 93fcbd228..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/Policy.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ssh2;
-
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-public class Policy {
- protected static ResourceBundle bundle = null;
-
- /**
- * Creates a NLS catalog for the given locale.
- */
- public static void localize(String bundleName) {
- bundle = ResourceBundle.getBundle(bundleName);
- }
-
- /**
- * Gets a string from the resource bundle. We don't want to crash because of a missing String.
- * Returns the key if not found.
- */
- public static String bind(String key) {
- try {
- return bundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
- public static String bind(String id, String binding) {
- return bind(id, new String[] { binding });
- }
-
- /**
- * Gets a string from the resource bundle and binds it with the given arguments. If the key is
- * not found, return the key.
- */
- public static String bind(String key, Object[] args) {
- try {
- return MessageFormat.format(bind(key), args);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public static void checkCanceled(IProgressMonitor monitor) {
- if (monitor != null && monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties
deleted file mode 100644
index 675bd9412..000000000
--- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/messages.properties
+++ /dev/null
@@ -1,105 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-JSchSession.5=SSH2 Client
-CVSSSH2ServerConnection.open=Connecting via SSH to {0}...
-CVSSSH2PreferencePage.18=Configuration options for SSH2:
-CVSSSH2PreferencePage.19=&General
-CVSSSH2PreferencePage.20=&Proxy
-CVSSSH2PreferencePage.21=&Key Management
-CVSSSH2PreferencePage.22=&Enable SSH protocol version 2 support (temporary until version 2 fully tested)
-CVSSSH2PreferencePage.23=SSH2 &Home:
-CVSSSH2PreferencePage.24=&Browse...
-CVSSSH2PreferencePage.25=P&rivate key:
-CVSSSH2PreferencePage.26=Add Pr&ivate Key...
-CVSSSH2PreferencePage.27=SSH Home:
-CVSSSH2PreferencePage.30=&Enable proxy connection
-CVSSSH2PreferencePage.31=Proxy &type:
-CVSSSH2PreferencePage.32=Proxy host add&ress:
-CVSSSH2PreferencePage.33=Proxy host p&ort:
-CVSSSH2PreferencePage.34=E&nable proxy authentication
-CVSSSH2PreferencePage.35=Proxy &user name:
-CVSSSH2PreferencePage.36=Proxy pa&ssword:
-CVSSSH2PreferencePage.37=Key &type:
-CVSSSH2PreferencePage.38=G&enerate
-CVSSSH2PreferencePage.39=&You can paste this public key into the remote authorized_keys file:
-CVSSSH2PreferencePage.41=&Fingerprint:
-CVSSSH2PreferencePage.42=&Comment:
-CVSSSH2PreferencePage.43=Passp&hrase:
-CVSSSH2PreferencePage.44=C&onfirm passphrase:
-CVSSSH2PreferencePage.45=&Save Private Key...
-CVSSSH2PreferencePage.47=The key was not generated.
-CVSSSH2PreferencePage.48=The passphrases entered do not match.
-CVSSSH2PreferencePage.49=Are you sure you want to save this private key without passphrase protection?
-CVSSSH2PreferencePage.50={0} does not exsit.\nAre you sure you want to create it?
-CVSSSH2PreferencePage.53={0} has already existed.\nAre you sure you want to over write it?
-CVSSSH2PreferencePage.55=Successfully saved.
-CVSSSH2PreferencePage.57=Private key:
-CVSSSH2PreferencePage.59=Public key:
-CVSSSH2PreferencePage.66=Proxy settings
-CVSSSH2PreferencePage.67=Enable proxy connection
-CVSSSH2PreferencePage.68=Proxy type
-CVSSSH2PreferencePage.69=Proxy host address
-CVSSSH2PreferencePage.70=Proxy host port
-CVSSSH2PreferencePage.71=Enable proxy authentication
-CVSSSH2PreferencePage.72=Proxy user name
-CVSSSH2PreferencePage.73=Proxy password
-CVSSSH2PreferencePage.74=Key Management
-CVSSSH2PreferencePage.75=Key type
-CVSSSH2PreferencePage.76=Generate
-CVSSSH2PreferencePage.77=&You can paste this public key into the remote authorized_keys file:
-CVSSSH2PreferencePage.79=&Fingerprint
-CVSSSH2PreferencePage.80=Comment
-CVSSSH2PreferencePage.81=Passphrase
-CVSSSH2PreferencePage.82=Confirm passphrase
-CVSSSH2PreferencePage.83=Save
-CVSSSH2PreferencePage.86=The passphrases entered do not match.
-CVSSSH2PreferencePage.87=Are you sure you want to save this private key without the passphrase protection?
-CVSSSH2PreferencePage.93=Successfully saved.
-CVSSSH2PreferencePage.95=Private key:
-CVSSSH2PreferencePage.97=Public key:
-CVSSSH2PreferencePage.99={0} does not exist.\nAre you sure you want to create it?
-CVSSSH2PreferencePage.100=Failed to create
-CVSSSH2PreferencePage.101={0} does not exist.\nAre you sure you want to create it?
-CVSSSH2PreferencePage.102=Failed to create
-CVSSSH2PreferencePage.103=Proxy host port is not a number.
-CVSSSH2PreferencePage.104=Proxy host port must be a number between 0 and 65535.
-CVSSSH2PreferencePage.105=E&xport via sftp...
-CVSSSH2PreferencePage.106=Export ssh key to remote server via sftp.
-CVSSSH2PreferencePage.107=Specify a target site(in user@host[:port] format) where your public key should be installed.\nYour key will be stored in user@host[:port]:~/.ssh/authorized_keys
-CVSSSH2PreferencePage.108={0} is not valid site.
-CVSSSH2PreferencePage.109=Your public key has been successfully installed to
-CVSSSH2PreferencePage.110=Remote sshd is not from OpenSSH.
-CVSSSH2PreferencePage.111=Failed to export ssh key to remote server.
-CVSSSH2ServerConnection.3=session is down
-CVSSSH2ServerConnection.0=An undetermined authentication failure has occurred
-CVSSSH2ServerConnection.1=No route to host {0} could be found
-CVSSSH2PreferencePage.info=Information
-CVSSSH2PreferencePage.warning=Warning
-CVSSSH2PreferencePage.information=Information
-CVSSSH2PreferencePage.error=Error
-CVSSSH2PreferencePage.confirmation=Confirmation
-CVSSSH2PreferencePage.question=Question
-CVSSSH2PreferencePage.125=Target site:
-CVSSSH2PreferencePage.126=Enter passphrase for {0}
-CVSSSH2PreferencePage.127=Passphrase:
-CVSSSH2PreferencePage.128=&Load existing key...
-CVSSSH2PreferencePage.129=failed to decrypt {0}
-CVSSSH2PreferencePage.130=failed to load given file.
-CVSSSH2PreferencePage.131=G&enerate DSA key...
-CVSSSH2PreferencePage.132=Ge&nerate RSA key...
-CVSSSH2PreferencePage.133=Kno&wnHosts
-CVSSSH2PreferencePage.134=Hostname
-CVSSSH2PreferencePage.135=Type
-CVSSSH2PreferencePage.136=Fingerprint
-CVSSSH2PreferencePage.137=Add...
-CVSSSH2PreferencePage.138=Remove
-CVSSSH2PreferencePage.139=Host Keys included in known_hosts.
-Util.timeout=A timeout occurred connecting to host {0}

Back to the top