@Override protected Drive connect(final HostKeyCallback callback, final LoginCallback prompt) { authorizationService = new OAuth2RequestInterceptor(builder.build(this, prompt).build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); final HttpClientBuilder configuration = builder.build(this, prompt); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService)); this.transport = new ApacheHttpTransport(configuration.build()); return new Drive.Builder(transport, json, new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setSuppressUserAgentSuffix(true); // OAuth Bearer added in interceptor } }) .setApplicationName(useragent.get()) .build(); }
public OAuthAccessToken build() throws IOException { Url = new GenericUrl(config.getAccessTokenUrl()); transport = new ApacheHttpTransport(); HttpRequestFactory requestFactory = transport.createRequestFactory(); request = requestFactory.buildRequest(HttpMethods.GET, Url, null); HttpHeaders headers = new HttpHeaders(); headers.setUserAgent(config.getUserAgent()); headers.setAccept(config.getAccept()); request.setHeaders(headers); createRefreshParameters().intercept(request); return this; }
@Test public void testBrokenPipe_ApacheHttpTransport() throws IOException, Failure { HttpRequestFactory factory = new ApacheHttpTransport().createRequestFactory(); TestService.Iface client = new TestService.Client(new HttpClientHandler( this::endpoint, factory, provider)); try { // The request must be larger than the socket read buffer, to force it to fail the write to socket. client.test(new Request(Strings.times("request ", 1024 * 1024))); fail("No exception"); } catch (SocketException ex) { // TODO: This should be a HttpResponseException assertThat(ex.getMessage(), anyOf( containsString("Broken pipe"), is("Connection reset"), is("Software caused connection abort: socket write error"))); } }
@Test public void testThriftClient() throws TException, IOException, Failure { ApacheHttpTransport transport = new ApacheHttpTransport(); THttpClient httpClient = new THttpClient(endpoint().toString(), transport.getHttpClient()); TBinaryProtocol protocol = new TBinaryProtocol(httpClient); net.morimekta.test.thrift.service.TestService.Iface client = new net.morimekta.test.thrift.service.TestService.Client(protocol); doAnswer(i -> new Response("reply")) .when(impl) .test(any(Request.class)); net.morimekta.test.thrift.service.Response response = client.test(new net.morimekta.test.thrift.service.Request("call")); assertThat(response.getText(), is("reply")); verify(impl).test(any(Request.class)); verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class)); verifyNoMoreInteractions(impl, instrumentation); }
@Test public void testThriftClient_void() throws TException, IOException, Failure { ApacheHttpTransport transport = new ApacheHttpTransport(); THttpClient httpClient = new THttpClient(endpoint().toString(), transport.getHttpClient()); TBinaryProtocol protocol = new TBinaryProtocol(httpClient); net.morimekta.test.thrift.service.TestService.Iface client = new net.morimekta.test.thrift.service.TestService.Client(protocol); AtomicBoolean called = new AtomicBoolean(); doAnswer(i -> { called.set(true); return null; }).when(impl).voidMethod(55); client.voidMethod(55); waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called); verify(impl).voidMethod(55); verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class)); verifyNoMoreInteractions(impl, instrumentation); }
@Test public void testThriftClient_oneway() throws TException, IOException, Failure { ApacheHttpTransport transport = new ApacheHttpTransport(); THttpClient httpClient = new THttpClient(endpoint().toString(), transport.getHttpClient()); TBinaryProtocol protocol = new TBinaryProtocol(httpClient); net.morimekta.test.thrift.service.TestService.Iface client = new net.morimekta.test.thrift.service.TestService.Client(protocol); AtomicBoolean called = new AtomicBoolean(); doAnswer(i -> { called.set(true); return null; }).when(impl).ping(); client.ping(); waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called); verify(impl).ping(); verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), isNull()); verifyNoMoreInteractions(impl, instrumentation); }
@Test public void testThriftClient_failure() throws TException, IOException, Failure { ApacheHttpTransport transport = new ApacheHttpTransport(); THttpClient httpClient = new THttpClient(endpoint().toString(), transport.getHttpClient()); TBinaryProtocol protocol = new TBinaryProtocol(httpClient); net.morimekta.test.thrift.service.TestService.Iface client = new net.morimekta.test.thrift.service.TestService.Client(protocol); AtomicBoolean called = new AtomicBoolean(); doAnswer(i -> { called.set(true); throw new Failure("test"); }).when(impl).voidMethod(55); try { client.voidMethod(55); } catch (net.morimekta.test.thrift.service.Failure e) { assertEquals("test", e.getText()); } waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called); verify(impl).voidMethod(55); verify(instrumentation).onComplete(anyDouble(), any(PServiceCall.class), any(PServiceCall.class)); verifyNoMoreInteractions(impl, instrumentation); }
public GcsAuthentication(String authMethod, Optional<String> serviceAccountEmail, Optional<String> p12KeyFilePath, Optional<String> jsonKeyFilePath, String applicationName) throws IOException, GeneralSecurityException { this.serviceAccountEmail = serviceAccountEmail; this.p12KeyFilePath = p12KeyFilePath; this.jsonKeyFilePath = jsonKeyFilePath; this.applicationName = applicationName; this.httpTransport = new ApacheHttpTransport.Builder().build(); this.jsonFactory = new JacksonFactory(); if (authMethod.equals("compute_engine")) { this.credentials = getComputeCredential(); } else if (authMethod.toLowerCase().equals("json_key")) { this.credentials = getServiceAccountCredentialFromJsonFile(); } else { this.credentials = getServiceAccountCredential(); } }
@Test public void signWithHostHeader() throws URISyntaxException, IOException, RequestSigningException { HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport(); HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(); URI uri = URI.create("https://ignored-hostname.com/billing-usage/v1/reportSources"); HttpRequest request = requestFactory.buildGetRequest(new GenericUrl(uri)); request.getHeaders().put("Host", "ignored-hostname.com"); GoogleHttpClientEdgeGridRequestSigner googleHttpSigner = new GoogleHttpClientEdgeGridRequestSigner(credential); googleHttpSigner.sign(request); // NOTE: The library lower-cases all header names. assertThat(request.getHeaders().containsKey("Host"), is(false)); assertThat(request.getHeaders().containsKey("host"), is(true)); assertThat((String) request.getHeaders().get("host"), equalTo("endpoint.net")); assertThat(request.getUrl().getHost(), equalTo("endpoint.net")); assertThat(request.getHeaders().containsKey("authorization"), is(true)); assertThat(request.getHeaders().getAuthorization(), not(isEmptyOrNullString())); }
@Test public void testBuildTransportOptions() { gsWagon.swapAndCloseConnection(connectionPOJO); final HttpTransportOptions transportOptions = (HttpTransportOptions) gsWagon.buildTransportOptions(connectionPOJO.client); assertEquals(ApacheHttpTransport.class, transportOptions.getHttpTransportFactory().create().getClass()); assertEquals(gsWagon.getTimeout(), transportOptions.getConnectTimeout()); assertEquals(gsWagon.getReadTimeout(), transportOptions.getReadTimeout()); assertEquals( connectionPOJO.client, ((ApacheHttpTransport) transportOptions.getHttpTransportFactory().create()).getHttpClient() ); }
public void execute() { OAuthSigner signer = signerFactory.createSigner(null); tokenRequest = new OAuthGetTemporaryToken(config.getRequestTokenUrl()); tokenRequest.consumerKey = config.getConsumerKey(); tokenRequest.callback = config.getRedirectUri(); ApacheHttpTransport.Builder transBuilder = new ApacheHttpTransport.Builder(); if (config.getProxyHost() != null && "" != config.getProxyHost()) { String proxy_host = config.getProxyHost(); long proxy_port = config.getProxyPort(); boolean proxyHttps = config.getProxyHttpsEnabled(); String proxy_schema = proxyHttps == true ? "https" : "http"; System.out.println("proxy.host=" + proxy_host + ", proxy.port=" + proxy_port + ", proxy_schema=" + proxy_schema); HttpHost proxy = new HttpHost(proxy_host, (int) proxy_port, proxy_schema); transBuilder.setProxy(proxy); tokenRequest.transport = transBuilder.build(); } else { tokenRequest.transport = new ApacheHttpTransport(); } tokenRequest.signer = signer; OAuthCredentialsResponse temporaryTokenResponse = null; try { temporaryTokenResponse = tokenRequest.execute(); tempToken = temporaryTokenResponse.token; tempTokenSecret = temporaryTokenResponse.tokenSecret; } catch (IOException e) { e.printStackTrace(); } }
@Override protected Void doInBackground(Uri... params) { try { signer.clientSharedSecret = Constants.CONSUMER_SECRET; OAuthGetTemporaryToken temporaryToken = new OAuthGetTemporaryToken(Constants.REQUEST_URL); temporaryToken.transport = new ApacheHttpTransport(); temporaryToken.signer = signer; temporaryToken.consumerKey = Constants.CONSUMER_KEY; temporaryToken.callback = Constants.OAUTH_CALLBACK_URL; OAuthCredentialsResponse tempCredentials = temporaryToken.execute(); signer.tokenSharedSecret = tempCredentials.tokenSecret; OAuthAuthorizeTemporaryTokenUrl authorizeUrl = new OAuthAuthorizeTemporaryTokenUrl(Constants.AUTHORIZE_URL); authorizeUrl.temporaryToken = tempCredentials.token; authorizationUrl = authorizeUrl.build(); handled = false; } catch (Exception ex) { ex.printStackTrace(); } return null; }
public OAuthGetAccessToken getOAuthAccessToken(String requestToken) { signer.clientSharedSecret = Constants.CONSUMER_SECRET; OAuthGetAccessToken accessToken = new OAuthGetAccessToken(Constants.ACCESS_URL); accessToken.transport = new ApacheHttpTransport(); accessToken.temporaryToken = requestToken; accessToken.signer = signer; accessToken.consumerKey = Constants.CONSUMER_KEY; return accessToken; }
@Test public void testSimpleRequest_connectionRefused_apacheHttpTransport() throws IOException, Failure { HttpRequestFactory factory = new ApacheHttpTransport().createRequestFactory(); GenericUrl url = new GenericUrl("http://localhost:" + (port - 10) + "/" + ENDPOINT); TestService.Iface client = new TestService.Client(new HttpClientHandler( () -> url, factory, provider)); try { client.test(new Request("request")); fail("No exception"); } catch (HttpHostConnectException ex) { assertThat(ex.getMessage(), is(startsWith("Connect to localhost:" + (port - 10) + " failed: Connection refused"))); } }
public HttpClientAssist(@Nullable HttpClientConfig conf, @Nullable ProxySelector proxySelector) { HttpClientConfig hcc = conf == null ? defaultHcc : conf.clone(); // httpTransport = new NetHttpTransport.Builder() // .setConnectionFactory(url -> { // Proxy proxy = hcc.proxy; // if (proxyPicker != null) // proxy = proxyPicker.pick(); // HttpURLConnection conn = (HttpURLConnection) (proxy == null ? url.openConnection() // : url.openConnection(proxy)); // return conn; // }).build(); ApacheHttpTransport.Builder apacheBuilder = new ApacheHttpTransport.Builder().setProxySelector(proxySelector); HttpParams httpParams = apacheBuilder.getHttpParams(); HttpConnectionParams.setSoTimeout(httpParams, hcc.soTimeout); HttpConnectionParams.setConnectionTimeout(httpParams, hcc.connectionTimeout); ConnManagerParams.setMaxTotalConnections(httpParams, hcc.maxTotalConnections); ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(hcc.maxConnectionsPerRoute)); httpTransport = apacheBuilder.build(); reqFactory = httpTransport.createRequestFactory(req -> { req.setConnectTimeout(hcc.connectionTimeout) .setReadTimeout(hcc.soTimeout) .setSuppressUserAgentSuffix(true) .setThrowExceptionOnExecuteError(false) ; if (hcc.headers != null) { req.getHeaders().putAll(hcc.headers); } req.getHeaders() .setUserAgent(hcc.userAgent) .put(HttpHeaders.CONNECTION, hcc.isKeepAlive ? "keep-alive" : "close") ; }); }
public HttpResponse callApi(String apimethod, String httpmethod) throws IOException { HttpTransport http_transport = new ApacheHttpTransport(); OAuthParameters parameters = tokmgr.getOAuthParameters(); HttpRequestFactory factory = http_transport.createRequestFactory(parameters); GenericUrl url = new GenericUrl(API_URL + apimethod); HttpRequest req = factory.buildGetRequest(url); req.setRequestMethod(httpmethod); HttpResponse resp = req.execute(); return resp; }
public HttpResponse callApi(String apimethod, String httpmethod, String content) throws IOException { HttpTransport http_transport = new ApacheHttpTransport(); OAuthParameters parameters = tokmgr.getOAuthParameters(); HttpRequestFactory factory = http_transport.createRequestFactory(parameters); GenericUrl url = new GenericUrl(API_URL + apimethod); HttpRequest req = factory.buildGetRequest(url); req.setRequestMethod(httpmethod); // UrlEncodedContent cont = new UrlEncodedContent(content); PlainHttpContent conte = new PlainHttpContent(content, "text/xml"); req.setContent(conte); HttpResponse resp = req.execute(); return resp; }
public User getUserByIdToken(String idTokenString) throws GeneralSecurityException, IOException, IllegalArgumentException, ObjectNotFoundException, NdexException { ApacheHttpTransport.Builder builder = new ApacheHttpTransport.Builder(); GoogleIdTokenVerifier localVerifier = new GoogleIdTokenVerifier.Builder(builder.build(), new JacksonFactory()) .setAudience(Collections.singletonList(clientID)) // Or, if multiple clients access the backend: //.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3)) .build(); GoogleIdToken idToken = localVerifier.verify(idTokenString); if (idToken != null) { Payload payload = idToken.getPayload(); // Print user identifier // String userId = payload.getSubject(); // System.out.println("User ID: " + userId); // Get profile information from payload String email = payload.getEmail(); /* boolean emailVerified = Boolean.valueOf(payload.getEmailVerified()); String name = (String) payload.get("name"); String pictureUrl = (String) payload.get("picture"); String locale = (String) payload.get("locale"); String familyName = (String) payload.get("family_name"); String givenName = (String) payload.get("given_name"); */ try (UserDAO userDao = new UserDAO()) { User user = userDao.getUserByEmail(email.toLowerCase(),true); return user; } catch ( SQLException e1) { e1.printStackTrace(); throw new UnauthorizedOperationException("SQL Error when getting user by email: " + e1.getMessage()); } } throw new UnauthorizedOperationException("Invalid OAuth ID token."); }
public UUID getUserUUIDByIdToken(String idTokenString) throws GeneralSecurityException, IOException, IllegalArgumentException, ObjectNotFoundException, NdexException { ApacheHttpTransport.Builder builder = new ApacheHttpTransport.Builder(); GoogleIdTokenVerifier localVerifier = new GoogleIdTokenVerifier.Builder(builder.build(), new JacksonFactory()) .setAudience(Collections.singletonList(clientID)) // Or, if multiple clients access the backend: //.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3)) .build(); GoogleIdToken idToken = localVerifier.verify(idTokenString); if (idToken != null) { Payload payload = idToken.getPayload(); // Print user identifier String userId = payload.getSubject(); System.out.println("User ID: " + userId); // Get profile information from payload String email = payload.getEmail(); try (UserDAO userDao = new UserDAO()) { UUID userUUID = userDao.getUUIDByEmail(email.toLowerCase()); return userUUID; } catch ( SQLException e1) { e1.printStackTrace(); throw new UnauthorizedOperationException("SQL Error when getting user by email: " + e1.getMessage()); } } throw new UnauthorizedOperationException("Invalid OAuth ID token."); }
public HttpTail(String aUrl, long aStartingOffset, long aDelay) { url = new GenericUrl(aUrl); HttpTransport transport = new ApacheHttpTransport(); requestFactory = transport.createRequestFactory(); startingOffset = aStartingOffset; delay = aDelay; }
private HttpRequestFactory createSigningRequestFactory() { HttpTransport httpTransport = new ApacheHttpTransport(); return httpTransport.createRequestFactory(new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setInterceptor(new GoogleHttpClientEdgeGridInterceptor(credential)); } }); }
@Test public void signEachRequest() throws URISyntaxException, IOException, RequestSigningException { HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport(); HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(); URI uri = URI.create("https://ignored-hostname.com/billing-usage/v1/reportSources"); HttpRequest request = requestFactory.buildGetRequest(new GenericUrl(uri)); GoogleHttpClientEdgeGridRequestSigner googleHttpSigner = new GoogleHttpClientEdgeGridRequestSigner(credential); googleHttpSigner.sign(request); assertThat(request.getHeaders().containsKey("host"), is(false)); assertThat(request.getUrl().getHost(), equalTo("endpoint.net")); assertThat(request.getHeaders().containsKey("authorization"), is(true)); assertThat(request.getHeaders().getAuthorization(), not(isEmptyOrNullString())); }
private HttpRequestFactory createSigningRequestFactory() { HttpTransport httpTransport = null; try { httpTransport = new ApacheHttpTransport.Builder().doNotValidateCertificate().build(); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } return httpTransport.createRequestFactory(new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { request.setInterceptor(new GoogleHttpClientEdgeGridInterceptor(credential)); } }); }
@VisibleForTesting HttpTransportFactory getTransportFactory(final HttpClient httpClient) { return () -> new ApacheHttpTransport(httpClient); }
@VisibleForTesting HttpClient buildClient() { return ApacheHttpTransport.newDefaultHttpClient(); }
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); }
/** * Executes the HTTP request for a temporary or long-lived token. * * @throws IOException */ public final HttpResponse execute() throws IOException { ApacheHttpTransport.Builder builder = new ApacheHttpTransport.Builder(); if(this.proxyEnabled) { builder.setProxy(this.proxy); } transport = builder.build(); if(usePost && body != null){ requestBody = ByteArrayContent.fromString(null, body); } HttpHeaders headers = new HttpHeaders(); headers.setUserAgent(config.getUserAgent()); headers.setAccept(accept != null ? accept : config.getAccept()); headers.setContentType(contentType == null ? "application/xml" : contentType); if(ifModifiedSince != null) { //System.out.println("Set Header " + this.ifModifiedSince); headers.setIfModifiedSince(this.ifModifiedSince); } HttpRequestFactory requestFactory = transport.createRequestFactory(); HttpRequest request; HttpResponse response = null; request = requestFactory.buildRequest(this.httpMethod, Url, requestBody); request.setConnectTimeout(connectTimeout); request.setReadTimeout(readTimeout); request.setHeaders(headers); createParameters().intercept(request); response = request.execute(); response.setContentLoggingLimit(0); return response; }
@Override public HttpTransport getHttpTransport() { return new ApacheHttpTransport(); }
public TestApp() { String projectId = ServiceOptions.getDefaultProjectId(); try { //export GRPC_PROXY_EXP=localhost:3128 HttpHost proxy = new HttpHost("127.0.0.1",3128); DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); httpClient.addRequestInterceptor(new HttpRequestInterceptor(){ @Override public void process(org.apache.http.HttpRequest request, HttpContext context) throws HttpException, IOException { //if (request.getRequestLine().getMethod().equals("CONNECT")) // request.addHeader(new BasicHeader("Proxy-Authorization","Basic dXNlcjE6dXNlcjE=")); } }); mHttpTransport = new ApacheHttpTransport(httpClient); HttpTransportFactory hf = new HttpTransportFactory(){ @Override public HttpTransport create() { return mHttpTransport; } }; credential = GoogleCredentials.getApplicationDefault(hf); CredentialsProvider credentialsProvider = new GoogleCredentialsProvider(){ public List<String> getScopesToApply(){ return Arrays.asList("https://www.googleapis.com/auth/pubsub"); } public Credentials getCredentials() { return credential; } }; TopicAdminSettings topicAdminSettings = TopicAdminSettings.newBuilder().setCredentialsProvider(credentialsProvider) .build(); TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings); //TopicAdminClient topicAdminClient = TopicAdminClient.create(); ProjectName project = ProjectName.create(projectId); for (Topic element : topicAdminClient.listTopics(project).iterateAll()) System.out.println(element.getName()); } catch (Exception ex) { System.out.println("ERROR " + ex); } }
/** * Here the actual Credentials are built with any parameters provided to this class, such * as JsonFactory, Scope and HttpTransport. If any parameters are not provided, stock * options will be used. * * @return * @throws IOException * @throws GeneralSecurityException */ public Credential build() throws IOException, GeneralSecurityException { GoogleCredential.Builder credential = new GoogleCredential.Builder(); Log.d(TAG, "Initiated Builder"); // 1. Service Account ID credential.setServiceAccountId(accountID); Log.d(TAG, "Setup Account ID"); // 2. Private Key credential.setServiceAccountPrivateKeyFromP12File( getGoogleCloudKeyFile(context, key_resource_ID)); Log.d(TAG, "Setup Private Key"); // 3. HttpTransport if( httpTransport != null ) { credential.setTransport(httpTransport); Log.d(TAG, "Setup given HttpTransport"); } else { credential.setTransport(new ApacheHttpTransport()); Log.d(TAG, "Setup stock HttpTransport (ApacheHttpTransport)"); } // 4. Scope if( scopes != null && scopes.size() > 0 ) { credential.setServiceAccountScopes(scopes); Log.d(TAG, "Setup given scope"); } else { scopes = new ArrayList<>(); scopes.add(StorageScopes.DEVSTORAGE_FULL_CONTROL); credential.setServiceAccountScopes(scopes); Log.d(TAG, "Setup stock scope (DEVSTORAGE_FULL_CONTROL)"); } // 5. JsonFactory if( jsonFactory != null ) { credential.setJsonFactory(jsonFactory); Log.d(TAG, "Setup given JsonFactory"); } else { credential.setJsonFactory(new JacksonFactory()); Log.d(TAG, "Setup stock JsonFactory (JacksonFactory)"); } // 6. Build GoogleCredential builtCredential = credential.build(); Log.d(TAG, "Building Google Credential"); Log.d(TAG, "Returning built Credential"); return builtCredential; }
@Override public HttpRequestFactory get() { return new ApacheHttpTransport.Builder() .build() .createRequestFactory(); }
private static ApacheHttpTransport getTransport(){ return new ApacheHttpTransport(newDefaultHttpClient(SSLSocketFactory.getSocketFactory(), getHttpParams(), ProxySelector.getDefault())); }
public static HttpTransport newCompatibleTransport() { return isGingerbreadOrHigher() ? new GapiOkTransport() : new ApacheHttpTransport(); }
/** * Create an {@link ApacheHttpTransport} for calling Google APIs with an optional HTTP proxy. * * @param proxy Optional HTTP proxy to use with the transport. * @return The resulting HttpTransport. * @throws IOException If there is an issue connecting to Google's certification server. * @throws GeneralSecurityException If there is a security issue with the keystore. */ public static ApacheHttpTransport createApacheHttpTransport(@Nullable HttpHost proxy) throws IOException, GeneralSecurityException { ApacheHttpTransport.Builder builder = new ApacheHttpTransport.Builder(); builder.trustCertificates(GoogleUtils.getCertificateTrustStore()); builder.setProxy(proxy); return builder.build(); }