|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.amazonaws.auth.CognitoCredentialsProvider
com.amazonaws.auth.CognitoCachingCredentialsProvider
public class CognitoCachingCredentialsProvider
This credentials provider is intended for Android applications. It offers the
ability to persist the Cognito identity id in SharedPreferences
.
Furthermore, it caches session credentials so as to reduce the number of
network requests. This is the provider to use with a custom identity
provider, which should be an extension of AWSAbstractCognitoIdentityProvider.
This will consume an identity provider, as well. If one is passed in to a
constructor, then that one is the one that is consumed, but if not/a
constructor that doesn't take an identity provider is used, then the Cognito
identity provider is used by default.
// initiate a credentials provider CognitoCachingCredentialsProvider provider = new CognitoCachingCredentialsProvider( context, "awsAccountId", "identityPoolId", "unauthRoleArn", "authRoleArn", Regions.US_EAST_1); // use the provider to instantiate an AWS client AmazonSNS snsClient = new AmazonSNSClient(provider); // If the user is authenticated through login with Amazon, you can set the map // of token to the provider Map<String, String> logins = new HashMap<String, String>(); logins.put(""www.amazon.com", "login with Amazon token"); provider.setLogins(logins); // Note: Please reuse the provider when possible.
Field Summary |
---|
Fields inherited from class com.amazonaws.auth.CognitoCredentialsProvider |
---|
DEFAULT_DURATION_SECONDS, DEFAULT_THRESHOLD_SECONDS |
Constructor Summary | |
---|---|
CognitoCachingCredentialsProvider(android.content.Context context,
AWSCognitoIdentityProvider provider,
java.lang.String unauthRoleArn,
java.lang.String authRoleArn)
Constructs a new CognitoCachingCredentialsProvider , which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. |
|
CognitoCachingCredentialsProvider(android.content.Context context,
AWSCognitoIdentityProvider provider,
java.lang.String unauthRoleArn,
java.lang.String authRoleArn,
AWSSecurityTokenService sts)
Constructs a new CognitoCachingCredentialsProvider , which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. |
|
CognitoCachingCredentialsProvider(android.content.Context context,
java.lang.String accountId,
java.lang.String identityPoolId,
java.lang.String unauthRoleArn,
java.lang.String authRoleArn,
AmazonCognitoIdentityClient cib,
AWSSecurityTokenService sts)
Constructs a new CognitoCachingCredentialsProvider , which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. |
|
CognitoCachingCredentialsProvider(android.content.Context context,
java.lang.String accountId,
java.lang.String identityPoolId,
java.lang.String unauthRoleArn,
java.lang.String authRoleArn,
Regions region)
Constructs a new CognitoCachingCredentialsProvider , which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. |
|
CognitoCachingCredentialsProvider(android.content.Context context,
java.lang.String accountId,
java.lang.String identityPoolId,
java.lang.String unauthRoleArn,
java.lang.String authRoleArn,
Regions region,
ClientConfiguration clientConfiguration)
Constructs a new CognitoCachingCredentialsProvider , which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. |
Method Summary | |
---|---|
void |
clear()
Clear all in-memory and saved state for the credentials provider. |
void |
clearCredentials()
Clear credentials. |
java.lang.String |
getCachedIdentityId()
Gets the cached identity id without making a network request. |
AWSSessionCredentials |
getCredentials()
If the current session has expired/credentials are invalid, a new session is started, establishing the credentials. |
java.lang.String |
getIdentityId()
Gets the Cognito identity id of the user. |
void |
setLogins(java.util.Map<java.lang.String,java.lang.String> logins)
Set the logins map used to authenticated with Amazon Cognito. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CognitoCachingCredentialsProvider(android.content.Context context, java.lang.String accountId, java.lang.String identityPoolId, java.lang.String unauthRoleArn, java.lang.String authRoleArn, Regions region)
CognitoCachingCredentialsProvider
, which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. By default, this will utilize a Cognito
identity provider.
context
- The context to be used for the cachingaccountId
- The AWS accountId for the account with Amazon CognitoidentityPoolId
- The Amazon Cogntio identity pool to useunauthRoleArn
- The ARN of the IAM Role that will be assumed when
unauthenticatedauthRoleArn
- The ARN of the IAM Role that will be assumed when
authenticatedregion
- The region to use when contacting Cognito Identity, and STS
(if STS supports the provided regions, otherwise STS will be
contacted using the US_EAST_1 region)public CognitoCachingCredentialsProvider(android.content.Context context, java.lang.String accountId, java.lang.String identityPoolId, java.lang.String unauthRoleArn, java.lang.String authRoleArn, Regions region, ClientConfiguration clientConfiguration)
CognitoCachingCredentialsProvider
, which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. By default, this will utilize a Cognito
identity provider.
context
- The context to be used for the cachingaccountId
- The AWS accountId for the account with Amazon CognitoidentityPoolId
- The Amazon Cogntio identity pool to useunauthRoleArn
- The ARN of the IAM Role that will be assumed when
unauthenticatedauthRoleArn
- The ARN of the IAM Role that will be assumed when
authenticatedclientConfiguration
- Configuration to apply to service clients
createdregion
- The region to use when contacting Cognito Identity, and STS
(if STS supports the provided regions, otherwise STS will be
contacted using the US_EAST_1 region)public CognitoCachingCredentialsProvider(android.content.Context context, java.lang.String accountId, java.lang.String identityPoolId, java.lang.String unauthRoleArn, java.lang.String authRoleArn, AmazonCognitoIdentityClient cib, AWSSecurityTokenService sts)
CognitoCachingCredentialsProvider
, which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. By default, this will utilize a Cognito
identity provider.
context
- The context to be used for the cachingaccountId
- The AWS accountId for the account with Amazon CognitoidentityPoolId
- The Amazon Cogntio identity pool to useunauthRoleArn
- The ARN of the IAM Role that will be assumed when
unauthenticatedauthRoleArn
- The ARN of the IAM Role that will be assumed when
authenticatedcibClient
- Preconfigured CognitoIdentity client to make requests
withstsClient
- Preconfigured STS client to make requests withpublic CognitoCachingCredentialsProvider(android.content.Context context, AWSCognitoIdentityProvider provider, java.lang.String unauthRoleArn, java.lang.String authRoleArn, AWSSecurityTokenService sts)
CognitoCachingCredentialsProvider
, which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. This is to be used with a custom identity
provider
context
- The context to be used for the cachingprovider
- The identity provider to be consumed by the credentials
providerunauthRoleArn
- The ARN of the IAM Role that will be assumed when
unauthenticatedauthRoleArn
- The ARN of the IAM Role that will be assumed when
authenticatedstsClient
- Preconfigured STS client to make requests withpublic CognitoCachingCredentialsProvider(android.content.Context context, AWSCognitoIdentityProvider provider, java.lang.String unauthRoleArn, java.lang.String authRoleArn)
CognitoCachingCredentialsProvider
, which will
use the specified Amazon Cognito identity pool and account id to make a
request to the AWS Security Token Service (STS), as well as various other
tasks to handle the lifecycle. This is to be used with a custom identity
provider
context
- The context to be used for the cachingprovider
- The identity provider to be consumed by the credentials
providerunauthRoleArn
- The ARN of the IAM Role that will be assumed when
unauthenticatedauthRoleArn
- The ARN of the IAM Role that will be assumed when
authenticatedMethod Detail |
---|
public java.lang.String getIdentityId()
SharedPreferences
. Please don't call it
in the main thread.
getIdentityId
in class CognitoCredentialsProvider
public AWSSessionCredentials getCredentials()
CognitoCredentialsProvider
getCredentials
in interface AWSCredentialsProvider
getCredentials
in class CognitoCredentialsProvider
public void setLogins(java.util.Map<java.lang.String,java.lang.String> logins)
CognitoCredentialsProvider
setLogins
in class CognitoCredentialsProvider
logins
- The new logins map (providerName, providerToken) to use to
communicate with Amazon Cognitopublic void clear()
CognitoCredentialsProvider
clear
in class CognitoCredentialsProvider
public void clearCredentials()
CognitoCredentialsProvider
clearCredentials
in class CognitoCredentialsProvider
public java.lang.String getCachedIdentityId()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |