@Override public StatsResponse call() throws Exception { final RequestConfig.Builder builder = RequestConfig .custom() .setConnectTimeout(TIMEOUT) .setConnectionRequestTimeout(TIMEOUT) .setSocketTimeout(TIMEOUT); IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, HybrisConstants.STATS_COLLECTOR_URL); final RequestConfig config = builder.build(); final HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); final List<NameValuePair> patchedUrlParameters = ContainerUtil.newArrayList(urlParameters); patchUrlParameters(patchedUrlParameters); final HttpPost post = new HttpPost(HybrisConstants.STATS_COLLECTOR_URL); post.setEntity(new UrlEncodedFormEntity(patchedUrlParameters, UTF_8)); return new StatsResponse(client.execute(post)); }
@NotNull private HttpClient getClient(@NotNull SVNURL repositoryUrl) { // TODO: Implement algorithm of resolving necessary enabled protocols (TLSv1 vs SSLv3) instead of just using values from Settings. SSLContext sslContext = createSslContext(repositoryUrl); List<String> supportedProtocols = getSupportedSslProtocols(); SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, ArrayUtil.toStringArray(supportedProtocols), null, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); // TODO: Seems more suitable here to read timeout values directly from config file - without utilizing SvnAuthenticationManager. final RequestConfig.Builder requestConfigBuilder = RequestConfig.custom(); final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); if (haveDataForTmpConfig()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyIfEnabled(requestConfigBuilder); IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsIfEnabled(credentialsProvider); } return HttpClients.custom() .setSSLSocketFactory(socketFactory) .setDefaultSocketConfig(SocketConfig.custom() .setSoTimeout(getAuthenticationManager().getReadTimeout(repositoryUrl)) .build()) .setDefaultRequestConfig(requestConfigBuilder .setConnectTimeout(getAuthenticationManager().getConnectTimeout(repositoryUrl)) .build()) .setDefaultCredentialsProvider(credentialsProvider) .build(); }
@NotNull private CredentialsProvider createCredentialsProvider() { CredentialsProvider provider = new BasicCredentialsProvider(); // Basic authentication if(isUseHttpAuthentication()) { provider.setCredentials(BASIC_AUTH_SCOPE, new UsernamePasswordCredentials(getUsername(), getPassword())); } // Proxy authentication if(isUseProxy()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsForUrlIfEnabled(provider, getUrl()); } return provider; }
@NotNull private CredentialsProvider createCredentialsProvider() { CredentialsProvider provider = new BasicCredentialsProvider(); // Basic authentication if (isUseHttpAuthentication()) { provider.setCredentials(BASIC_AUTH_SCOPE, new UsernamePasswordCredentials(getUsername(), getPassword())); } // Proxy authentication if (isUseProxy()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsForUrlIfEnabled(provider, getUrl()); } return provider; }
@NotNull protected RequestConfig createRequestConfig() { TaskSettings tasksSettings = TaskSettings.getInstance(); RequestConfig.Builder builder = RequestConfig.custom() .setConnectTimeout(3000) .setSocketTimeout(tasksSettings.CONNECTION_TIMEOUT); if (isUseProxy()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, getUrl()); } return builder.build(); }
@NotNull private static RequestConfig createRequestConfig(@NotNull GithubAuthData auth) { RequestConfig.Builder builder = RequestConfig.custom(); int timeout = GithubSettings.getInstance().getConnectionTimeout(); builder .setConnectTimeout(timeout) .setSocketTimeout(timeout); if (auth.isUseProxy()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, auth.getHost()); } return builder.build(); }
@NotNull private static CredentialsProvider createCredentialsProvider(@NotNull GithubAuthData auth) { CredentialsProvider provider = new BasicCredentialsProvider(); // Basic authentication GithubAuthData.BasicAuth basicAuth = auth.getBasicAuth(); if (basicAuth != null) { provider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(basicAuth.getLogin(), basicAuth.getPassword())); } if (auth.isUseProxy()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsForUrlIfEnabled(provider, auth.getHost()); } return provider; }
@NotNull protected RequestConfig createRequestConfig() { TaskSettings tasksSettings = TaskSettings.getInstance(); RequestConfig.Builder builder = RequestConfig.custom().setConnectTimeout(3000).setSocketTimeout(tasksSettings.CONNECTION_TIMEOUT); if(isUseProxy()) { IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, getUrl()); } return builder.build(); }