Class ImpersonatedCredentials.Builder (1.54.0)

public static class ImpersonatedCredentials.Builder extends GoogleCredentials.Builder

Inheritance

java.lang.Object > OAuth2Credentials.Builder > GoogleCredentials.Builder > ImpersonatedCredentials.Builder

Constructors

Builder()

protected Builder()

Builder(GoogleCredentials sourceCredentials, String targetPrincipal) (deprecated)

protected Builder(GoogleCredentials sourceCredentials, String targetPrincipal)

Deprecated. Use #Builder(ImpersonatedCredentials) instead. This constructor will be removed in a future release.

Parameters
Name Description
sourceCredentials GoogleCredentials

The source credentials to use for impersonation.

targetPrincipal String

The service account to impersonate.

Builder(ImpersonatedCredentials credentials)

protected Builder(ImpersonatedCredentials credentials)
Parameter
Name Description
credentials ImpersonatedCredentials

Methods

build()

public ImpersonatedCredentials build()
Returns
Type Description
ImpersonatedCredentials
Overrides

getCalendar()

public @Nullable Calendar getCalendar()

This method is marked obsolete. There is no alternative to getting a custom calendar for the Credential.

Returns the calendar to be used for parsing the expiration time.

Returns
Type Description
@org.jspecify.annotations.Nullable java.util.Calendar

the calendar

getDelegates()

public @Nullable List<String> getDelegates()
Returns
Type Description
@org.jspecify.annotations.Nullable java.util.List<String>

getHttpTransportFactory()

public @Nullable HttpTransportFactory getHttpTransportFactory()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.auth.http.HttpTransportFactory

getIamEndpointOverride()

public @Nullable String getIamEndpointOverride()
Returns
Type Description
@org.jspecify.annotations.Nullable java.lang.String

getLifetime()

public int getLifetime()
Returns
Type Description
int

getScopes()

public @Nullable List<String> getScopes()
Returns
Type Description
@org.jspecify.annotations.Nullable java.util.List<String>

List of scopes to be applied to the impersonated token.

getSourceCredentials()

public @Nullable GoogleCredentials getSourceCredentials()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.auth.oauth2.GoogleCredentials

getTargetPrincipal()

public @Nullable String getTargetPrincipal()
Returns
Type Description
@org.jspecify.annotations.Nullable java.lang.String

setCalendar(@Nullable Calendar calendar)

public ImpersonatedCredentials.Builder setCalendar(@Nullable Calendar calendar)

This method is marked obsolete. There is no alternative to setting a custom calendar for the Credential.

Sets the calendar to be used for parsing the expiration time.

Parameter
Name Description
calendar @org.jspecify.annotations.Nullable java.util.Calendar

the calendar to use

Returns
Type Description
ImpersonatedCredentials.Builder

the builder

setDelegates(@Nullable List<String> delegates)

public ImpersonatedCredentials.Builder setDelegates(@Nullable List<String> delegates)
Parameter
Name Description
delegates @org.jspecify.annotations.Nullable java.util.List<String>
Returns
Type Description
ImpersonatedCredentials.Builder

setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory)

public ImpersonatedCredentials.Builder setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory)
Parameter
Name Description
transportFactory @org.jspecify.annotations.Nullable com.google.auth.http.HttpTransportFactory
Returns
Type Description
ImpersonatedCredentials.Builder

setIamEndpointOverride(@Nullable String iamEndpointOverride)

public ImpersonatedCredentials.Builder setIamEndpointOverride(@Nullable String iamEndpointOverride)
Parameter
Name Description
iamEndpointOverride @org.jspecify.annotations.Nullable java.lang.String
Returns
Type Description
ImpersonatedCredentials.Builder

setLifetime(int lifetime)

public ImpersonatedCredentials.Builder setLifetime(int lifetime)
Parameter
Name Description
lifetime int
Returns
Type Description
ImpersonatedCredentials.Builder

setQuotaProjectId(@Nullable String quotaProjectId)

public ImpersonatedCredentials.Builder setQuotaProjectId(@Nullable String quotaProjectId)
Parameter
Name Description
quotaProjectId @org.jspecify.annotations.Nullable java.lang.String
Returns
Type Description
ImpersonatedCredentials.Builder
Overrides

setScopes(List<String> scopes)

public ImpersonatedCredentials.Builder setScopes(List<String> scopes)

Set the scopes to be applied on the impersonated token and not on the source credential. This user configuration has precedence over the scopes listed in the source credential json file.

Parameter
Name Description
scopes List<String>

List of scopes to apply to the impersonated token

Returns
Type Description
ImpersonatedCredentials.Builder

setSourceCredentials(GoogleCredentials sourceCredentials)

public ImpersonatedCredentials.Builder setSourceCredentials(GoogleCredentials sourceCredentials)
Parameter
Name Description
sourceCredentials GoogleCredentials
Returns
Type Description
ImpersonatedCredentials.Builder

setTargetPrincipal(String targetPrincipal)

public ImpersonatedCredentials.Builder setTargetPrincipal(String targetPrincipal)
Parameter
Name Description
targetPrincipal String
Returns
Type Description
ImpersonatedCredentials.Builder