diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java index ba7a8cdbea8d..2f634d08b939 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java @@ -135,7 +135,7 @@ public class GithubApiUtil { @Nullable final String requestBody, @NotNull final Collection
headers, @NotNull final HttpVerb verb) throws IOException { - HttpClient client = getHttpClient(auth.getBasicAuth()); + HttpClient client = getHttpClient(auth.getBasicAuth(), auth.isUseProxy()); return GithubSslSupport.getInstance() .executeSelfSignedCertificateAwareRequest(client, uri, new ThrowableConvertor() { @Override @@ -173,7 +173,7 @@ public class GithubApiUtil { } @NotNull - private static HttpClient getHttpClient(@Nullable GithubAuthData.BasicAuth basicAuth) { + private static HttpClient getHttpClient(@Nullable GithubAuthData.BasicAuth basicAuth, boolean useProxy) { final HttpClient client = new HttpClient(); HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams(); params.setConnectionTimeout(CONNECTION_TIMEOUT); //set connection timeout (how long it takes to connect to remote host) @@ -182,7 +182,7 @@ public class GithubApiUtil { client.getParams().setContentCharset("UTF-8"); // Configure proxySettings if it is required final HttpConfigurable proxySettings = HttpConfigurable.getInstance(); - if (proxySettings.USE_HTTP_PROXY && !StringUtil.isEmptyOrSpaces(proxySettings.PROXY_HOST)) { + if (useProxy && proxySettings.USE_HTTP_PROXY && !StringUtil.isEmptyOrSpaces(proxySettings.PROXY_HOST)) { client.getHostConfiguration().setProxy(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT); if (proxySettings.PROXY_AUTHENTICATION) { client.getState().setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(proxySettings.PROXY_LOGIN, diff --git a/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepository.java b/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepository.java index 4f4626680673..3d337c289c56 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepository.java +++ b/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepository.java @@ -269,7 +269,7 @@ public class GithubRepository extends BaseRepositoryImpl { } private GithubAuthData getAuthData() { - return GithubAuthData.createTokenAuth(getUrl(), getToken()); + return GithubAuthData.createTokenAuth(getUrl(), getToken(), isUseProxy()); } @Override diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java index 5de9a65b6de9..63e93a6e230e 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java @@ -36,15 +36,19 @@ public class GithubAuthData { @NotNull private final String myHost; @Nullable private final BasicAuth myBasicAuth; @Nullable private final TokenAuth myTokenAuth; + private final boolean myUseProxy; + private GithubAuthData(@NotNull AuthType authType, @NotNull String host, @Nullable BasicAuth basicAuth, - @Nullable TokenAuth tokenAuth) { + @Nullable TokenAuth tokenAuth, + boolean useProxy) { myAuthType = authType; myHost = host; myBasicAuth = basicAuth; myTokenAuth = tokenAuth; + myUseProxy = useProxy; } public static GithubAuthData createAnonymous() { @@ -52,15 +56,19 @@ public class GithubAuthData { } public static GithubAuthData createAnonymous(@NotNull String host) { - return new GithubAuthData(AuthType.ANONYMOUS, host, null, null); + return new GithubAuthData(AuthType.ANONYMOUS, host, null, null, true); } public static GithubAuthData createBasicAuth(@NotNull String host, @NotNull String login, @NotNull String password) { - return new GithubAuthData(AuthType.BASIC, host, new BasicAuth(login, password), null); + return new GithubAuthData(AuthType.BASIC, host, new BasicAuth(login, password), null, true); } public static GithubAuthData createTokenAuth(@NotNull String host, @NotNull String token) { - return new GithubAuthData(AuthType.TOKEN, host, null, new TokenAuth(token)); + return new GithubAuthData(AuthType.TOKEN, host, null, new TokenAuth(token), true); + } + + public static GithubAuthData createTokenAuth(@NotNull String host, @NotNull String token, boolean useProxy) { + return new GithubAuthData(AuthType.TOKEN, host, null, new TokenAuth(token), useProxy); } @NotNull @@ -83,6 +91,10 @@ public class GithubAuthData { return myTokenAuth; } + public boolean isUseProxy() { + return myUseProxy; + } + public static class BasicAuth { @NotNull private final String myLogin; @NotNull private final String myPassword;