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();
}
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());
}
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()));
}
}
}
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();
}
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);
}
}
Aggregations