Search in sources :

Example 1 with AdminConfirmSignUpRequest

use of com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest in project aws-sdk-android by aws-amplify.

the class AWSMobileClientPersistenceWithRestartabilityTest method createUser.

public static void createUser(final AWSMobileClient auth, final String userPoolId, final String username, final String password, final String email) throws Exception {
    HashMap<String, String> userAttributes = new HashMap<String, String>();
    userAttributes.put("email", email);
    auth.signUp(username, password, userAttributes, null);
    AdminConfirmSignUpRequest adminConfirmSignUpRequest = new AdminConfirmSignUpRequest();
    adminConfirmSignUpRequest.withUsername(username).withUserPoolId(userPoolId);
    getCognitoUserPoolLowLevelClient().adminConfirmSignUp(adminConfirmSignUpRequest);
}
Also used : HashMap(java.util.HashMap) AdminConfirmSignUpRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest)

Example 2 with AdminConfirmSignUpRequest

use of com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest in project aws-sdk-android by aws-amplify.

the class AWSMobileClientTest method deleteAllUsers.

public static void deleteAllUsers(final String userpoolId) {
    ListUsersResult listUsersResult;
    do {
        ListUsersRequest listUsersRequest = new ListUsersRequest().withUserPoolId(userpoolId).withLimit(60);
        listUsersResult = getUserpoolLL().listUsers(listUsersRequest);
        for (UserType user : listUsersResult.getUsers()) {
            if (USERNAME.equals(user.getUsername()) || "bimin".equals(user.getUsername()) || "customAuthTestUser".equals(user.getUsername())) {
                // This user is saved to test the identity id permanence
                continue;
            }
            boolean retryConfirmSignUp = false;
            do {
                try {
                    Log.d(TAG, "deleteAllUsers: " + user.getUsername());
                    getUserpoolLL().adminDeleteUser(new AdminDeleteUserRequest().withUsername(user.getUsername()).withUserPoolId(userpoolId));
                } catch (UserNotConfirmedException e) {
                    if (!retryConfirmSignUp) {
                        AdminConfirmSignUpRequest adminConfirmSignUpRequest = new AdminConfirmSignUpRequest();
                        adminConfirmSignUpRequest.withUsername(user.getUsername()).withUserPoolId(userpoolId);
                        getUserpoolLL().adminConfirmSignUp(adminConfirmSignUpRequest);
                        retryConfirmSignUp = true;
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                    } else {
                        retryConfirmSignUp = false;
                    }
                } catch (Exception e) {
                    Log.e(TAG, "deleteAllUsers: Some error trying to delete user", e);
                }
            } while (retryConfirmSignUp);
        }
    } while (listUsersResult.getPaginationToken() != null);
}
Also used : AdminDeleteUserRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminDeleteUserRequest) ListUsersRequest(com.amazonaws.services.cognitoidentityprovider.model.ListUsersRequest) AdminConfirmSignUpRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest) UserType(com.amazonaws.services.cognitoidentityprovider.model.UserType) UserNotConfirmedException(com.amazonaws.services.cognitoidentityprovider.model.UserNotConfirmedException) UsernameExistsException(com.amazonaws.services.cognitoidentityprovider.model.UsernameExistsException) JSONException(org.json.JSONException) UserNotConfirmedException(com.amazonaws.services.cognitoidentityprovider.model.UserNotConfirmedException) NotAuthorizedException(com.amazonaws.services.cognitoidentityprovider.model.NotAuthorizedException) ResourceNotFoundException(com.amazonaws.services.cognitoidentityprovider.model.ResourceNotFoundException) InvalidParameterException(com.amazonaws.services.cognitoidentityprovider.model.InvalidParameterException) ListUsersResult(com.amazonaws.services.cognitoidentityprovider.model.ListUsersResult)

Example 3 with AdminConfirmSignUpRequest

use of com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest in project aws-sdk-android by aws-amplify.

the class AWSMobileClientTest method createUser.

public static void createUser(final AWSMobileClient auth, final String userpoolId, final String username, final String password, final String email) throws Exception {
    HashMap<String, String> userAttributes = new HashMap<String, String>();
    userAttributes.put("email", email);
    auth.signUp(username, password, userAttributes, null);
    AdminConfirmSignUpRequest adminConfirmSignUpRequest = new AdminConfirmSignUpRequest();
    adminConfirmSignUpRequest.withUsername(username).withUserPoolId(userpoolId);
    getUserpoolLL().adminConfirmSignUp(adminConfirmSignUpRequest);
}
Also used : HashMap(java.util.HashMap) AdminConfirmSignUpRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest)

Example 4 with AdminConfirmSignUpRequest

use of com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest in project aws-sdk-android by aws-amplify.

the class AWSMobileClientPersistenceTest method createUser.

public static void createUser(final AWSMobileClient auth, final String userpoolId, final String username, final String password, final String email) throws Exception {
    HashMap<String, String> userAttributes = new HashMap<String, String>();
    userAttributes.put("email", email);
    auth.signUp(username, password, userAttributes, null);
    AdminConfirmSignUpRequest adminConfirmSignUpRequest = new AdminConfirmSignUpRequest();
    adminConfirmSignUpRequest.withUsername(username).withUserPoolId(userpoolId);
    getUserpoolLL().adminConfirmSignUp(adminConfirmSignUpRequest);
}
Also used : HashMap(java.util.HashMap) AdminConfirmSignUpRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest)

Example 5 with AdminConfirmSignUpRequest

use of com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest in project aws-sdk-android by aws-amplify.

the class AWSMobileClientPersistenceTest method deleteAllUsers.

public static void deleteAllUsers(final String userpoolId) {
    ListUsersResult listUsersResult;
    do {
        ListUsersRequest listUsersRequest = new ListUsersRequest().withUserPoolId(userpoolId).withLimit(60);
        listUsersResult = getUserpoolLL().listUsers(listUsersRequest);
        for (UserType user : listUsersResult.getUsers()) {
            if (USERNAME.equals(user.getUsername()) || "bimin".equals(user.getUsername())) {
                // This user is saved to test the identity id permanence
                continue;
            }
            boolean retryConfirmSignUp = false;
            do {
                try {
                    Log.d(TAG, "deleteAllUsers: " + user.getUsername());
                    getUserpoolLL().adminDeleteUser(new AdminDeleteUserRequest().withUsername(user.getUsername()).withUserPoolId(userpoolId));
                } catch (UserNotConfirmedException e) {
                    if (!retryConfirmSignUp) {
                        AdminConfirmSignUpRequest adminConfirmSignUpRequest = new AdminConfirmSignUpRequest();
                        adminConfirmSignUpRequest.withUsername(user.getUsername()).withUserPoolId(userpoolId);
                        getUserpoolLL().adminConfirmSignUp(adminConfirmSignUpRequest);
                        retryConfirmSignUp = true;
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e1) {
                            e1.printStackTrace();
                        }
                    } else {
                        retryConfirmSignUp = false;
                    }
                } catch (Exception e) {
                    Log.e(TAG, "deleteAllUsers: Some error trying to delete user", e);
                }
            } while (retryConfirmSignUp);
        }
    } while (listUsersResult.getPaginationToken() != null);
}
Also used : AdminDeleteUserRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminDeleteUserRequest) ListUsersRequest(com.amazonaws.services.cognitoidentityprovider.model.ListUsersRequest) AdminConfirmSignUpRequest(com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest) UserType(com.amazonaws.services.cognitoidentityprovider.model.UserType) UserNotConfirmedException(com.amazonaws.services.cognitoidentityprovider.model.UserNotConfirmedException) UserNotConfirmedException(com.amazonaws.services.cognitoidentityprovider.model.UserNotConfirmedException) ListUsersResult(com.amazonaws.services.cognitoidentityprovider.model.ListUsersResult)

Aggregations

AdminConfirmSignUpRequest (com.amazonaws.services.cognitoidentityprovider.model.AdminConfirmSignUpRequest)6 AdminDeleteUserRequest (com.amazonaws.services.cognitoidentityprovider.model.AdminDeleteUserRequest)3 ListUsersRequest (com.amazonaws.services.cognitoidentityprovider.model.ListUsersRequest)3 ListUsersResult (com.amazonaws.services.cognitoidentityprovider.model.ListUsersResult)3 UserNotConfirmedException (com.amazonaws.services.cognitoidentityprovider.model.UserNotConfirmedException)3 UserType (com.amazonaws.services.cognitoidentityprovider.model.UserType)3 HashMap (java.util.HashMap)3 JSONException (org.json.JSONException)2 InvalidParameterException (com.amazonaws.services.cognitoidentityprovider.model.InvalidParameterException)1 NotAuthorizedException (com.amazonaws.services.cognitoidentityprovider.model.NotAuthorizedException)1 ResourceNotFoundException (com.amazonaws.services.cognitoidentityprovider.model.ResourceNotFoundException)1 UsernameExistsException (com.amazonaws.services.cognitoidentityprovider.model.UsernameExistsException)1