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, Serializable
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 GoogleCredentials
GoogleCredentials.BuilderNested classes/interfaces inherited from class OAuth2Credentials
OAuth2Credentials.AsyncRefreshResult, OAuth2Credentials.CacheState, OAuth2Credentials.CredentialsChangedListener, OAuth2Credentials.FutureCallbackToMetadataCallbackAdapter, OAuth2Credentials.OAuthValue, OAuth2Credentials.RefreshTask, OAuth2Credentials.RefreshTaskListenerNested classes/interfaces inherited from interface ServiceAccountSigner
ServiceAccountSigner.SigningException -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String(package private) static final String(package private) static final Stringprivate Objectprivate static final String(package private) static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate Methodprivate Methodprivate Methodprivate Methodprivate final Collection<String> private final booleanprivate static final longprivate static final Stringprivate Method(package private) static final StringFields inherited from class GoogleCredentials
GDCH_SERVICE_ACCOUNT_FILE_TYPE, QUOTA_PROJECT_ID_HEADER_KEY, quotaProjectId, SERVICE_ACCOUNT_FILE_TYPE, USER_FILE_TYPEFields inherited from class OAuth2Credentials
clock, DEFAULT_EXPIRATION_MARGIN, DEFAULT_REFRESH_MARGIN, lock, refreshTaskFields inherited from class Credentials
GOOGLE_DEFAULT_UNIVERSE -
Constructor Summary
ConstructorsConstructorDescriptionAppEngineCredentials(Collection<String> scopes, Collection<String> defaultScopes) AppEngineCredentials(Collection<String> scopes, Collection<String> defaultScopes, AppEngineCredentials unscoped) -
Method Summary
Modifier and TypeMethodDescriptioncreateScoped(Collection<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.createScoped(Collection<String> scopes, Collection<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.booleanIndicates whether the credentials require scopes to be specified via a call toGoogleCredentials.createScoped(Collection)before use.boolean(package private) Class<?> Returns the service account associated with the signer.inthashCode()private voidinit()private voidreadObject(ObjectInputStream input) 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.toString()Methods inherited from class GoogleCredentials
addQuotaProjectIdToRequestMetadata, create, create, createDelegated, createScoped, createWithCustomRetryStrategy, createWithQuotaProject, fromStream, fromStream, getAdditionalHeaders, getApplicationDefault, getApplicationDefault, getQuotaProjectId, getUniverseDomain, isDefaultUniverseDomain, isExplicitUniverseDomain, newBuilder, toBuilder, toStringHelperMethods inherited from class OAuth2Credentials
addChangeListener, getAccessToken, getAuthenticationType, getExpirationMargin, getFromServiceLoader, getRefreshMargin, getRequestMetadata, getRequestMetadata, getRequestMetadataInternal, hasRequestMetadata, hasRequestMetadataOnly, newInstance, refresh, refreshIfExpired, removeChangeListenerMethods inherited from class Credentials
blockingGetToCallback, getMetricsCredentialType, getRequestMetadata
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
APP_IDENTITY_SERVICE_FACTORY_CLASS
- See Also:
-
APP_IDENTITY_SERVICE_CLASS
- See Also:
-
GET_ACCESS_TOKEN_RESULT_CLASS
- See Also:
-
SIGNING_RESULT_CLASS
- See Also:
-
GET_APP_IDENTITY_SERVICE_METHOD
- See Also:
-
GET_ACCESS_TOKEN_RESULT_METHOD
- See Also:
-
GET_ACCESS_TOKEN_METHOD
- See Also:
-
GET_EXPIRATION_TIME_METHOD
- See Also:
-
GET_SERVICE_ACCOUNT_NAME_METHOD
- See Also:
-
SIGN_FOR_APP_METHOD
- See Also:
-
GET_SIGNATURE_METHOD
- See Also:
-
scopes
-
scopesRequired
private final boolean scopesRequired -
appIdentityService
-
getAccessToken
-
getAccessTokenResult
-
getExpirationTime
-
signForApp
-
getSignature
-
account
-
-
Constructor Details
-
AppEngineCredentials
AppEngineCredentials(Collection<String> scopes, Collection<String> defaultScopes) throws IOException - Throws:
IOException
-
AppEngineCredentials
AppEngineCredentials(Collection<String> scopes, Collection<String> defaultScopes, AppEngineCredentials unscoped)
-
-
Method Details
-
init
- Throws:
IOException
-
refreshAccessToken
Refresh the access token by getting it from the App Identity service.- Overrides:
refreshAccessTokenin classOAuth2Credentials- Returns:
- never
- Throws:
IOException
-
createScopedRequired
public boolean createScopedRequired()Description copied from class:GoogleCredentialsIndicates whether the credentials require scopes to be specified via a call toGoogleCredentials.createScoped(Collection)before use.- Overrides:
createScopedRequiredin classGoogleCredentials- Returns:
- Whether the credentials require scopes to be specified.
-
createScoped
Description copied from class:GoogleCredentialsIf 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:
createScopedin classGoogleCredentials- Parameters:
scopes- Collection of scopes to request.- Returns:
- GoogleCredentials with requested scopes.
-
createScoped
Description copied from class:GoogleCredentialsIf 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:
createScopedin classGoogleCredentials- Parameters:
scopes- Collection of scopes to request.defaultScopes- Collection of default scopes to request.- Returns:
- GoogleCredentials with requested scopes.
-
getAccount
Description copied from interface:ServiceAccountSignerReturns the service account associated with the signer.- Specified by:
getAccountin interfaceServiceAccountSigner- Returns:
- The service account associated with the signer.
-
sign
public byte[] sign(byte[] toSign) Description copied from interface:ServiceAccountSignerSigns the provided bytes using the private key associated with the service account.- Specified by:
signin interfaceServiceAccountSigner- Parameters:
toSign- bytes to sign- Returns:
- signed bytes
-
hashCode
public int hashCode()- Overrides:
hashCodein classGoogleCredentials
-
toString
- Overrides:
toStringin classGoogleCredentials
-
equals
- Overrides:
equalsin classGoogleCredentials
-
readObject
- Throws:
IOExceptionClassNotFoundException
-
forName
- Throws:
ClassNotFoundException
-