com.google.cloud.bigtable.config
Class CredentialOptions
- java.lang.Object
-
- com.google.cloud.bigtable.config.CredentialOptions
-
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- CredentialOptions.JsonCredentialsOptions, CredentialOptions.P12CredentialOptions, CredentialOptions.UserSuppliedCredentialOptions
public class CredentialOptions extends Object implements Serializable
This class encapsulates the method the Cloud Bigtable client should use to look upCredentials
. Here are the credential types supported:- DefaultCredentials - Initializes OAuth2 credential using preconfigured ServiceAccount settings on the local Google Compute Engine instance or GOOGLE_APPLICATION_CREDENTIALS environment variable or gcloud configured security. See: Creating and Enabling Service Accounts for Instances and Application Default Credentials.
- P12 - Initializes OAuth2 credential from a private keyfile, as described in Service accounts.
- UserSupplied - User supplies a fully formed Credentials.
- None - used for unit testing
- Version:
- $Id: $Id
- Author:
- sduskis
- See Also:
CredentialFactory for more details on how CredentialOptions are used to create a {@link com.google.auth.Credentials}.
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
CredentialOptions.CredentialType
static class
CredentialOptions.JsonCredentialsOptions
A CredentialOption that has a json credentials configured as an InputStream instead of a system environment property.static class
CredentialOptions.P12CredentialOptions
A CredentialOptions defined by a serviceAccount and a p12 key file.static class
CredentialOptions.UserSuppliedCredentialOptions
A CredentialOption that supplies the Credentials directly.
-
Field Summary
Fields Modifier and Type Field and Description protected static Logger
LOG
ConstantLOG
static String
SERVICE_ACCOUNT_JSON_ENV_VARIABLE
ConstantSERVICE_ACCOUNT_JSON_ENV_VARIABLE="GOOGLE_APPLICATION_CREDENTIALS"
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static CredentialOptions
credential(com.google.auth.Credentials credentials)
A CredentialOption that wraps an existingCredentials
object.static CredentialOptions
defaultCredentials()
Use the Application Default Credentials which are credentials that identify and authorize the whole application.boolean
equals(Object obj)
CredentialOptions.CredentialType
getCredentialType()
Getter for the fieldcredentialType
.static String
getEnvJsonFile()
Get a configured json credentials file from the GOOGLE_APPLICATION_CREDENTIALS environment variable.static CredentialOptions
jsonCredentials(InputStream jsonInputStream)
jsonCredentials.static CredentialOptions
jsonCredentials(String jsonString)
jsonCredentials.static CredentialOptions
nullCredential()
No credentials - used for unit testing.static CredentialOptions
p12Credential(String serviceAccount, String keyFile)
Initializes OAuth2 credential from a private keyfile, as described in Service accounts.
-
-
-
Field Detail
-
SERVICE_ACCOUNT_JSON_ENV_VARIABLE
public static final String SERVICE_ACCOUNT_JSON_ENV_VARIABLE
ConstantSERVICE_ACCOUNT_JSON_ENV_VARIABLE="GOOGLE_APPLICATION_CREDENTIALS"
- See Also:
- Constant Field Values
-
LOG
protected static final Logger LOG
ConstantLOG
-
-
Method Detail
-
jsonCredentials
public static CredentialOptions jsonCredentials(InputStream jsonInputStream)
jsonCredentials.- Parameters:
jsonInputStream
- aInputStream
object.- Returns:
- a
CredentialOptions
object.
-
jsonCredentials
public static CredentialOptions jsonCredentials(String jsonString)
jsonCredentials.- Parameters:
jsonString
- aString
object.- Returns:
- a
CredentialOptions
object.
-
getEnvJsonFile
public static String getEnvJsonFile()
Get a configured json credentials file from the GOOGLE_APPLICATION_CREDENTIALS environment variable.- Returns:
- a
String
object.
-
defaultCredentials
public static CredentialOptions defaultCredentials()
Use the Application Default Credentials which are credentials that identify and authorize the whole application. This is the built-in service account if running on Google Compute Engine. Alternatively, the credentials file from the path in the environment variable GOOGLE_APPLICATION_CREDENTIAL. If GOOGLE_APPLICATION_CREDENTIAL is not set, look at the gcloud/application_default_credentials.json file in the (User)/APPDATA/ directory on Windows or ~/.config/ directory on other OSs . Initializes OAuth2 credential using preconfigured ServiceAccount settings on the local Google Compute Engine VM. See: Creating and Enabling Service Accounts for Instances.- Returns:
- a
CredentialOptions
object.
-
p12Credential
public static CredentialOptions p12Credential(String serviceAccount, String keyFile)
Initializes OAuth2 credential from a private keyfile, as described in Service accounts.- Parameters:
serviceAccount
- aString
object.keyFile
- aString
object.- Returns:
- a
CredentialOptions
object.
-
credential
public static CredentialOptions credential(com.google.auth.Credentials credentials)
A CredentialOption that wraps an existingCredentials
object.- Parameters:
credentials
- aCredentials
object.- Returns:
- a
CredentialOptions
object.
-
nullCredential
public static CredentialOptions nullCredential()
No credentials - used for unit testing.- Returns:
- a
CredentialOptions
object.
-
getCredentialType
public CredentialOptions.CredentialType getCredentialType()
Getter for the fieldcredentialType
.- Returns:
- a
CredentialOptions.CredentialType
object.
-
-