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

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

Introduction

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

Prototype


public void setSession(String session) 

Source Link

Document

The session which should be passed both ways in challenge-response calls to the service.

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.
 *//* w w w . jav  a2 s  . 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);
            }
        };
    }
}