List of usage examples for com.amazonaws.services.cognitoidp.model ResourceNotFoundException getMessage
@Override
public String getMessage()
From source file:io.fineo.client.auth.cognito.CognitoUser.java
License:Open Source License
/** * This method sends the challenge response to the Cognito IDP service. The call to the Cognito IDP * service returns a new challenge and a different method is called to process the challenge. * Restarts authentication if the service cannot find a device-key. * * @param challengeResponse REQUIRED: {@link RespondToAuthChallengeRequest} contains * response for the current challenge. * @param callback REQUIRED: {@link AuthenticationHandler} callback. * @param runInBackground REQUIRED: Boolean to indicate the current threading. * @return {@link Runnable} for the next step in user authentication. *//* w ww .j a v a 2 s . c o m*/ public Runnable respondToChallenge(final RespondToAuthChallengeRequest challengeResponse, final AuthenticationHandler callback, final boolean runInBackground) { try { if (challengeResponse != null && challengeResponse.getChallengeResponses() != null) { Map<String, String> challengeResponses = challengeResponse.getChallengeResponses(); challengeResponses.put("DEVICE_KEY", deviceKey); challengeResponse.setChallengeResponses(challengeResponses); } RespondToAuthChallengeResult challenge = cognitoIdentityProviderClient .respondToAuthChallenge(challengeResponse); return handleChallenge(challenge, callback, runInBackground); } catch (final ResourceNotFoundException rna) { final CognitoUser cognitoUser = this; if (rna.getMessage().contains("Device")) { return clearCache(cognitoUser, runInBackground, callback); } else { return new Runnable() { @Override public void run() { callback.onFailure(rna); } }; } } catch (final Exception e) { return new Runnable() { @Override public void run() { callback.onFailure(e); } }; } }
From source file:io.fineo.client.auth.cognito.CognitoUser.java
License:Open Source License
/** * This method starts the user authentication with user password verification. * Restarts authentication if the service cannot find a device-key. * * @param authenticationDetails REQUIRED: {@link AuthenticationDetails} contains user details * for authentication. * @param callback REQUIRED: {@link AuthenticationHandler} callback. * @param runInBackground REQUIRED: Boolean to indicate the current threading. * @return {@link Runnable} for the next step in user authentication. *//*www.j av a 2s. com*/ private Runnable startWithUserSrpAuth(final AuthenticationDetails authenticationDetails, final AuthenticationHandler callback, final boolean runInBackground) { AuthenticationHelper authenticationHelper = new AuthenticationHelper(pool.getUserPoolId()); InitiateAuthRequest initiateAuthRequest = initiateUserSrpAuthRequest(authenticationDetails, authenticationHelper); try { InitiateAuthResult initiateAuthResult = cognitoIdentityProviderClient.initiateAuth(initiateAuthRequest); updateInternalUsername(initiateAuthResult.getChallengeParameters()); // verify that the password matches if (initiateAuthResult.getChallengeName().equals("PASSWORD_VERIFIER")) { if (authenticationDetails.getPassword() != null) { RespondToAuthChallengeRequest challengeRequest = userSrpAuthRequest(initiateAuthResult, authenticationDetails, authenticationHelper); return respondToChallenge(challengeRequest, callback, runInBackground); } } return handleChallenge(initiateAuthResult, callback, runInBackground); } catch (final ResourceNotFoundException rna) { final CognitoUser cognitoUser = this; if (rna.getMessage().contains("Device")) { return clearCache(cognitoUser, runInBackground, callback); } else { return new Runnable() { @Override public void run() { callback.onFailure(rna); } }; } } catch (final Exception e) { return new Runnable() { @Override public void run() { callback.onFailure(e); } }; } }