List of usage examples for com.amazonaws.services.cognitoidp.model InvalidParameterException InvalidParameterException
public InvalidParameterException(String message)
From source file:io.fineo.client.auth.cognito.CognitoUser.java
License:Open Source License
/** * Returns a valid tokens for a user through the callback method. Runs in background. * {@link AuthenticationHandler#onSuccess(CognitoUserSession, Object)}. * <p>//from www. j a v a2s . c om * Tokens are passed as instance of {@link CognitoUserSession}. * Call this method to get valid tokens for a user. This method returns any valid cached * tokens for the user. If no valid cached tokens are available this method initiates the * process to authenticate the user and get tokens from Cognito Identity Provider service. * Implement the interface {@link AuthenticationHandler} and pass it as callback to this * method. This method uses the callback to interact with application at different * stages of the authentication process. Continuation objects are used when the authentication * process requires more data to continue. * <b>Note:</b> This method will perform network operations. Calling this method in * applications' main thread will cause Android to throw NetworkOnMainThreadException. * </p> * @param callback REQUIRED: {@link AuthenticationHandler} callback */ public void getSession(final AuthenticationHandler callback) { if (callback == null) { throw new InvalidParameterException("callback is null"); } try { getCachedSession(); callback.onSuccess(cipSession, null); } catch (InvalidParameterException e) { callback.onFailure(e); } catch (CognitoNotAuthorizedException e) { AuthenticationContinuation authenticationContinuation = new AuthenticationContinuation(this, AuthenticationContinuation.RUN_IN_CURRENT, callback); callback.getAuthenticationDetails(authenticationContinuation, getUserId()); } catch (Exception e) { callback.onFailure(e); } }