com.google.api.client.http.apache.v2.ApacheHttpTransport Java Examples
The following examples show how to use
com.google.api.client.http.apache.v2.ApacheHttpTransport.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpEventPublisher.java From DataflowTemplates with Apache License 2.0 | 6 votes |
/** * Utility method to create a {@link CloseableHttpClient} to make http POSTs against Splunk's * HEC. * * @param maxConnections max number of parallel connections. * @param disableCertificateValidation should disable certificate validation. */ private CloseableHttpClient getHttpClient( int maxConnections, boolean disableCertificateValidation) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { HttpClientBuilder builder = ApacheHttpTransport.newDefaultHttpClientBuilder(); if (genericUrl().getScheme().equalsIgnoreCase(HTTPS_PROTOCOL_PREFIX)) { LOG.info("SSL connection requested"); HostnameVerifier hostnameVerifier = disableCertificateValidation ? NoopHostnameVerifier.INSTANCE : new DefaultHostnameVerifier(); SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); if (disableCertificateValidation) { LOG.info("Certificate validation is disabled"); sslContextBuilder.loadTrustMaterial((TrustStrategy) (chain, authType) -> true); } SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContextBuilder.build(), hostnameVerifier); builder.setSSLSocketFactory(connectionSocketFactory); } builder.setMaxConnTotal(maxConnections); builder.setDefaultRequestConfig( RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()); return builder.build(); }
Example #2
Source File: DriveSession.java From cyberduck with GNU General Public License v3.0 | 6 votes |
@Override protected Drive connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(new RateLimitingHttpRequestInterceptor(new DefaultHttpRateLimiter( PreferencesFactory.get().getInteger("googledrive.limit.requests.second") ))); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Drive.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); }
Example #3
Source File: HttpEventPublisher.java From DataflowTemplates with Apache License 2.0 | 5 votes |
/** * Validates and builds a {@link HttpEventPublisher} object. * * @return {@link HttpEventPublisher} */ public HttpEventPublisher build() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { checkNotNull(token(), "Authentication token needs to be specified via withToken(token)."); checkNotNull(genericUrl(), "URL needs to be specified via withUrl(url)."); if (disableCertificateValidation() == null) { LOG.info("Certificate validation disabled: {}", DEFAULT_DISABLE_CERTIFICATE_VALIDATION); setDisableCertificateValidation(DEFAULT_DISABLE_CERTIFICATE_VALIDATION); } if (maxElapsedMillis() == null) { LOG.info( "Defaulting max backoff time to: {} milliseconds ", ExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS); setMaxElapsedMillis(ExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS); } CloseableHttpClient httpClient = getHttpClient(DEFAULT_MAX_CONNECTIONS, disableCertificateValidation()); setTransport(new ApacheHttpTransport(httpClient)); setRequestFactory(transport().createRequestFactory()); return autoBuild(); }
Example #4
Source File: GoogleStorageSession.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Override public Storage connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Storage.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); }
Example #5
Source File: HttpEventPublisher.java From beam with Apache License 2.0 | 5 votes |
/** * Validates and builds a {@link HttpEventPublisher} object. * * @return {@link HttpEventPublisher} */ HttpEventPublisher build() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { checkNotNull(token(), "Authentication token needs to be specified via withToken(token)."); checkNotNull(genericUrl(), "URL needs to be specified via withUrl(url)."); if (disableCertificateValidation() == null) { LOG.info("Certificate validation disabled: {}", DEFAULT_DISABLE_CERTIFICATE_VALIDATION); setDisableCertificateValidation(DEFAULT_DISABLE_CERTIFICATE_VALIDATION); } if (maxElapsedMillis() == null) { LOG.info( "Defaulting max backoff time to: {} milliseconds ", ExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS); setMaxElapsedMillis(ExponentialBackOff.DEFAULT_MAX_ELAPSED_TIME_MILLIS); } CloseableHttpClient httpClient = getHttpClient(DEFAULT_MAX_CONNECTIONS, disableCertificateValidation()); setTransport(new ApacheHttpTransport(httpClient)); setRequestFactory(transport().createRequestFactory()); return autoBuild(); }
Example #6
Source File: HttpEventPublisher.java From beam with Apache License 2.0 | 5 votes |
/** * Creates a {@link CloseableHttpClient} to make HTTP POSTs against Splunk's HEC. * * @param maxConnections max number of parallel connections * @param disableCertificateValidation should disable certificate validation */ private CloseableHttpClient getHttpClient( int maxConnections, boolean disableCertificateValidation) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { HttpClientBuilder builder = ApacheHttpTransport.newDefaultHttpClientBuilder(); if (genericUrl().getScheme().equalsIgnoreCase(HTTPS_PROTOCOL_PREFIX)) { LOG.info("SSL connection requested"); HostnameVerifier hostnameVerifier = disableCertificateValidation ? NoopHostnameVerifier.INSTANCE : new DefaultHostnameVerifier(); SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); if (disableCertificateValidation) { LOG.info("Certificate validation is disabled"); sslContextBuilder.loadTrustMaterial((TrustStrategy) (chain, authType) -> true); } SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContextBuilder.build(), hostnameVerifier); builder.setSSLSocketFactory(connectionSocketFactory); } builder.setMaxConnTotal(maxConnections); builder.setDefaultRequestConfig( RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()); return builder.build(); }
Example #7
Source File: OAuth2AuthorizationService.java From cyberduck with GNU General Public License v3.0 | 4 votes |
public OAuth2AuthorizationService(final HttpClient client, final String tokenServerUrl, final String authorizationServerUrl, final String clientid, final String clientsecret, final List<String> scopes) { this(new ApacheHttpTransport(client), tokenServerUrl, authorizationServerUrl, clientid, clientsecret, scopes); }
Example #8
Source File: HttpEventPublisher.java From DataflowTemplates with Apache License 2.0 | votes |
abstract ApacheHttpTransport transport();
Example #9
Source File: HttpEventPublisher.java From DataflowTemplates with Apache License 2.0 | votes |
abstract Builder setTransport(ApacheHttpTransport transport);
Example #10
Source File: HttpEventPublisher.java From DataflowTemplates with Apache License 2.0 | votes |
abstract ApacheHttpTransport transport();
Example #11
Source File: HttpEventPublisher.java From beam with Apache License 2.0 | votes |
abstract ApacheHttpTransport transport();
Example #12
Source File: HttpEventPublisher.java From beam with Apache License 2.0 | votes |
abstract Builder setTransport(ApacheHttpTransport transport);
Example #13
Source File: HttpEventPublisher.java From beam with Apache License 2.0 | votes |
abstract ApacheHttpTransport transport();