com.google.cloud.bigtable.config
Class CredentialFactory
- java.lang.Object
-
- com.google.cloud.bigtable.config.CredentialFactory
-
public class CredentialFactory extends Object
Simple factory for creating OAuth Credential objects for use with Bigtable.- Version:
- $Id: $Id
- Author:
- sduskis
-
-
Field Summary
Fields Modifier and Type Field and Description static String
CLOUD_BIGTABLE_ADMIN_SCOPE
The OAuth scope required to perform administrator actions such as creating tables.static List<String>
CLOUD_BIGTABLE_ALL_SCOPES
Scopes required for full access to cloud bigtable.static List<String>
CLOUD_BIGTABLE_READ_WRITE_SCOPES
Scopes required to read and write data from tables.static String
CLOUD_BIGTABLE_READER_SCOPE
The OAuth scope required to read data from tables.static String
CLOUD_BIGTABLE_WRITER_SCOPE
The OAuth scope required to write data to tables.
-
Constructor Summary
Constructors Constructor and Description CredentialFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static com.google.auth.Credentials
getApplicationDefaultCredential()
Initializes OAuth2 application default credentials based on the environment the code is running in.static com.google.auth.Credentials
getCredentialFromPrivateKeyServiceAccount(String serviceAccountEmail, String privateKeyFile)
Initializes OAuth2 credential from a private keyfile, as described in Service accounts.static com.google.auth.Credentials
getCredentialFromPrivateKeyServiceAccount(String serviceAccountEmail, String privateKeyFile, List<String> scopes)
Initializes OAuth2 credential from a private keyfile, as described in Service accounts.static com.google.auth.Credentials
getCredentials(CredentialOptions options)
Look up a Credentials object based on a configuration of credentials described in aCredentialOptions
.static com.google.auth.http.HttpTransportFactory
getHttpTransportFactory()
static com.google.auth.Credentials
getInputStreamCredential(InputStream inputStream)
Initializes OAuth2 application default credentials based on an inputStream.static void
setHttpTransportFactory(com.google.auth.http.HttpTransportFactory httpTransportFactory)
Allow for an override of the credentials HttpTransportFactory.
-
-
-
Field Detail
-
CLOUD_BIGTABLE_ADMIN_SCOPE
public static final String CLOUD_BIGTABLE_ADMIN_SCOPE
The OAuth scope required to perform administrator actions such as creating tables.- See Also:
- Constant Field Values
-
CLOUD_BIGTABLE_READER_SCOPE
public static final String CLOUD_BIGTABLE_READER_SCOPE
The OAuth scope required to read data from tables.- See Also:
- Constant Field Values
-
CLOUD_BIGTABLE_WRITER_SCOPE
public static final String CLOUD_BIGTABLE_WRITER_SCOPE
The OAuth scope required to write data to tables.- See Also:
- Constant Field Values
-
CLOUD_BIGTABLE_READ_WRITE_SCOPES
public static final List<String> CLOUD_BIGTABLE_READ_WRITE_SCOPES
Scopes required to read and write data from tables.
-
-
Method Detail
-
setHttpTransportFactory
public static void setHttpTransportFactory(com.google.auth.http.HttpTransportFactory httpTransportFactory)
Allow for an override of the credentials HttpTransportFactory.- Parameters:
httpTransportFactory
-
-
getHttpTransportFactory
public static com.google.auth.http.HttpTransportFactory getHttpTransportFactory()
-
getCredentials
public static com.google.auth.Credentials getCredentials(CredentialOptions options) throws IOException, GeneralSecurityException
Look up a Credentials object based on a configuration of credentials described in aCredentialOptions
.- Parameters:
options
- aCredentialOptions
object.- Returns:
- a
Credentials
object. - Throws:
IOException
- if any.GeneralSecurityException
- if any.
-
getCredentialFromPrivateKeyServiceAccount
public static com.google.auth.Credentials getCredentialFromPrivateKeyServiceAccount(String serviceAccountEmail, String privateKeyFile) throws IOException, GeneralSecurityException
Initializes OAuth2 credential from a private keyfile, as described in Service accounts.- Parameters:
serviceAccountEmail
- Email address of the service account associated with the keyfile.privateKeyFile
- Full local path to private keyfile.- Returns:
- a
Credentials
object. - Throws:
IOException
- if any.GeneralSecurityException
- if any.
-
getCredentialFromPrivateKeyServiceAccount
public static com.google.auth.Credentials getCredentialFromPrivateKeyServiceAccount(String serviceAccountEmail, String privateKeyFile, List<String> scopes) throws IOException, GeneralSecurityException
Initializes OAuth2 credential from a private keyfile, as described in Service accounts.- Parameters:
serviceAccountEmail
- Email address of the service account associated with the keyfile.privateKeyFile
- Full local path to private keyfile.scopes
- List of well-formed desired scopes to use with the credential.- Returns:
- a
Credentials
object. - Throws:
IOException
- if any.GeneralSecurityException
- if any.
-
getApplicationDefaultCredential
public static com.google.auth.Credentials getApplicationDefaultCredential() throws IOException
Initializes OAuth2 application default credentials based on the environment the code is running in. If a service account is to be used with JSON file, set the environment variable with name "GOOGLE_APPLICATION_CREDENTIALS" to the JSON file path. For more details on application default credentials: Application Default Credentials.- Returns:
- a
Credentials
object. - Throws:
IOException
- if any.
-
getInputStreamCredential
public static com.google.auth.Credentials getInputStreamCredential(InputStream inputStream) throws IOException
Initializes OAuth2 application default credentials based on an inputStream.- Parameters:
inputStream
- aInputStream
object.- Returns:
- a
Credentials
object. - Throws:
IOException
- if any.
-
-