Class GdchCredentials

All Implemented Interfaces:
QuotaProjectIdProvider, Serializable

public class GdchCredentials extends GoogleCredentials
See Also:
  • Method Details

    • fromStream

      public static GdchCredentials fromStream(InputStream credentialsStream) throws IOException
      Returns credentials defined by a GdchCredentials key file in JSON format from the Google Developers Console.

      Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to .

      Parameters:
      credentialsStream - the stream with the credential definition.
      Returns:
      the credential defined by the credentialsStream.
      Throws:
      IOException - if the credential cannot be created from the stream.
    • fromStream

      public static GdchCredentials fromStream(InputStream credentialsStream, HttpTransportFactory transportFactory) throws IOException
      Returns credentials defined by a GdchCredentials key file in JSON format from the Google Developers Console.

      Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to .

      Parameters:
      credentialsStream - the stream with the credential definition.
      transportFactory - HTTP transport factory, creates the transport used to get access tokens.
      Returns:
      the credential defined by the credentialsStream.
      Throws:
      IOException - if the credential cannot be created from the stream.
    • createWithGdchAudience

      @ObsoleteApi("Use createWithGdchAudience(String) instead.") public GdchCredentials createWithGdchAudience(URI apiAudience)
      This method is obsolete. Please use createWithGdchAudience(String)} instead. Create a copy of GDCH credentials with the specified audience.
      Parameters:
      apiAudience - The intended audience for GDCH credentials.
    • createWithGdchAudience

      public GdchCredentials createWithGdchAudience(String apiAudience)
      Create a copy of GDCH credentials with the specified audience.
      Parameters:
      apiAudience - The intended audience for GDCH credentials.
    • refreshAccessToken

      public AccessToken refreshAccessToken() throws IOException
      Refresh the OAuth2 access token by getting a new access token using a JSON Web Token (JWT).

      For GDCH credentials, this class creates a self-signed JWT, and sends to the GDCH authentication endpoint (tokenServerUri) to exchange an access token for the intended api audience (apiAudience).

      Overrides:
      refreshAccessToken in class OAuth2Credentials
      Returns:
      never
      Throws:
      IOException
    • getProjectId

      public final String getProjectId()
      Description copied from class: GoogleCredentials
      The projectId value for a Credential type. Since not all GoogleCredentials subclass have a projectId associated, the projectId may be null. A subset of GoogleCredentials subclasses will override to return their projectId.
      Overrides:
      getProjectId in class GoogleCredentials
      Returns:
      the projectId set in the GDCH SA Key file or the user set projectId
    • getPrivateKeyId

      public final String getPrivateKeyId()
    • getPrivateKey

      public final PrivateKey getPrivateKey()
    • getServiceIdentityName

      public final String getServiceIdentityName()
    • getTokenServerUri

      public final URI getTokenServerUri()
    • getGdchAudience

      public final String getGdchAudience()
      Returns the underlying audience string set for this credentials object.
      Returns:
      the audience string, or null if no audience has been set.
    • getApiAudience

      @ObsoleteApi("Use getGdchAudience() instead.") public final URI getApiAudience()
      NOTE: This method is obsolete, please use getGdchAudience() instead. Returns a URI representation of the underlying audience string set for this credentials object. This method may fail if the underlying audience string does not conform to a URI format.
      Returns:
      a URI object representing the audience of the credentials, or null if no audience has been set or if the audience string is not a valid URI.
    • getTransportFactory

      public final HttpTransportFactory getTransportFactory()
    • getCaCertPath

      public final String getCaCertPath()
    • newBuilder

      public static GdchCredentials.Builder newBuilder()
    • toBuilder

      public GdchCredentials.Builder toBuilder()
      Overrides:
      toBuilder in class GoogleCredentials
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class GoogleCredentials
    • toString

      public String toString()
      Description copied from class: OAuth2Credentials
      Returns a string representation of this credential, including request metadata and access token.

      Security Warning: The output of this method includes the request metadata which contains the raw Bearer access token, and the raw access token value. Do not log this output in production environments as it may expose sensitive credentials.

      Overrides:
      toString in class GoogleCredentials
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class GoogleCredentials