IDEA-125609 - Built-in Git SSH executable ignores IDEA http proxy settings

This commit is contained in:
Michael Golubev
2014-06-02 16:03:22 +02:00
parent f894389f49
commit 9ea2438ded
3 changed files with 41 additions and 1 deletions
@@ -48,7 +48,15 @@ public interface GitSSHHandler {
* Name of the handler
*/
@NonNls String HANDLER_NAME = "Git4ideaSSHHandler";
/**
* Proxy settings
*/
@NonNls String SSH_USE_PROXY_ENV = "GIT4IDEA_SSH_USE_PROXY";
@NonNls String SSH_PROXY_HOST_ENV = "GIT4IDEA_SSH_PROXY_HOST";
@NonNls String SSH_PROXY_PORT_ENV = "GIT4IDEA_SSH_PROXY_PORT";
@NonNls String SSH_PROXY_AUTHENTICATION_ENV = "GIT4IDEA_SSH_PROXY_AUTHENTICATION";
@NonNls String SSH_PROXY_USER_ENV = "GIT4IDEA_SSH_PROXY_USER";
@NonNls String SSH_PROXY_PASSWORD_ENV = "GIT4IDEA_SSH_PROXY_PASSWORD";
/**
* Verify server host key
*
@@ -153,6 +153,21 @@ public class SSHMain implements GitExternalApp {
Connection c = new Connection(myHost.getHostName(), myHost.getPort());
try {
configureKnownHosts(c);
boolean useHttpProxy = Boolean.valueOf(System.getenv(GitSSHHandler.SSH_USE_PROXY_ENV));
if (useHttpProxy) {
String proxyHost = System.getenv(GitSSHHandler.SSH_PROXY_HOST_ENV);
Integer proxyPort = Integer.valueOf(System.getenv(GitSSHHandler.SSH_PROXY_PORT_ENV));
boolean proxyAuthentication = Boolean.valueOf(System.getenv(GitSSHHandler.SSH_PROXY_AUTHENTICATION_ENV));
String proxyUser = null;
String proxyPassword = null;
if (proxyAuthentication) {
proxyUser = System.getenv(GitSSHHandler.SSH_PROXY_USER_ENV);
proxyPassword = System.getenv(GitSSHHandler.SSH_PROXY_PASSWORD_ENV);
}
c.setProxyData(new HTTPProxyData(proxyHost, proxyPort, proxyUser, proxyPassword));
}
c.connect(new HostKeyVerifier());
authenticate(c);
final Session s = c.openSession();
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.EventDispatcher;
import com.intellij.util.Processor;
import com.intellij.util.net.HttpConfigurable;
import com.intellij.vcsUtil.VcsFileUtil;
import git4idea.GitVcs;
import git4idea.config.GitVcsApplicationSettings;
@@ -436,6 +437,22 @@ public abstract class GitHandler {
int port = ssh.getXmlRcpPort();
myEnv.put(GitSSHHandler.SSH_PORT_ENV, Integer.toString(port));
LOG.debug(String.format("handler=%s, port=%s", myHandlerNo, port));
final HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
boolean useHttpProxy = httpConfigurable.USE_HTTP_PROXY;
myEnv.put(GitSSHHandler.SSH_USE_PROXY_ENV, String.valueOf(useHttpProxy));
if (useHttpProxy) {
myEnv.put(GitSSHHandler.SSH_PROXY_HOST_ENV, httpConfigurable.PROXY_HOST);
myEnv.put(GitSSHHandler.SSH_PROXY_PORT_ENV, String.valueOf(httpConfigurable.PROXY_PORT));
boolean proxyAuthentication = httpConfigurable.PROXY_AUTHENTICATION;
myEnv.put(GitSSHHandler.SSH_PROXY_AUTHENTICATION_ENV, String.valueOf(proxyAuthentication));
if (proxyAuthentication) {
myEnv.put(GitSSHHandler.SSH_PROXY_USER_ENV, httpConfigurable.PROXY_LOGIN);
myEnv.put(GitSSHHandler.SSH_PROXY_PASSWORD_ENV, httpConfigurable.getPlainProxyPassword());
}
}
}
else if (remoteProtocol == GitRemoteProtocol.HTTP) {
GitHttpAuthService service = ServiceManager.getService(GitHttpAuthService.class);