Package com.google.auth.oauth2
Class AppEngineCredentials
- java.lang.Object
-
- com.google.auth.Credentials
-
- com.google.auth.oauth2.OAuth2Credentials
-
- com.google.auth.oauth2.GoogleCredentials
-
- com.google.auth.oauth2.AppEngineCredentials
-
- All Implemented Interfaces:
QuotaProjectIdProvider
,ServiceAccountSigner
,java.io.Serializable
class AppEngineCredentials extends GoogleCredentials implements ServiceAccountSigner
OAuth2 credentials representing the built-in service account for Google App Engine.Instances of this class use reflection to access AppIdentityService in AppEngine SDK.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.auth.oauth2.GoogleCredentials
GoogleCredentials.Builder
-
Nested classes/interfaces inherited from class com.google.auth.oauth2.OAuth2Credentials
OAuth2Credentials.AsyncRefreshResult, OAuth2Credentials.CacheState, OAuth2Credentials.CredentialsChangedListener, OAuth2Credentials.FutureCallbackToMetadataCallbackAdapter, OAuth2Credentials.OAuthValue, OAuth2Credentials.RefreshTask, OAuth2Credentials.RefreshTaskListener
-
Nested classes/interfaces inherited from interface com.google.auth.ServiceAccountSigner
ServiceAccountSigner.SigningException
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
account
(package private) static java.lang.String
APP_IDENTITY_SERVICE_CLASS
(package private) static java.lang.String
APP_IDENTITY_SERVICE_FACTORY_CLASS
private java.lang.Object
appIdentityService
private static java.lang.String
GET_ACCESS_TOKEN_METHOD
(package private) static java.lang.String
GET_ACCESS_TOKEN_RESULT_CLASS
private static java.lang.String
GET_ACCESS_TOKEN_RESULT_METHOD
private static java.lang.String
GET_APP_IDENTITY_SERVICE_METHOD
private static java.lang.String
GET_EXPIRATION_TIME_METHOD
private static java.lang.String
GET_SERVICE_ACCOUNT_NAME_METHOD
private static java.lang.String
GET_SIGNATURE_METHOD
private java.lang.reflect.Method
getAccessToken
private java.lang.reflect.Method
getAccessTokenResult
private java.lang.reflect.Method
getExpirationTime
private java.lang.reflect.Method
getSignature
private java.util.Collection<java.lang.String>
scopes
private boolean
scopesRequired
private static long
serialVersionUID
private static java.lang.String
SIGN_FOR_APP_METHOD
private java.lang.reflect.Method
signForApp
(package private) static java.lang.String
SIGNING_RESULT_CLASS
-
Fields inherited from class com.google.auth.oauth2.GoogleCredentials
GDCH_SERVICE_ACCOUNT_FILE_TYPE, QUOTA_PROJECT_ID_HEADER_KEY, quotaProjectId, SERVICE_ACCOUNT_FILE_TYPE, USER_FILE_TYPE
-
Fields inherited from class com.google.auth.oauth2.OAuth2Credentials
clock, DEFAULT_EXPIRATION_MARGIN, DEFAULT_REFRESH_MARGIN, lock, refreshTask
-
Fields inherited from class com.google.auth.Credentials
GOOGLE_DEFAULT_UNIVERSE
-
-
Constructor Summary
Constructors Constructor Description AppEngineCredentials(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes)
AppEngineCredentials(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes, AppEngineCredentials unscoped)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GoogleCredentials
createScoped(java.util.Collection<java.lang.String> scopes)
If the credentials support scopes, creates a copy of the identity with the specified scopes, invalidates the existing scoped access token; otherwise, return the same instance.GoogleCredentials
createScoped(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes)
If the credentials support scopes, creates a copy of the identity with the specified scopes and default scopes; otherwise, returns the same instance.boolean
createScopedRequired()
Indicates whether the credentials require scopes to be specified via a call toGoogleCredentials.createScoped(java.util.Collection<java.lang.String>)
before use.boolean
equals(java.lang.Object obj)
(package private) java.lang.Class<?>
forName(java.lang.String className)
java.lang.String
getAccount()
Returns the service account associated with the signer.int
hashCode()
private void
init()
private void
readObject(java.io.ObjectInputStream input)
AccessToken
refreshAccessToken()
Refresh the access token by getting it from the App Identity service.byte[]
sign(byte[] toSign)
Signs the provided bytes using the private key associated with the service account.java.lang.String
toString()
-
Methods inherited from class com.google.auth.oauth2.GoogleCredentials
addQuotaProjectIdToRequestMetadata, create, create, createDelegated, createScoped, createWithCustomRetryStrategy, createWithQuotaProject, fromStream, fromStream, getAdditionalHeaders, getApplicationDefault, getApplicationDefault, getQuotaProjectId, getUniverseDomain, isDefaultUniverseDomain, isExplicitUniverseDomain, newBuilder, toBuilder, toStringHelper
-
Methods inherited from class com.google.auth.oauth2.OAuth2Credentials
addChangeListener, getAccessToken, getAuthenticationType, getExpirationMargin, getFromServiceLoader, getRefreshMargin, getRequestMetadata, getRequestMetadata, getRequestMetadataInternal, hasRequestMetadata, hasRequestMetadataOnly, newInstance, refresh, refreshIfExpired, removeChangeListener
-
Methods inherited from class com.google.auth.Credentials
blockingGetToCallback, getMetricsCredentialType, getRequestMetadata
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
APP_IDENTITY_SERVICE_FACTORY_CLASS
static final java.lang.String APP_IDENTITY_SERVICE_FACTORY_CLASS
- See Also:
- Constant Field Values
-
APP_IDENTITY_SERVICE_CLASS
static final java.lang.String APP_IDENTITY_SERVICE_CLASS
- See Also:
- Constant Field Values
-
GET_ACCESS_TOKEN_RESULT_CLASS
static final java.lang.String GET_ACCESS_TOKEN_RESULT_CLASS
- See Also:
- Constant Field Values
-
SIGNING_RESULT_CLASS
static final java.lang.String SIGNING_RESULT_CLASS
- See Also:
- Constant Field Values
-
GET_APP_IDENTITY_SERVICE_METHOD
private static final java.lang.String GET_APP_IDENTITY_SERVICE_METHOD
- See Also:
- Constant Field Values
-
GET_ACCESS_TOKEN_RESULT_METHOD
private static final java.lang.String GET_ACCESS_TOKEN_RESULT_METHOD
- See Also:
- Constant Field Values
-
GET_ACCESS_TOKEN_METHOD
private static final java.lang.String GET_ACCESS_TOKEN_METHOD
- See Also:
- Constant Field Values
-
GET_EXPIRATION_TIME_METHOD
private static final java.lang.String GET_EXPIRATION_TIME_METHOD
- See Also:
- Constant Field Values
-
GET_SERVICE_ACCOUNT_NAME_METHOD
private static final java.lang.String GET_SERVICE_ACCOUNT_NAME_METHOD
- See Also:
- Constant Field Values
-
SIGN_FOR_APP_METHOD
private static final java.lang.String SIGN_FOR_APP_METHOD
- See Also:
- Constant Field Values
-
GET_SIGNATURE_METHOD
private static final java.lang.String GET_SIGNATURE_METHOD
- See Also:
- Constant Field Values
-
scopes
private final java.util.Collection<java.lang.String> scopes
-
scopesRequired
private final boolean scopesRequired
-
appIdentityService
private transient java.lang.Object appIdentityService
-
getAccessToken
private transient java.lang.reflect.Method getAccessToken
-
getAccessTokenResult
private transient java.lang.reflect.Method getAccessTokenResult
-
getExpirationTime
private transient java.lang.reflect.Method getExpirationTime
-
signForApp
private transient java.lang.reflect.Method signForApp
-
getSignature
private transient java.lang.reflect.Method getSignature
-
account
private transient java.lang.String account
-
-
Constructor Detail
-
AppEngineCredentials
AppEngineCredentials(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes) throws java.io.IOException
- Throws:
java.io.IOException
-
AppEngineCredentials
AppEngineCredentials(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes, AppEngineCredentials unscoped)
-
-
Method Detail
-
init
private void init() throws java.io.IOException
- Throws:
java.io.IOException
-
refreshAccessToken
public AccessToken refreshAccessToken() throws java.io.IOException
Refresh the access token by getting it from the App Identity service.- Overrides:
refreshAccessToken
in classOAuth2Credentials
- Returns:
- never
- Throws:
java.io.IOException
-
createScopedRequired
public boolean createScopedRequired()
Description copied from class:GoogleCredentials
Indicates whether the credentials require scopes to be specified via a call toGoogleCredentials.createScoped(java.util.Collection<java.lang.String>)
before use.- Overrides:
createScopedRequired
in classGoogleCredentials
- Returns:
- Whether the credentials require scopes to be specified.
-
createScoped
public GoogleCredentials createScoped(java.util.Collection<java.lang.String> scopes)
Description copied from class:GoogleCredentials
If the credentials support scopes, creates a copy of the identity with the specified scopes, invalidates the existing scoped access token; otherwise, return the same instance.- Overrides:
createScoped
in classGoogleCredentials
- Parameters:
scopes
- Collection of scopes to request.- Returns:
- GoogleCredentials with requested scopes.
-
createScoped
public GoogleCredentials createScoped(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes)
Description copied from class:GoogleCredentials
If the credentials support scopes, creates a copy of the identity with the specified scopes and default scopes; otherwise, returns the same instance. This is mainly used by client libraries.- Overrides:
createScoped
in classGoogleCredentials
- Parameters:
scopes
- Collection of scopes to request.defaultScopes
- Collection of default scopes to request.- Returns:
- GoogleCredentials with requested scopes.
-
getAccount
public java.lang.String getAccount()
Description copied from interface:ServiceAccountSigner
Returns the service account associated with the signer.- Specified by:
getAccount
in interfaceServiceAccountSigner
- Returns:
- The service account associated with the signer.
-
sign
public byte[] sign(byte[] toSign)
Description copied from interface:ServiceAccountSigner
Signs the provided bytes using the private key associated with the service account.- Specified by:
sign
in interfaceServiceAccountSigner
- Parameters:
toSign
- bytes to sign- Returns:
- signed bytes
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classGoogleCredentials
-
toString
public java.lang.String toString()
- Overrides:
toString
in classGoogleCredentials
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classGoogleCredentials
-
readObject
private void readObject(java.io.ObjectInputStream input) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
forName
java.lang.Class<?> forName(java.lang.String className) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
-