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:
  • Constructor Details

    • MutableCredentials

      public MutableCredentials(com.google.auth.oauth2.ServiceAccountCredentials credentials)
      Creates a MutableCredentials instance with default spanner scopes.
    • MutableCredentials

      public MutableCredentials(@Nonnull com.google.auth.oauth2.ServiceAccountCredentials credentials, @Nonnull Set<String> scopes)
  • 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 ServiceAccountCredentials is scoped using the same scopes that were supplied when this MutableCredentials instance was created.

      Parameters:
      credentials - the new base service account credentials to scope and use for client authorization.
    • getAuthenticationType

      public String getAuthenticationType()
      Specified by:
      getAuthenticationType in class com.google.auth.Credentials
    • getRequestMetadata

      public Map<String,List<String>> getRequestMetadata(URI uri) throws IOException
      Specified by:
      getRequestMetadata in class com.google.auth.Credentials
      Throws:
      IOException
    • hasRequestMetadata

      public boolean hasRequestMetadata()
      Specified by:
      hasRequestMetadata in class com.google.auth.Credentials
    • hasRequestMetadataOnly

      public boolean hasRequestMetadataOnly()
      Specified by:
      hasRequestMetadataOnly in class com.google.auth.Credentials
    • refresh

      public void refresh() throws IOException
      Specified by:
      refresh in class com.google.auth.Credentials
      Throws:
      IOException
    • getRequestMetadata

      public void getRequestMetadata(URI uri, Executor executor, com.google.auth.RequestMetadataCallback callback)
      Overrides:
      getRequestMetadata in class com.google.auth.Credentials
    • getUniverseDomain

      public String getUniverseDomain() throws IOException
      Overrides:
      getUniverseDomain in class com.google.auth.Credentials
      Throws:
      IOException
    • getMetricsCredentialType

      public com.google.auth.CredentialTypeForMetrics getMetricsCredentialType()
      Overrides:
      getMetricsCredentialType in class com.google.auth.Credentials