use of com.google.api.client.http.apache.v2.ApacheHttpTransport in project hub-alert by blackducksoftware.
the class AzureHttpRequestCreatorFactory method defaultHttpTransport.
private static ApacheHttpTransport defaultHttpTransport(Proxy proxy) {
HttpHost httpHost = HttpHost.create(proxy.toString());
CloseableHttpClient httpClient = ApacheHttpTransport.newDefaultHttpClientBuilder().setProxy(httpHost).build();
return new ApacheHttpTransport(httpClient);
}
use of com.google.api.client.http.apache.v2.ApacheHttpTransport in project hub-alert by blackducksoftware.
the class AzureHttpRequestCreatorTest method init.
@BeforeAll
public static void init() {
ApacheHttpTransport httpTransport = new ApacheHttpTransport(ApacheHttpTransport.newDefaultHttpClient());
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
azureHttpRequestCreator = new AzureHttpRequestCreator(TEST_BASE_URL, GSON, requestFactory, API_VERSION_APPENDER);
}
use of com.google.api.client.http.apache.v2.ApacheHttpTransport in project hub-alert by blackducksoftware.
the class AzureBoardsProperties method createHttpTransport.
public HttpTransport createHttpTransport(ProxyInfo proxyInfo) {
// Authenticated proxies aren't supported with the OAuth client library by default.
// Need to use an Apache Http Client backed transport to support authenticated proxies.
// Setup the client as the int-rest project does. That is known to setup a client that supports authenticated proxies.
// https://github.com/googleapis/google-http-java-client/issues/190
HttpClientBuilder httpClientBuilder = ApacheHttpTransport.newDefaultHttpClientBuilder();
if (proxyInfo.shouldUseProxy()) {
String proxyHost = proxyInfo.getHost().orElse(null);
int proxyPort = proxyInfo.getPort();
InetSocketAddress proxyAddress = InetSocketAddress.createUnresolved(proxyHost, proxyPort);
ProxySelector proxySelector = ProxySelector.of(proxyAddress);
httpClientBuilder.setRoutePlanner(new SystemDefaultRoutePlanner(proxySelector));
httpClientBuilder.setProxy(new HttpHost(proxyHost, proxyPort));
if (proxyInfo.hasAuthenticatedProxySettings()) {
NTCredentials credentials = new NTCredentials(proxyInfo.getUsername().orElse(null), proxyInfo.getPassword().orElse(null), proxyInfo.getNtlmWorkstation().orElse(null), proxyInfo.getNtlmDomain().orElse(null));
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(proxyInfo.getHost().orElse(null), proxyInfo.getPort()), credentials);
httpClientBuilder.setProxyAuthenticationStrategy(ProxyAuthenticationStrategy.INSTANCE);
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
}
return new ApacheHttpTransport(httpClientBuilder.build());
}
Aggregations