use of com.amazonaws.internal.keyvaluestore.AWSKeyValueStore in project aws-sdk-android by aws-amplify.
the class AWSMobileClientTestBase method writeUserPoolsTokens.
public static void writeUserPoolsTokens(final Context appContext, final String clientId, final String username, final long expiryFromNow) {
// Store tokens in shared preferences
final AWSKeyValueStore awsKeyValueStore = new AWSKeyValueStore(appContext, "CognitoIdentityProviderCache", true);
String storeFieldPrefix = "CognitoIdentityProvider." + clientId + "." + username + ".";
awsKeyValueStore.put("CognitoIdentityProvider." + clientId + ".LastAuthUser", username);
awsKeyValueStore.put(storeFieldPrefix + "idToken", getValidJWT(expiryFromNow));
awsKeyValueStore.put(storeFieldPrefix + "accessToken", getValidJWT(expiryFromNow));
awsKeyValueStore.put(storeFieldPrefix + "refreshToken", "DummyRefresh");
}
use of com.amazonaws.internal.keyvaluestore.AWSKeyValueStore in project aws-sdk-android by aws-amplify.
the class AWSMobileClientTestBase method setAccessToken.
public static void setAccessToken(final Context appContext, final String clientId, final String username, final String accessToken) {
final AWSKeyValueStore awsKeyValueStore = new AWSKeyValueStore(appContext, "CognitoIdentityProviderCache", true);
String storeFieldPrefix = "CognitoIdentityProvider." + clientId + "." + username + ".";
awsKeyValueStore.put(storeFieldPrefix + "accessToken", accessToken);
}
use of com.amazonaws.internal.keyvaluestore.AWSKeyValueStore in project aws-sdk-android by aws-amplify.
the class CognitoCachingCredentialsProvider method initialize.
/**
* @param context the Android application context
*/
private void initialize(Context context) {
awsKeyValueStore = new AWSKeyValueStore(context, AWS_KEY_VALUE_STORE_NAMESPACE_IDENTIFIER, isPersistenceEnabled);
checkUpgrade();
this.identityId = getCachedIdentityId();
loadCachedCredentials();
registerIdentityChangedListener(listener);
}
use of com.amazonaws.internal.keyvaluestore.AWSKeyValueStore in project aws-sdk-android by aws-amplify.
the class CognitoUserPool method initialize.
private void initialize(final Context context) {
this.awsKeyValueStore = new AWSKeyValueStore(context, DEFAULT_SHARED_PREFERENCES_NAME, isPersistenceEnabled);
CognitoDeviceHelper.setPersistenceEnabled(isPersistenceEnabled);
}
use of com.amazonaws.internal.keyvaluestore.AWSKeyValueStore in project aws-sdk-android by aws-amplify.
the class CognitoDeviceHelper method cacheDeviceGroupKey.
/**
* This method caches the device group key. Device verifier is generated locally by the SDK and
* it is used to authenticate the device through device SRP authentication.
*
* @param username REQUIRED: The current user.
* @param userPoolId REQUIRED: Client ID of the device.
* @param deviceGroupKey REQUIRED: Cognito assigned device group key.
* @param context REQUIRED: App context, needed to access device datastore.
*/
public static void cacheDeviceGroupKey(String username, String userPoolId, String deviceGroupKey, Context context) {
try {
final AWSKeyValueStore awsKeyValueStore = getAWSKeyValueStore(context, username, userPoolId);
awsKeyValueStore.put(COGNITO_DEVICE_GROUP_KEY, deviceGroupKey);
} catch (final Exception e) {
LOGGER.error("Error accessing SharedPreferences", e);
}
}
Aggregations