Package com.google.cloud.spanner
Class MutableCredentials
java.lang.Object
com.google.auth.Credentials
com.google.cloud.spanner.MutableCredentials
- All Implemented Interfaces:
Serializable
public class MutableCredentials
extends com.google.auth.Credentials
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(com.google.auth.oauth2.ServiceAccountCredentials credentials) Creates a MutableCredentials instance with default spanner scopes.MutableCredentials(com.google.auth.oauth2.ServiceAccountCredentials credentials, Set<String> scopes) -
Method Summary
Modifier and TypeMethodDescriptioncom.google.auth.CredentialTypeForMetricsgetRequestMetadata(URI uri) voidgetRequestMetadata(URI uri, Executor executor, com.google.auth.RequestMetadataCallback callback) booleanbooleanvoidrefresh()voidupdateCredentials(com.google.auth.oauth2.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
public MutableCredentials(com.google.auth.oauth2.ServiceAccountCredentials credentials) Creates a MutableCredentials instance with default spanner scopes. -
MutableCredentials
-
-
Method Details
-
updateCredentials
public void updateCredentials(@Nonnull com.google.auth.oauth2.ServiceAccountCredentials credentials) 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 classcom.google.auth.Credentials
-
getRequestMetadata
- Specified by:
getRequestMetadatain classcom.google.auth.Credentials- Throws:
IOException
-
hasRequestMetadata
public boolean hasRequestMetadata()- Specified by:
hasRequestMetadatain classcom.google.auth.Credentials
-
hasRequestMetadataOnly
public boolean hasRequestMetadataOnly()- Specified by:
hasRequestMetadataOnlyin classcom.google.auth.Credentials
-
refresh
- Specified by:
refreshin classcom.google.auth.Credentials- Throws:
IOException
-
getRequestMetadata
public void getRequestMetadata(URI uri, Executor executor, com.google.auth.RequestMetadataCallback callback) - Overrides:
getRequestMetadatain classcom.google.auth.Credentials
-
getUniverseDomain
- Overrides:
getUniverseDomainin classcom.google.auth.Credentials- Throws:
IOException
-
getMetricsCredentialType
public com.google.auth.CredentialTypeForMetrics getMetricsCredentialType()- Overrides:
getMetricsCredentialTypein classcom.google.auth.Credentials
-