public class IdentityManager
extends java.lang.Object
// Create IdentityManager and set it as the default instance.
IdentityManager idm = new IdentityManager(getApplicationContext(),
new AWSConfiguration(getApplicationContext()));
IdentityManager.setDefaultIdentityManager(idm);
// Use IdentityManager to retrieve the CognitoCachingCredentialsProvider
// object.
IdentityManager.getDefaultIdentityManager().getUnderlyingProvider();
Constructor and Description |
---|
IdentityManager(android.content.Context context)
Constructor that takes in the application context.
|
IdentityManager(android.content.Context context,
AWSConfiguration awsConfiguration)
Constructor.
|
IdentityManager(android.content.Context context,
AWSConfiguration awsConfiguration,
ClientConfiguration clientConfiguration)
Constructor.
|
IdentityManager(android.content.Context context,
CognitoCachingCredentialsProvider credentialsProvider,
ClientConfiguration clientConfiguration)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addSignInProvider(java.lang.Class<? extends SignInProvider> providerClass)
Add a supported identity provider to your app.
|
void |
addSignInStateChangeListener(SignInStateChangeListener listener)
Add a listener to receive callbacks when sign-in or sign-out occur.
|
boolean |
areCredentialsExpired()
Check if the short-lived AWS Credentials are expired.
|
void |
doStartupAuth(android.app.Activity callingActivity,
StartupAuthResultHandler startupAuthResultHandler)
Deprecated.
Please use
resumeSession(Activity, StartupAuthResultHandler) method instead. |
void |
doStartupAuth(android.app.Activity callingActivity,
StartupAuthResultHandler startupAuthResultHandler,
long minimumDelay)
Deprecated.
Please use
resumeSession(Activity, StartupAuthResultHandler, long) method instead. |
void |
enableFederation(boolean enabled)
Set the flag that indicates if tokens will be
federated into Cognito Identity pool
|
void |
expireSignInTimeout()
Call this to ignore waiting for the remaining timeout delay.
|
void |
federateWithProvider(IdentityProvider provider)
Fetch the token from the SignIn provider and insert into the loginMap
and then invoke
refreshCredentialWithLogins(Map) to set the
loginsMap with the CredentialsProvider object in-order to federate
the token with Amazon Cognito Federated Identities. |
java.lang.String |
getCachedUserID()
Gets the cached unique identifier for the user.
|
AWSConfiguration |
getConfiguration()
Retrieve the AWSConfiguration object that represents the `awsconfiguration.json`.
|
AWSCredentialsProvider |
getCredentialsProvider()
Retrieve the reference to AWSCredentialsProvider object.
|
IdentityProvider |
getCurrentIdentityProvider()
Gets the current provider.
|
static IdentityManager |
getDefaultIdentityManager()
Return the default instance of the IdentityManager
|
com.amazonaws.mobile.auth.core.IdentityManager.SignInProviderResultAdapter |
getResultsAdapter()
Call getResultsAdapter to get the IdentityManager's handler that adapts results before
sending them back to the handler set by
setProviderResultsHandler(SignInProviderResultHandler) |
java.util.Collection<java.lang.Class<? extends SignInProvider>> |
getSignInProviderClasses()
Gets the list of SignInProvider classes
|
CognitoCachingCredentialsProvider |
getUnderlyingProvider()
Retrieve the reference to CognitoCachingCredentialsProvider object.
|
void |
getUserID(IdentityHandler handler)
Gets the user's unique identifier.
|
boolean |
isUserSignedIn()
Check if user is signed in.
|
void |
login(android.content.Context context,
SignInResultHandler signInResultHandler)
Call login to initiate sign-in with a provider.
|
void |
removeSignInStateChangeListener(SignInStateChangeListener listener)
Remove a listener from receiving callbacks when sign-in or sign-out occur.
|
void |
resumeSession(android.app.Activity callingActivity,
StartupAuthResultHandler startupAuthResultHandler)
This should be called from your app's splash activity upon start-up.
|
void |
resumeSession(android.app.Activity callingActivity,
StartupAuthResultHandler startupAuthResultHandler,
long minimumDelay)
This should be called from your app's activity upon start-up.
|
void |
setConfiguration(AWSConfiguration configuration)
Set the AWSConfiguration.
|
static void |
setDefaultIdentityManager(IdentityManager identityManager)
Set the IdentityManager object passed in as the default instance
|
void |
setPersistenceEnabled(boolean persistenceEnabled)
Set the flag that indicates if persistence is enabled or not.
|
void |
setProviderResultsHandler(SignInProviderResultHandler signInProviderResultHandler)
Set the results handler that will be used for results when calling federateWithProvider.
|
void |
setUpToAuthenticate(android.content.Context context,
SignInResultHandler signInResultHandler)
Deprecated.
Please use
login(Context, SignInResultHandler) method instead. |
void |
signOut()
Sign out of the current identity provider, and clear Cognito credentials.
|
public IdentityManager(android.content.Context context)
context
- the application context.public IdentityManager(android.content.Context context, AWSConfiguration awsConfiguration)
context
- the application context.awsConfiguration
- the aws configuration.public IdentityManager(android.content.Context context, AWSConfiguration awsConfiguration, ClientConfiguration clientConfiguration)
context
- the application context.awsConfiguration
- the aws configuration.clientConfiguration
- the client configuration options such as retries and timeouts.public IdentityManager(android.content.Context context, CognitoCachingCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration)
context
- application contextcredentialsProvider
- credentials provider to talk with Cognito IdentityclientConfiguration
- the client configuration options such as retries and timeoutspublic void setPersistenceEnabled(boolean persistenceEnabled)
persistenceEnabled
- the flag that indicates if persistence is enabled or not.public void enableFederation(boolean enabled)
enabled
- Flag that indicates if tokens will
be federated into Cognito Identity poolpublic static IdentityManager getDefaultIdentityManager()
public static void setDefaultIdentityManager(IdentityManager identityManager)
identityManager
- The IdentityManager object to be set as the defaultpublic AWSConfiguration getConfiguration()
public void setConfiguration(AWSConfiguration configuration)
configuration
- public boolean areCredentialsExpired()
public AWSCredentialsProvider getCredentialsProvider()
public CognitoCachingCredentialsProvider getUnderlyingProvider()
public java.lang.String getCachedUserID()
public void getUserID(IdentityHandler handler)
handler
- handles the unique identifier for the userpublic void addSignInStateChangeListener(SignInStateChangeListener listener)
listener
- the sign-in state change listener.public void removeSignInStateChangeListener(SignInStateChangeListener listener)
listener
- the sign-in state change listener.public com.amazonaws.mobile.auth.core.IdentityManager.SignInProviderResultAdapter getResultsAdapter()
setProviderResultsHandler(SignInProviderResultHandler)
public void signOut()
getUserID(IdentityHandler)
.public void setProviderResultsHandler(SignInProviderResultHandler signInProviderResultHandler)
signInProviderResultHandler
- the results handler.public void federateWithProvider(IdentityProvider provider)
refreshCredentialWithLogins(Map)
to set the
loginsMap with the CredentialsProvider object in-order to federate
the token with Amazon Cognito Federated Identities.provider
- A sign-in provider.public IdentityProvider getCurrentIdentityProvider()
public void addSignInProvider(java.lang.Class<? extends SignInProvider> providerClass)
providerClass
- the provider class for the identity provider.public java.util.Collection<java.lang.Class<? extends SignInProvider>> getSignInProviderClasses()
public boolean isUserSignedIn()
public void resumeSession(android.app.Activity callingActivity, StartupAuthResultHandler startupAuthResultHandler, long minimumDelay)
callingActivity
- the calling activity.startupAuthResultHandler
- a handler for returning results.minimumDelay
- the minimum delay to wait before returning the sign-in result.public void resumeSession(android.app.Activity callingActivity, StartupAuthResultHandler startupAuthResultHandler)
callingActivity
- the calling activity.startupAuthResultHandler
- a handler for returning results.@Deprecated public void doStartupAuth(android.app.Activity callingActivity, StartupAuthResultHandler startupAuthResultHandler)
resumeSession(Activity, StartupAuthResultHandler)
method instead.callingActivity
- the calling activity.startupAuthResultHandler
- a handler for returning results.@Deprecated public void doStartupAuth(android.app.Activity callingActivity, StartupAuthResultHandler startupAuthResultHandler, long minimumDelay)
resumeSession(Activity, StartupAuthResultHandler, long)
method instead.callingActivity
- the calling activity.startupAuthResultHandler
- a handler for returning results.public void expireSignInTimeout()
@Deprecated public void setUpToAuthenticate(android.content.Context context, SignInResultHandler signInResultHandler)
login(Context, SignInResultHandler)
method instead.context
- context.signInResultHandler
- the results handler.public void login(android.content.Context context, SignInResultHandler signInResultHandler)
context
- context.signInResultHandler
- the results handler.Copyright © 2018 Amazon Web Services, Inc. All Rights Reserved.