mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-136797 respect PROXY_EXCEPTIONS in Tasks plugin and other places
This commit is contained in:
@@ -28,6 +28,7 @@ import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.util.Base64;
|
||||
@@ -419,33 +420,51 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHttpProxyEnabledForUrl(@Nullable String url) {
|
||||
if (!USE_HTTP_PROXY) return false;
|
||||
URI uri = url != null ? VfsUtil.toUri(url) : null;
|
||||
return uri == null || !mySelector.isProxyException(uri.getHost());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RequestConfig.Builder setProxy(@NotNull RequestConfig.Builder builder) {
|
||||
return setProxy(builder, USE_HTTP_PROXY);
|
||||
if (USE_HTTP_PROXY) {
|
||||
builder.setProxy(new HttpHost(PROXY_HOST, PROXY_PORT));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CredentialsProvider setProxyCredentials(@NotNull CredentialsProvider provider) {
|
||||
return setProxyCredentials(provider, USE_HTTP_PROXY);
|
||||
if (USE_HTTP_PROXY && PROXY_AUTHENTICATION) {
|
||||
String ntlmUserPassword = PROXY_LOGIN.replace('\\', '/') + ":" + getPlainProxyPassword();
|
||||
provider.setCredentials(new AuthScope(PROXY_HOST, PROXY_PORT, AuthScope.ANY_REALM, AuthSchemes.NTLM), new NTCredentials(ntlmUserPassword));
|
||||
provider.setCredentials(new AuthScope(PROXY_HOST, PROXY_PORT), new UsernamePasswordCredentials(PROXY_LOGIN, getPlainProxyPassword()));
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RequestConfig.Builder setProxy(@NotNull RequestConfig.Builder builder, boolean useProxy) {
|
||||
if (useProxy) {
|
||||
builder.setProxy(new HttpHost(PROXY_HOST, PROXY_PORT));
|
||||
}
|
||||
|
||||
if (useProxy) setProxy(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CredentialsProvider setProxyCredentials(@NotNull CredentialsProvider provider, boolean useProxy) {
|
||||
if (useProxy && PROXY_AUTHENTICATION) {
|
||||
String ntlmUserPassword = PROXY_LOGIN.replace('\\', '/') + ":" + getPlainProxyPassword();
|
||||
provider.setCredentials(new AuthScope(PROXY_HOST, PROXY_PORT, AuthScope.ANY_REALM, AuthSchemes.NTLM), new NTCredentials(ntlmUserPassword));
|
||||
provider.setCredentials(new AuthScope(PROXY_HOST, PROXY_PORT), new UsernamePasswordCredentials(PROXY_LOGIN, getPlainProxyPassword()));
|
||||
}
|
||||
if (useProxy) setProxyCredentials(provider);
|
||||
return provider;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RequestConfig.Builder setProxyIfEnabled(@NotNull RequestConfig.Builder builder, @Nullable String url) {
|
||||
if (isHttpProxyEnabledForUrl(url)) setProxy(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CredentialsProvider setProxyCredentialsIfEnabled(@NotNull CredentialsProvider provider, @Nullable String url) {
|
||||
if (isHttpProxyEnabledForUrl(url)) setProxyCredentials(provider);
|
||||
return provider;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ public class GithubConnection {
|
||||
.setSocketTimeout(timeout);
|
||||
|
||||
if (auth.isUseProxy()) {
|
||||
HttpConfigurable.getInstance().setProxy(builder);
|
||||
HttpConfigurable.getInstance().setProxyIfEnabled(builder, auth.getHost());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
@@ -184,7 +184,7 @@ public class GithubConnection {
|
||||
}
|
||||
|
||||
if (auth.isUseProxy()) {
|
||||
HttpConfigurable.getInstance().setProxyCredentials(provider);
|
||||
HttpConfigurable.getInstance().setProxyCredentialsIfEnabled(provider, auth.getHost());
|
||||
}
|
||||
|
||||
return provider;
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ public abstract class NewBaseRepositoryImpl extends BaseRepository {
|
||||
provider.setCredentials(BASIC_AUTH_SCOPE, new UsernamePasswordCredentials(getUsername(), getPassword()));
|
||||
}
|
||||
// Proxy authentication
|
||||
HttpConfigurable.getInstance().setProxyCredentials(provider, isUseProxy());
|
||||
if (isUseProxy()) HttpConfigurable.getInstance().setProxyCredentialsIfEnabled(provider, getUrl());
|
||||
|
||||
return provider;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public abstract class NewBaseRepositoryImpl extends BaseRepository {
|
||||
RequestConfig.Builder builder = RequestConfig.custom()
|
||||
.setConnectTimeout(3000)
|
||||
.setSocketTimeout(tasksSettings.CONNECTION_TIMEOUT);
|
||||
HttpConfigurable.getInstance().setProxy(builder, isUseProxy());
|
||||
if (isUseProxy()) HttpConfigurable.getInstance().setProxyIfEnabled(builder, getUrl());
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user