Class ClientSideCredentialAccessBoundaryFactory.Builder
- Enclosing class:
- ClientSideCredentialAccessBoundaryFactory
ClientSideCredentialAccessBoundaryFactory.
Use this builder to create instances of ClientSideCredentialAccessBoundaryFactory
with the desired configuration options.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a newClientSideCredentialAccessBoundaryFactoryinstance based on the current builder configuration.setClock(com.google.api.client.util.Clock clock) Set the clock for checking token expiry.setHttpTransportFactory(HttpTransportFactory transportFactory) Sets the HTTP transport factory.setMinimumTokenLifetime(Duration minimumTokenLifetime) Sets the minimum acceptable lifetime for a generated downscoped access token.setRefreshMargin(Duration refreshMargin) Sets the refresh margin for the underlying credentials.setSourceCredential(GoogleCredentials sourceCredential) Sets the required source credential.setUniverseDomain(String universeDomain) Sets the optional universe domain.
-
Method Details
-
setSourceCredential
@CanIgnoreReturnValue public ClientSideCredentialAccessBoundaryFactory.Builder setSourceCredential(GoogleCredentials sourceCredential) Sets the required source credential.- Parameters:
sourceCredential- theGoogleCredentialsto set. This is a required parameter.- Returns:
- this
Builderobject for chaining. - Throws:
NullPointerException- ifsourceCredentialisnull.
-
setMinimumTokenLifetime
@CanIgnoreReturnValue public ClientSideCredentialAccessBoundaryFactory.Builder setMinimumTokenLifetime(Duration minimumTokenLifetime) Sets the minimum acceptable lifetime for a generated downscoped access token.This parameter ensures that any generated downscoped access token has a minimum validity period. If the time remaining before the underlying credentials expire is less than this value, the factory will perform a blocking refresh, meaning that it will wait until the credentials are refreshed before generating a new downscoped token. This guarantees that the generated token will be valid for at least
minimumTokenLifetime. A reasonable value should be chosen based on the expected duration of operations using the downscoped token. If not set, the default value is defined byClientSideCredentialAccessBoundaryFactory.DEFAULT_MINIMUM_TOKEN_LIFETIME.- Parameters:
minimumTokenLifetime- The minimum acceptable lifetime for a generated downscoped access token. Must be greater than zero.- Returns:
- This
Builderobject. - Throws:
IllegalArgumentException- ifminimumTokenLifetimeis negative or zero.
-
setRefreshMargin
@CanIgnoreReturnValue public ClientSideCredentialAccessBoundaryFactory.Builder setRefreshMargin(Duration refreshMargin) Sets the refresh margin for the underlying credentials.This duration specifies how far in advance of the credentials' expiration time an asynchronous refresh should be initiated. This refresh happens in the background, without blocking the main thread. If not provided, it will default to the value defined by
ClientSideCredentialAccessBoundaryFactory.DEFAULT_REFRESH_MARGIN.Note: The
refreshMarginmust be at least one minute longer than theminimumTokenLifetime.- Parameters:
refreshMargin- The refresh margin. Must be greater than zero.- Returns:
- This
Builderobject. - Throws:
IllegalArgumentException- ifrefreshMarginis negative or zero.
-
setHttpTransportFactory
@CanIgnoreReturnValue public ClientSideCredentialAccessBoundaryFactory.Builder setHttpTransportFactory(HttpTransportFactory transportFactory) Sets the HTTP transport factory.- Parameters:
transportFactory- theHttpTransportFactoryto set- Returns:
- this
Builderobject
-
setUniverseDomain
@CanIgnoreReturnValue public ClientSideCredentialAccessBoundaryFactory.Builder setUniverseDomain(String universeDomain) Sets the optional universe domain.- Parameters:
universeDomain- the universe domain to set- Returns:
- this
Builderobject
-
setClock
public ClientSideCredentialAccessBoundaryFactory.Builder setClock(com.google.api.client.util.Clock clock) Set the clock for checking token expiry. Used for testing.- Parameters:
clock- the clock to use. Defaults to the system clock- Returns:
- the builder
-
build
Creates a newClientSideCredentialAccessBoundaryFactoryinstance based on the current builder configuration.- Returns:
- A new
ClientSideCredentialAccessBoundaryFactoryinstance. - Throws:
IllegalStateException- if the builder is not properly configured (e.g., if the source credential is not set).IllegalArgumentException- if the refresh margin is not at least one minute longer than the minimum token lifetime.
-