Search in sources :

Example 6 with HttpConfigurable

use of com.intellij.util.net.HttpConfigurable in project android by JetBrains.

the class GradlePreSyncTest method testAddProxyConfigureToPropertyFile.

// Verifies that the IDE, during sync, asks the user to copy IDE proxy settings to gradle.properties, if applicable.
// See https://code.google.com/p/android/issues/detail?id=65325
// Similar to {@link com.android.tools.idea.gradle.util.GradlePropertiesTest#testSetProxySettings} test, but also tests the UI
// element that is involved.
@Test
public void testAddProxyConfigureToPropertyFile() throws IOException {
    guiTest.importSimpleApplication();
    String host = "myproxy.test.com";
    int port = 443;
    HttpConfigurable ideSettings = HttpConfigurable.getInstance();
    ideSettings.USE_HTTP_PROXY = true;
    ideSettings.PROXY_HOST = host;
    ideSettings.PROXY_PORT = port;
    ideSettings.PROXY_AUTHENTICATION = true;
    ideSettings.setProxyLogin("test");
    ideSettings.setPlainProxyPassword("testPass");
    ProxySettings ideProxySettings = new ProxySettings(ideSettings);
    GradleProperties properties = new GradleProperties(guiTest.ideFrame().getProject());
    assertNotEquals(ideProxySettings, properties.getHttpProxySettings());
    guiTest.ideFrame().requestProjectSync();
    ProxySettingsDialogFixture proxySettingsDialog = ProxySettingsDialogFixture.find(guiTest.robot());
    proxySettingsDialog.enableHttpsProxy();
    proxySettingsDialog.clickOk();
    properties = new GradleProperties(guiTest.ideFrame().getProject());
    assertEquals(ideProxySettings, properties.getHttpProxySettings());
    ideProxySettings.setProxyType(ProxySettings.HTTPS_PROXY_TYPE);
    assertEquals(ideProxySettings, properties.getHttpsProxySettings());
    guiTest.ideFrame().waitForGradleProjectSyncToFinish();
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable) ProxySettingsDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture) GradleProperties(com.android.tools.idea.gradle.util.GradleProperties) ProxySettings(com.android.tools.idea.gradle.util.ProxySettings) Test(org.junit.Test)

Example 7 with HttpConfigurable

use of com.intellij.util.net.HttpConfigurable in project android by JetBrains.

the class GradlePropertiesTest method testCopyProxySettingsFromIde.

public void testCopyProxySettingsFromIde() {
    String host = "myproxy.test.com";
    int port = 443;
    HttpConfigurable ideSettings = HttpConfigurable.getInstance();
    ideSettings.USE_HTTP_PROXY = true;
    ideSettings.PROXY_HOST = host;
    ideSettings.PROXY_PORT = port;
    ProxySettings proxySettings = new ProxySettings(ideSettings);
    assertEquals(host, proxySettings.getHost());
    assertEquals(port, proxySettings.getPort());
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable)

Example 8 with HttpConfigurable

use of com.intellij.util.net.HttpConfigurable in project intellij-community by JetBrains.

the class GitHandler method setupSshAuthenticator.

private void setupSshAuthenticator() throws IOException {
    GitXmlRpcSshService ssh = ServiceManager.getService(GitXmlRpcSshService.class);
    myEnv.put(GitSSHHandler.GIT_SSH_ENV, ssh.getScriptPath().getPath());
    mySshHandler = ssh.registerHandler(new GitSSHGUIHandler(myProject), myProject);
    myEnvironmentCleanedUp = false;
    myEnv.put(GitSSHHandler.SSH_HANDLER_ENV, mySshHandler.toString());
    int port = ssh.getXmlRcpPort();
    myEnv.put(GitSSHHandler.SSH_PORT_ENV, Integer.toString(port));
    LOG.debug(String.format("handler=%s, port=%s", mySshHandler, port));
    final HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
    boolean useHttpProxy = httpConfigurable.USE_HTTP_PROXY && !isSshUrlExcluded(httpConfigurable, ObjectUtils.assertNotNull(myUrls));
    myEnv.put(GitSSHHandler.SSH_USE_PROXY_ENV, String.valueOf(useHttpProxy));
    if (useHttpProxy) {
        myEnv.put(GitSSHHandler.SSH_PROXY_HOST_ENV, StringUtil.notNullize(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, StringUtil.notNullize(httpConfigurable.getProxyLogin()));
            myEnv.put(GitSSHHandler.SSH_PROXY_PASSWORD_ENV, StringUtil.notNullize(httpConfigurable.getPlainProxyPassword()));
        }
    }
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable) GitXmlRpcSshService(org.jetbrains.git4idea.ssh.GitXmlRpcSshService)

Example 9 with HttpConfigurable

use of com.intellij.util.net.HttpConfigurable in project intellij-community by JetBrains.

the class BaseGradleProjectResolverExtension method getExtraJvmArgs.

@NotNull
@Override
public List<Pair<String, String>> getExtraJvmArgs() {
    if (ExternalSystemApiUtil.isInProcessMode(GradleConstants.SYSTEM_ID)) {
        final List<Pair<String, String>> extraJvmArgs = ContainerUtil.newArrayList();
        final HttpConfigurable httpConfigurable = HttpConfigurable.getInstance();
        if (!StringUtil.isEmpty(httpConfigurable.PROXY_EXCEPTIONS)) {
            List<String> hosts = StringUtil.split(httpConfigurable.PROXY_EXCEPTIONS, ",");
            if (!hosts.isEmpty()) {
                final String nonProxyHosts = StringUtil.join(hosts, StringUtil.TRIMMER, "|");
                extraJvmArgs.add(pair("http.nonProxyHosts", nonProxyHosts));
                extraJvmArgs.add(pair("https.nonProxyHosts", nonProxyHosts));
            }
        }
        if (httpConfigurable.USE_HTTP_PROXY && StringUtil.isNotEmpty(httpConfigurable.getProxyLogin())) {
            extraJvmArgs.add(pair("http.proxyUser", httpConfigurable.getProxyLogin()));
            extraJvmArgs.add(pair("https.proxyUser", httpConfigurable.getProxyLogin()));
            final String plainProxyPassword = httpConfigurable.getPlainProxyPassword();
            extraJvmArgs.add(pair("http.proxyPassword", plainProxyPassword));
            extraJvmArgs.add(pair("https.proxyPassword", plainProxyPassword));
        }
        extraJvmArgs.addAll(httpConfigurable.getJvmProperties(false, null));
        return extraJvmArgs;
    }
    return Collections.emptyList();
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with HttpConfigurable

use of com.intellij.util.net.HttpConfigurable in project intellij-community by JetBrains.

the class BaseRepositoryImpl method configureHttpClient.

protected void configureHttpClient(HttpClient client) {
    client.getParams().setConnectionManagerTimeout(3000);
    client.getParams().setSoTimeout(TaskSettings.getInstance().CONNECTION_TIMEOUT);
    if (isUseProxy()) {
        HttpConfigurable proxy = HttpConfigurable.getInstance();
        client.getHostConfiguration().setProxy(proxy.PROXY_HOST, proxy.PROXY_PORT);
        if (proxy.PROXY_AUTHENTICATION && proxy.getProxyLogin() != null) {
            AuthScope authScope = new AuthScope(proxy.PROXY_HOST, proxy.PROXY_PORT);
            Credentials credentials = getCredentials(proxy.getProxyLogin(), proxy.getPlainProxyPassword(), proxy.PROXY_HOST);
            client.getState().setProxyCredentials(authScope, credentials);
        }
    }
    if (isUseHttpAuthentication()) {
        client.getParams().setCredentialCharset("UTF-8");
        client.getParams().setAuthenticationPreemptive(true);
        client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(getUsername(), getPassword()));
    } else {
        client.getState().clearCredentials();
        client.getParams().setAuthenticationPreemptive(false);
    }
}
Also used : HttpConfigurable(com.intellij.util.net.HttpConfigurable) AuthScope(org.apache.commons.httpclient.auth.AuthScope)

Aggregations

HttpConfigurable (com.intellij.util.net.HttpConfigurable)15 GradleProperties (com.android.tools.idea.gradle.util.GradleProperties)3 NotNull (org.jetbrains.annotations.NotNull)3 Test (org.junit.Test)3 ProxySettings (com.android.tools.idea.gradle.util.ProxySettings)2 ProxySettingsDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ProxySettingsDialogFixture)2 File (java.io.File)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 AndroidGradleNotification (com.android.tools.idea.gradle.project.AndroidGradleNotification)1 ProxySettingsDialog (com.android.tools.idea.gradle.project.ProxySettingsDialog)1 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)1 LocalProperties (com.android.tools.idea.gradle.util.LocalProperties)1 PropertiesFiles.getProperties (com.android.tools.idea.gradle.util.PropertiesFiles.getProperties)1 Pair (com.intellij.openapi.util.Pair)1 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ConfirmingTrustManager (com.intellij.util.net.ssl.ConfirmingTrustManager)1 CommonProxy (com.intellij.util.proxy.CommonProxy)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1