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.Stringaccount(package private) static java.lang.StringAPP_IDENTITY_SERVICE_CLASS(package private) static java.lang.StringAPP_IDENTITY_SERVICE_FACTORY_CLASSprivate java.lang.ObjectappIdentityServiceprivate static java.lang.StringGET_ACCESS_TOKEN_METHOD(package private) static java.lang.StringGET_ACCESS_TOKEN_RESULT_CLASSprivate static java.lang.StringGET_ACCESS_TOKEN_RESULT_METHODprivate static java.lang.StringGET_APP_IDENTITY_SERVICE_METHODprivate static java.lang.StringGET_EXPIRATION_TIME_METHODprivate static java.lang.StringGET_SERVICE_ACCOUNT_NAME_METHODprivate static java.lang.StringGET_SIGNATURE_METHODprivate java.lang.reflect.MethodgetAccessTokenprivate java.lang.reflect.MethodgetAccessTokenResultprivate java.lang.reflect.MethodgetExpirationTimeprivate java.lang.reflect.MethodgetSignatureprivate java.util.Collection<java.lang.String>scopesprivate booleanscopesRequiredprivate static longserialVersionUIDprivate static java.lang.StringSIGN_FOR_APP_METHODprivate java.lang.reflect.MethodsignForApp(package private) static java.lang.StringSIGNING_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 GoogleCredentialscreateScoped(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.GoogleCredentialscreateScoped(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.booleancreateScopedRequired()Indicates whether the credentials require scopes to be specified via a call toGoogleCredentials.createScoped(java.util.Collection<java.lang.String>)before use.booleanequals(java.lang.Object obj)(package private) java.lang.Class<?>forName(java.lang.String className)java.lang.StringgetAccount()Returns the service account associated with the signer.inthashCode()private voidinit()private voidreadObject(java.io.ObjectInputStream input)AccessTokenrefreshAccessToken()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.StringtoString()-
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:
refreshAccessTokenin classOAuth2Credentials- Returns:
- never
- Throws:
java.io.IOException
-
createScopedRequired
public boolean createScopedRequired()
Description copied from class:GoogleCredentialsIndicates whether the credentials require scopes to be specified via a call toGoogleCredentials.createScoped(java.util.Collection<java.lang.String>)before use.- Overrides:
createScopedRequiredin 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: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
public GoogleCredentials createScoped(java.util.Collection<java.lang.String> scopes, java.util.Collection<java.lang.String> defaultScopes)
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
public java.lang.String 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
public java.lang.String toString()
- Overrides:
toStringin classGoogleCredentials
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classGoogleCredentials
-
readObject
private void readObject(java.io.ObjectInputStream input) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
forName
java.lang.Class<?> forName(java.lang.String className) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
-