use of com.google.api.client.http.HttpTransport in project hub-alert by blackducksoftware.
the class AzureBoardsProperties method hasOAuthCredentials.
public boolean hasOAuthCredentials(ProxyInfo proxy) {
HttpTransport httpTransport = createHttpTransport(proxy);
try {
AuthorizationCodeFlow oAuthFlow = createOAuthFlow(httpTransport);
Optional<Credential> oAuthCredential = getExistingOAuthCredential(oAuthFlow);
return oAuthCredential.isPresent();
} catch (IOException e) {
return false;
}
}
use of com.google.api.client.http.HttpTransport in project hub-alert by blackducksoftware.
the class AzureBoardsProperties method createAzureHttpRequestCreator.
public AzureHttpRequestCreator createAzureHttpRequestCreator(ProxyInfo proxyInfo, Gson gson) throws AlertException {
HttpTransport httpTransport = createHttpTransport(proxyInfo);
try {
AuthorizationCodeFlow oAuthFlow = createOAuthFlow(httpTransport);
Credential oAuthCredential = getExistingOAuthCredential(oAuthFlow).orElseThrow(() -> new AlertException(String.format("No existing Azure OAuth credential associated with '%s'", oauthUserId)));
return AzureHttpRequestCreatorFactory.withCredential(httpTransport, oAuthCredential, gson);
} catch (IOException e) {
throw new AlertException("Cannot read OAuth credentials", e);
}
}
use of com.google.api.client.http.HttpTransport in project hub-alert by blackducksoftware.
the class AzureBoardsProperties method createAzureHttpService.
public AzureHttpService createAzureHttpService(ProxyInfo proxy, Gson gson, String authorizationCode) throws AlertException {
HttpTransport httpTransport = createHttpTransport(proxy);
try {
AuthorizationCodeFlow oAuthFlow = createOAuthFlow(httpTransport);
Credential oAuthCredential = requestTokens(oAuthFlow, authorizationCode).orElseThrow(() -> new AlertException(String.format("Cannot request Azure OAuth credential associated with '%s'", oauthUserId)));
AzureHttpRequestCreator httpRequestCreator = AzureHttpRequestCreatorFactory.withCredential(httpTransport, oAuthCredential, gson);
return new AzureHttpService(gson, httpRequestCreator);
} catch (IOException e) {
throw new AlertException("Cannot request OAuth credentials", e);
}
}
use of com.google.api.client.http.HttpTransport in project cloudbreak by hortonworks.
the class GcpDeleteVpcTest method deleteNetwork.
@AfterSuite
@Parameters("vpcName")
public void deleteNetwork(@Optional("it-vpc") String vpcName) throws Exception {
springTestContextPrepareTestInstance();
String serviceAccountPrivateKey = ResourceUtil.readBase64EncodedContentFromResource(applicationContext, defaultP12File);
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
PrivateKey privateKey = SecurityUtils.loadPrivateKeyFromKeyStore(SecurityUtils.getPkcs12KeyStore(), new ByteArrayInputStream(Base64.decodeBase64(serviceAccountPrivateKey)), "notasecret", "privatekey", "notasecret");
JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();
GoogleCredential googleCredential = new GoogleCredential.Builder().setTransport(httpTransport).setJsonFactory(jsonFactory).setServiceAccountId(defaultServiceAccountId).setServiceAccountScopes(Collections.singletonList(ComputeScopes.COMPUTE)).setServiceAccountPrivateKey(privateKey).build();
Compute compute = new Builder(httpTransport, jsonFactory, null).setApplicationName(defaultName).setHttpRequestInitializer(googleCredential).build();
Delete delete = compute.networks().delete(defaultProjectId, vpcName);
Operation operation = delete.execute();
if (operation.getHttpErrorStatusCode() != null) {
throw new IllegalStateException("gcp operation failed: " + operation.getHttpErrorMessage());
}
}
use of com.google.api.client.http.HttpTransport in project pinpoint by naver.
the class HttpRequestIT method execute.
@Test
public void execute() throws Exception {
HttpTransport NET_HTTP_TRANSPORT = new NetHttpTransport();
HttpRequestFactory requestFactory = NET_HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) {
}
});
GenericUrl url = new GenericUrl(webServer.getCallHttpUrl());
HttpRequest request = null;
HttpResponse response = null;
try {
request = requestFactory.buildGetRequest(url);
response = request.execute();
} catch (IOException ignored) {
} finally {
close(response);
}
Method executeMethod = HttpRequest.class.getDeclaredMethod("execute");
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.verifyTrace(Expectations.event("GOOGLE_HTTP_CLIENT_INTERNAL", executeMethod));
}
Aggregations