Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-07-27 14:38:53 -0400
committerJean Michel-Lemieux2004-07-27 14:38:53 -0400
commitde13e6360125de8dd71a53cdc80453356cbbb935 (patch)
tree9c0ea9364ffc201a5f5d41dcc71b78ddceac30f0
parentb3ae2907246eaf0767326200348885cb1b9d3349 (diff)
downloadeclipse.platform.team-de13e6360125de8dd71a53cdc80453356cbbb935.tar.gz
eclipse.platform.team-de13e6360125de8dd71a53cdc80453356cbbb935.tar.xz
eclipse.platform.team-de13e6360125de8dd71a53cdc80453356cbbb935.zip
Bug 68852 [SSH2] Bug in Socks5 authentication
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/CVSSSH2PreferencePage.java126
-rw-r--r--bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/internal/ccvs/ssh2/JSchSession.java12
2 files changed, 56 insertions, 82 deletions
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
index 0dcd320dc..073627a95 100644
--- 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
@@ -26,6 +26,7 @@ import org.eclipse.swt.events.*;
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.*;
@@ -111,7 +112,7 @@ public class CVSSSH2PreferencePage extends PreferencePage
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();
@@ -936,8 +937,6 @@ public class CVSSSH2PreferencePage extends PreferencePage
setDefault(store, KEY_PROXY_TYPE, HTTP);
setDefault(store, KEY_PROXY_PORT, HTTP_DEFAULT_PORT);
setDefault(store, KEY_PROXY_AUTH, "false"); //$NON-NLS-1$
- setDefault(store, KEY_PROXY_USER, ""); //$NON-NLS-1$
- setDefault(store, KEY_PROXY_PASS, ""); //$NON-NLS-1$
}
private static void setDefault(IPreferenceStore store, String key, String value){
@@ -970,49 +969,49 @@ public class CVSSSH2PreferencePage extends PreferencePage
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;
- }
+ 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(KEY_SSH2HOME, home);
+ store.setValue(KEY_PRIVATEKEY, privateKeyText.getText());
+ store.setValue(KEY_PROXY, enableProxy.getSelection());
+ store.setValue(KEY_PROXY_TYPE, proxyTypeCombo.getText());
+ store.setValue(KEY_PROXY_HOST, proxyHostText.getText());
+ store.setValue(KEY_PROXY_PORT, proxyPortText.getText());
+ store.setValue(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(KEY_PROXY_USER, proxyUserText.getText());
+ map.put(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;
}
- }
-
- if(enableProxy.getSelection() && !isValidPort(proxyPortText.getText())){
- return false;
- }
-
- IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore();
- store.setValue(KEY_SSH2HOME, home);
- store.setValue(KEY_PRIVATEKEY, privateKeyText.getText());
- store.setValue(KEY_PROXY, enableProxy.getSelection());
- store.setValue(KEY_PROXY_TYPE, proxyTypeCombo.getText());
- store.setValue(KEY_PROXY_HOST, proxyHostText.getText());
- store.setValue(KEY_PROXY_PORT, proxyPortText.getText());
-
- store.setValue(KEY_PROXY_AUTH, enableAuth.getSelection());
- store.setValue(KEY_PROXY_USER, ""); //$NON-NLS-1$
- store.setValue(KEY_PROXY_PASS, ""); //$NON-NLS-1$
-
- Map map = Platform.getAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME); //$NON-NLS-1$
- if(map==null) map=new java.util.HashMap(10);
- map.put(KEY_PROXY_USER, proxyUserText.getText());
- map.put(KEY_PROXY_PASS, proxyPassText.getText());
- try{ Platform.addAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME, map);} //$NON-NLS-1$
- catch(CoreException e){}
- }
- CVSSSH2Plugin.getDefault().savePluginPreferences();
- return result;
- }
private boolean isValidPort(String port){
int i=-1;
@@ -1029,42 +1028,9 @@ public class CVSSSH2PreferencePage extends PreferencePage
}
return true;
}
+
public void performApply() {
- 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.101", home) //$NON-NLS-1$
- )){
- if(!(_home.mkdirs())){
- setErrorMessage(Policy.bind("CVSSSH2PreferencePage.102")+home); //$NON-NLS-1$
- return;
- }
- }
- }
-
- if(enableProxy.getSelection() && !isValidPort(proxyPortText.getText())){
- return;
- }
-
- IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore();
- store.setValue(KEY_SSH2HOME, ssh2HomeText.getText());
- store.setValue(KEY_PRIVATEKEY, privateKeyText.getText());
- store.setValue(KEY_PROXY, enableProxy.getSelection());
- store.setValue(KEY_PROXY_TYPE, proxyTypeCombo.getText());
- store.setValue(KEY_PROXY_HOST, proxyHostText.getText());
- store.setValue(KEY_PROXY_PORT, proxyPortText.getText());
-
- store.setValue(KEY_PROXY_AUTH, enableAuth.getSelection());
-
- Map map = Platform.getAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME); //$NON-NLS-1$
- if(map==null) map=new java.util.HashMap(10);
- map.put(KEY_PROXY_USER, proxyUserText.getText());
- map.put(KEY_PROXY_PASS, proxyPassText.getText());
- try{Platform.addAuthorizationInfo(FAKE_URL, "proxy", AUTH_SCHEME, map);} //$NON-NLS-1$
- catch (CoreException e) {}
+ performOk();
}
protected void performDefaults(){
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
index 7d232da72..c0376aa95 100644
--- 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
@@ -16,6 +16,7 @@ import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Enumeration;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -274,8 +275,15 @@ class JSchSession {
String _port = store.getString(CVSSSH2PreferencePage.KEY_PROXY_PORT);
boolean useAuth = store.getString(CVSSSH2PreferencePage.KEY_PROXY_AUTH).equals("true"); //$NON-NLS-1$
- String _user = store.getString(CVSSSH2PreferencePage.KEY_PROXY_USER);
- String _pass = store.getString(CVSSSH2PreferencePage.KEY_PROXY_PASS);
+ 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(CVSSSH2PreferencePage.KEY_PROXY_USER);
+ _pass=(String) map.get(CVSSSH2PreferencePage.KEY_PROXY_PASS);
+ }
Proxy proxy = null;
String proxyhost = _host + ":" + _port; //$NON-NLS-1$

Back to the top