use of com.google.cloud.iam.credentials.v1.IamCredentialsSettings in project gapic-generator-java by googleapis.
the class SyncGenerateAccessToken method syncGenerateAccessToken.
public static void syncGenerateAccessToken() throws Exception {
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
IamCredentialsStubSettings.Builder iamCredentialsSettingsBuilder = IamCredentialsStubSettings.newBuilder();
iamCredentialsSettingsBuilder.generateAccessTokenSettings().setRetrySettings(iamCredentialsSettingsBuilder.generateAccessTokenSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(30)).build());
IamCredentialsStubSettings iamCredentialsSettings = iamCredentialsSettingsBuilder.build();
}
use of com.google.cloud.iam.credentials.v1.IamCredentialsSettings in project gapic-generator-java by googleapis.
the class SyncCreateSetEndpoint method syncCreateSetEndpoint.
public static void syncCreateSetEndpoint() throws Exception {
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
IamCredentialsSettings iamCredentialsSettings = IamCredentialsSettings.newBuilder().setEndpoint(myEndpoint).build();
IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create(iamCredentialsSettings);
}
use of com.google.cloud.iam.credentials.v1.IamCredentialsSettings in project gapic-generator-java by googleapis.
the class SyncGenerateAccessToken method syncGenerateAccessToken.
public static void syncGenerateAccessToken() throws Exception {
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
IamCredentialsSettings.Builder iamCredentialsSettingsBuilder = IamCredentialsSettings.newBuilder();
iamCredentialsSettingsBuilder.generateAccessTokenSettings().setRetrySettings(iamCredentialsSettingsBuilder.generateAccessTokenSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(30)).build());
IamCredentialsSettings iamCredentialsSettings = iamCredentialsSettingsBuilder.build();
}
use of com.google.cloud.iam.credentials.v1.IamCredentialsSettings in project gapic-generator-java by googleapis.
the class SyncCreateSetCredentialsProvider method syncCreateSetCredentialsProvider.
public static void syncCreateSetCredentialsProvider() throws Exception {
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
IamCredentialsSettings iamCredentialsSettings = IamCredentialsSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create(iamCredentialsSettings);
}
use of com.google.cloud.iam.credentials.v1.IamCredentialsSettings in project spring-vault by spring-projects.
the class GcpIamCredentialsAuthentication method signJwt.
protected String signJwt() {
String serviceAccount = getServiceAccountId();
Map<String, Object> jwtPayload = getJwtPayload(this.options, serviceAccount);
try {
IamCredentialsSettings credentialsSettings = IamCredentialsSettings.newBuilder().setCredentialsProvider(() -> this.credentials).setTransportChannelProvider(this.transportChannelProvider).build();
try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create(credentialsSettings)) {
String payload = JSON_FACTORY.toString(jwtPayload);
ServiceAccountName serviceAccountName = ServiceAccountName.of("-", serviceAccount);
SignJwtResponse response = iamCredentialsClient.signJwt(serviceAccountName, Collections.emptyList(), payload);
return response.getSignedJwt();
}
} catch (IOException e) {
throw new VaultLoginException("Cannot sign JWT", e);
}
}
Aggregations