Package com.google.cloud.spanner
Class MutableCredentials
java.lang.Object
com.google.auth.Credentials
com.google.cloud.spanner.MutableCredentials
- All Implemented Interfaces:
Serializable
A mutable
Credentials implementation that delegates authentication behavior to a scoped
ServiceAccountCredentials instance.
This class is intended for scenarios where an application needs to replace the underlying service account credentials for a long-running Spanner Client.
All operations inherited from Credentials are forwarded to the current delegate,
including request metadata retrieval and token refresh. Calling updateCredentials(ServiceAccountCredentials) replaces the delegate with a newly scoped
credentials instance created from the same scopes that were provided when this object was
constructed.
- See Also:
-
Field Summary
Fields inherited from class com.google.auth.Credentials
GOOGLE_DEFAULT_UNIVERSE -
Constructor Summary
ConstructorsConstructorDescriptionMutableCredentials(ServiceAccountCredentials credentials) Creates a MutableCredentials instance with default spanner scopes.MutableCredentials(ServiceAccountCredentials credentials, Set<String> scopes) -
Method Summary
Modifier and TypeMethodDescriptiongetRequestMetadata(URI uri) voidgetRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback) booleanbooleanvoidrefresh()voidupdateCredentials(ServiceAccountCredentials credentials) Replaces the current delegate with a newly scoped credentials instance.Methods inherited from class com.google.auth.Credentials
blockingGetToCallback, getRequestMetadata
-
Constructor Details
-
MutableCredentials
Creates a MutableCredentials instance with default spanner scopes. -
MutableCredentials
public MutableCredentials(@Nonnull ServiceAccountCredentials credentials, @Nonnull Set<String> scopes)
-
-
Method Details
-
updateCredentials
Replaces the current delegate with a newly scoped credentials instance.Note any in-flight RPC may continue to use the old credentials.
The provided
ServiceAccountCredentialsis scoped using the same scopes that were supplied when thisMutableCredentialsinstance was created.- Parameters:
credentials- the new base service account credentials to scope and use for client authorization.
-
getAuthenticationType
- Specified by:
getAuthenticationTypein classCredentials
-
getRequestMetadata
- Specified by:
getRequestMetadatain classCredentials- Throws:
IOException
-
hasRequestMetadata
public boolean hasRequestMetadata()- Specified by:
hasRequestMetadatain classCredentials
-
hasRequestMetadataOnly
public boolean hasRequestMetadataOnly()- Specified by:
hasRequestMetadataOnlyin classCredentials
-
refresh
- Specified by:
refreshin classCredentials- Throws:
IOException
-
getRequestMetadata
- Overrides:
getRequestMetadatain classCredentials
-
getUniverseDomain
- Overrides:
getUniverseDomainin classCredentials- Throws:
IOException
-
getMetricsCredentialType
- Overrides:
getMetricsCredentialTypein classCredentials
-