Example usage for com.amazonaws.services.cognitoidp.model RespondToAuthChallengeResult RespondToAuthChallengeResult

List of usage examples for com.amazonaws.services.cognitoidp.model RespondToAuthChallengeResult RespondToAuthChallengeResult

Introduction

In this page you can find the example usage for com.amazonaws.services.cognitoidp.model RespondToAuthChallengeResult RespondToAuthChallengeResult.

Prototype

RespondToAuthChallengeResult

Source Link

Usage

From source file:io.fineo.client.auth.cognito.CognitoUser.java

License:Open Source License

/**
 * Determines the next step from the challenge.
 * This takes an object of type {@link InitiateAuthResult} as parameter and creates an object of type
 * {@link RespondToAuthChallengeResult} and calls {@code handleChallenge(RespondToAuthChallengeResult challenge, final AuthenticationHandler callback)} method.
 *
 * @param authResult        REQUIRED: Result from the {@code initiateAuth(...)} method.
 * @param callback          REQUIRED: Callback for type {@link AuthenticationHandler}
 * @param runInBackground   REQUIRED: Boolean to indicate the current threading.
 * @return {@link Runnable} for the next step in user authentication.
 *///from   www  .  j av  a  2s  .  c  om
private Runnable handleChallenge(final InitiateAuthResult authResult, final AuthenticationHandler callback,
        final boolean runInBackground) {
    try {
        RespondToAuthChallengeResult challenge = new RespondToAuthChallengeResult();
        challenge.setChallengeName(authResult.getChallengeName());
        challenge.setSession(authResult.getSession());
        challenge.setAuthenticationResult(authResult.getAuthenticationResult());
        challenge.setChallengeParameters(authResult.getChallengeParameters());
        return handleChallenge(challenge, callback, runInBackground);
    } catch (final Exception e) {
        return new Runnable() {
            @Override
            public void run() {
                callback.onFailure(e);
            }
        };
    }
}