Example usage for com.amazonaws.services.cognitoidp.model InitiateAuthResult getAuthenticationResult

List of usage examples for com.amazonaws.services.cognitoidp.model InitiateAuthResult getAuthenticationResult

Introduction

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

Prototype


public AuthenticationResultType getAuthenticationResult() 

Source Link

Document

The result of the authentication response.

Usage

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

License:Open Source License

/**
 * Internal method to refresh current {@link CognitoUserSession}, is a refresh token is available.
 *
 * @param currSession           REQUIRED: Current cached {@link CognitoUserSession}.
 * @return {@link CognitoUserSession} with new access and id tokens.
 *///  w  w w  .j a  v  a 2  s .  c  o m
private CognitoUserSession refreshSession(CognitoUserSession currSession) {
    CognitoUserSession cognitoUserSession = null;
    InitiateAuthRequest initiateAuthRequest = initiateRefreshTokenAuthRequest(currSession);
    InitiateAuthResult refreshSessionResult = cognitoIdentityProviderClient.initiateAuth(initiateAuthRequest);
    if (refreshSessionResult.getAuthenticationResult() == null) {
        throw new CognitoNotAuthorizedException("user is not authenticated");
    }
    cognitoUserSession = getCognitoUserSession(refreshSessionResult.getAuthenticationResult(),
            currSession.getRefreshToken());
    return cognitoUserSession;
}

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  .  j a  v 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);
            }
        };
    }
}