use of com.amazonaws.services.cognitoidentityprovider.model.AnalyticsMetadataType in project aws-sdk-android by aws-amplify.
the class CognitoUser method resendConfirmationCodeInternal.
/**
* Internal method to request registration code resend.
* @param clientMetadata A map of custom key-value pairs that is passed to the lambda function for
* custom workflow.
*/
private ResendConfirmationCodeResult resendConfirmationCodeInternal(final Map<String, String> clientMetadata) {
final ResendConfirmationCodeRequest resendConfirmationCodeRequest = new ResendConfirmationCodeRequest().withUsername(userId).withClientId(clientId).withSecretHash(secretHash).withClientMetadata(clientMetadata);
final String pinpointEndpointId = pool.getPinpointEndpointId();
resendConfirmationCodeRequest.setUserContextData(getUserContextData());
if (pinpointEndpointId != null) {
AnalyticsMetadataType amd = new AnalyticsMetadataType();
amd.setAnalyticsEndpointId(pinpointEndpointId);
resendConfirmationCodeRequest.setAnalyticsMetadata(amd);
}
return cognitoIdentityProviderClient.resendConfirmationCode(resendConfirmationCodeRequest);
}
use of com.amazonaws.services.cognitoidentityprovider.model.AnalyticsMetadataType in project aws-sdk-android by aws-amplify.
the class CognitoUser method forgotPasswordInternal.
/**
* Internal method to start forgot password process.
*/
private ForgotPasswordResult forgotPasswordInternal(final Map<String, String> clientMetadata) {
final ForgotPasswordRequest resetPasswordRequest = new ForgotPasswordRequest();
resetPasswordRequest.setClientId(clientId);
resetPasswordRequest.setSecretHash(secretHash);
resetPasswordRequest.setUsername(userId);
resetPasswordRequest.setUserContextData(getUserContextData());
resetPasswordRequest.setClientMetadata(clientMetadata);
final String pinpointEndpointId = pool.getPinpointEndpointId();
if (pinpointEndpointId != null) {
AnalyticsMetadataType amd = new AnalyticsMetadataType();
amd.setAnalyticsEndpointId(pinpointEndpointId);
resetPasswordRequest.setAnalyticsMetadata(amd);
}
return cognitoIdentityProviderClient.forgotPassword(resetPasswordRequest);
}
use of com.amazonaws.services.cognitoidentityprovider.model.AnalyticsMetadataType in project aws-sdk-android by aws-amplify.
the class CognitoUser method confirmPasswordInternal.
/**
* Internal method to set a new password.
*
* @param verificationCode REQUIRED: Verification code sent to the user.
* @param newPassword REQUIRED: New password for the user.
*/
private void confirmPasswordInternal(final String verificationCode, final String newPassword, final Map<String, String> clientMetadata) {
final ConfirmForgotPasswordRequest confirmResetPasswordRequest = new ConfirmForgotPasswordRequest();
confirmResetPasswordRequest.setUsername(userId);
confirmResetPasswordRequest.setClientId(clientId);
confirmResetPasswordRequest.setSecretHash(secretHash);
confirmResetPasswordRequest.setConfirmationCode(verificationCode);
confirmResetPasswordRequest.setPassword(newPassword);
confirmResetPasswordRequest.setUserContextData(getUserContextData());
confirmResetPasswordRequest.setClientMetadata(clientMetadata);
final String pinpointEndpointId = pool.getPinpointEndpointId();
if (pinpointEndpointId != null) {
AnalyticsMetadataType amd = new AnalyticsMetadataType();
amd.setAnalyticsEndpointId(pinpointEndpointId);
confirmResetPasswordRequest.setAnalyticsMetadata(amd);
}
cognitoIdentityProviderClient.confirmForgotPassword(confirmResetPasswordRequest);
}
use of com.amazonaws.services.cognitoidentityprovider.model.AnalyticsMetadataType in project aws-sdk-android by aws-amplify.
the class CognitoUserPool method signUpInternal.
/**
* Internal method to sign-up a new user in Cognito Identity Provider user pool.
*
* @param userId REQUIRED: The new user userId.
* @param password REQUIRED: Password you want to associate to this use.
* @param userAttributes REQUIRED: User attributes.
* @param validationData REQUIRED: Validation key value pairs, these will be passed to pre
* and post registration lambda functions.
* @param clientMetadata Client metadata for lambda function for user registration
* @return SignUpResult
*/
private SignUpResult signUpInternal(String userId, String password, CognitoUserAttributes userAttributes, Map<String, String> validationData, final Map<String, String> clientMetadata) {
// Create a list of {@link AttributeType} from {@code userAttributes}
List<AttributeType> validationDataList = null;
if (validationData != null) {
validationDataList = new ArrayList<AttributeType>();
for (final Map.Entry<String, String> data : validationData.entrySet()) {
final AttributeType validation = new AttributeType();
validation.setName(data.getKey());
validation.setValue(data.getValue());
validationDataList.add(validation);
}
}
// Generate Client secret hash
secretHash = CognitoSecretHash.getSecretHash(userId, clientId, clientSecret);
// Create User registration request
final SignUpRequest signUpUserRequest = new SignUpRequest().withUsername(userId).withPassword(password).withClientId(clientId).withSecretHash(secretHash).withUserAttributes(userAttributes.getAttributesList()).withValidationData(validationDataList).withClientMetadata(clientMetadata).withUserContextData(getUserContextData(userId));
String ppEndpoint = getPinpointEndpointId();
if (ppEndpoint != null) {
AnalyticsMetadataType amd = new AnalyticsMetadataType();
amd.setAnalyticsEndpointId(ppEndpoint);
signUpUserRequest.setAnalyticsMetadata(amd);
}
return client.signUp(signUpUserRequest);
}
use of com.amazonaws.services.cognitoidentityprovider.model.AnalyticsMetadataType in project aws-sdk-android by aws-amplify.
the class CognitoUser method initiateUserSrpAuthRequest.
/**
* Creates a authentication request to start authentication with user SRP
* verification.
*
* @param clientMetadata A map of custom key-value pairs that is passed to the lambda function for
* custom workflow.
* @param authenticationDetails REQUIRED: {@link AuthenticationDetails},
* contains details for user SRP authentication.
* @param authenticationHelper REQUIRED: Internal helper class for SRP
* calculations.
* @return {@link InitiateAuthRequest}, request to start with the user SRP
* authentication.
*/
private InitiateAuthRequest initiateUserSrpAuthRequest(final Map<String, String> clientMetadata, AuthenticationDetails authenticationDetails, AuthenticationHelper authenticationHelper) {
userId = authenticationDetails.getUserId();
final InitiateAuthRequest initiateAuthRequest = new InitiateAuthRequest();
initiateAuthRequest.setAuthFlow(CognitoServiceConstants.AUTH_TYPE_INIT_USER_SRP);
initiateAuthRequest.setClientId(clientId);
initiateAuthRequest.setClientMetadata(clientMetadata);
initiateAuthRequest.addAuthParametersEntry(CognitoServiceConstants.AUTH_PARAM_SECRET_HASH, CognitoSecretHash.getSecretHash(userId, clientId, clientSecret));
initiateAuthRequest.addAuthParametersEntry(CognitoServiceConstants.AUTH_PARAM_USERNAME, authenticationDetails.getUserId());
initiateAuthRequest.addAuthParametersEntry(CognitoServiceConstants.AUTH_PARAM_SRP_A, authenticationHelper.getA().toString(SRP_RADIX));
if (deviceKey == null) {
initiateAuthRequest.addAuthParametersEntry(CognitoServiceConstants.AUTH_PARAM_DEVICE_KEY, CognitoDeviceHelper.getDeviceKey(authenticationDetails.getUserId(), pool.getUserPoolId(), context));
} else {
initiateAuthRequest.addAuthParametersEntry(CognitoServiceConstants.AUTH_PARAM_DEVICE_KEY, deviceKey);
}
if (authenticationDetails.getValidationData() != null && authenticationDetails.getValidationData().size() > 0) {
final Map<String, String> userValidationData = new HashMap<String, String>();
for (final AttributeType attribute : authenticationDetails.getValidationData()) {
userValidationData.put(attribute.getName(), attribute.getValue());
}
initiateAuthRequest.setClientMetadata(userValidationData);
}
final String pinpointEndpointId = this.pool.getPinpointEndpointId();
if (pinpointEndpointId != null) {
AnalyticsMetadataType amd = new AnalyticsMetadataType();
amd.setAnalyticsEndpointId(pinpointEndpointId);
initiateAuthRequest.setAnalyticsMetadata(amd);
}
initiateAuthRequest.setUserContextData(getUserContextData());
return initiateAuthRequest;
}
Aggregations