Search in sources :

Example 1 with 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.
    IamCredentialsStubSettings.Builder iamCredentialsSettingsBuilder = IamCredentialsStubSettings.newBuilder();
    iamCredentialsSettingsBuilder.generateAccessTokenSettings().setRetrySettings(iamCredentialsSettingsBuilder.generateAccessTokenSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(30)).build());
    IamCredentialsStubSettings iamCredentialsSettings = iamCredentialsSettingsBuilder.build();
}
Also used : IamCredentialsStubSettings(com.google.cloud.iam.credentials.v1.stub.IamCredentialsStubSettings)

Example 2 with IamCredentialsSettings

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);
}
Also used : IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) IamCredentialsSettings(com.google.cloud.iam.credentials.v1.IamCredentialsSettings)

Example 3 with 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();
}
Also used : IamCredentialsSettings(com.google.cloud.iam.credentials.v1.IamCredentialsSettings)

Example 4 with IamCredentialsSettings

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);
}
Also used : IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) IamCredentialsSettings(com.google.cloud.iam.credentials.v1.IamCredentialsSettings)

Example 5 with 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);
    }
}
Also used : SignJwtResponse(com.google.cloud.iam.credentials.v1.SignJwtResponse) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) ServiceAccountName(com.google.cloud.iam.credentials.v1.ServiceAccountName) IOException(java.io.IOException) IamCredentialsSettings(com.google.cloud.iam.credentials.v1.IamCredentialsSettings)

Aggregations

IamCredentialsSettings (com.google.cloud.iam.credentials.v1.IamCredentialsSettings)4 IamCredentialsClient (com.google.cloud.iam.credentials.v1.IamCredentialsClient)3 ServiceAccountName (com.google.cloud.iam.credentials.v1.ServiceAccountName)1 SignJwtResponse (com.google.cloud.iam.credentials.v1.SignJwtResponse)1 IamCredentialsStubSettings (com.google.cloud.iam.credentials.v1.stub.IamCredentialsStubSettings)1 IOException (java.io.IOException)1