109109import com .amazonaws .services .cognitoidentity .model .NotAuthorizedException ;
110110import com .amazonaws .services .cognitoidentityprovider .AmazonCognitoIdentityProvider ;
111111import com .amazonaws .services .cognitoidentityprovider .AmazonCognitoIdentityProviderClient ;
112+ import com .amazonaws .services .cognitoidentityprovider .model .AuthFlowType ;
112113import com .amazonaws .services .cognitoidentityprovider .model .GlobalSignOutRequest ;
113114import com .amazonaws .services .cognitoidentityprovider .model .InvalidUserPoolConfigurationException ;
114115import com .amazonaws .util .StringUtils ;
@@ -1192,7 +1193,19 @@ public void signIn(final String username,
11921193 final Callback <SignInResult > callback ) {
11931194
11941195 final InternalCallback <SignInResult > internalCallback = new InternalCallback <SignInResult >(callback );
1195- internalCallback .async (_signIn (username , password , validationData , clientMetadata , internalCallback ));
1196+ internalCallback .async (_signIn (username , password , validationData , clientMetadata , null , internalCallback ));
1197+ }
1198+
1199+ @ AnyThread
1200+ public void signIn (final String username ,
1201+ final String password ,
1202+ final Map <String , String > validationData ,
1203+ final Map <String , String > clientMetadata ,
1204+ final AuthFlowType authFlowType ,
1205+ final Callback <SignInResult > callback ) {
1206+
1207+ final InternalCallback <SignInResult > internalCallback = new InternalCallback <SignInResult >(callback );
1208+ internalCallback .async (_signIn (username , password , validationData , clientMetadata , authFlowType , internalCallback ));
11961209 }
11971210
11981211 @ WorkerThread
@@ -1209,13 +1222,25 @@ public SignInResult signIn(final String username,
12091222 final Map <String , String > clientMetadata ) throws Exception {
12101223
12111224 final InternalCallback <SignInResult > internalCallback = new InternalCallback <SignInResult >();
1212- return internalCallback .await (_signIn (username , password , validationData , clientMetadata , internalCallback ));
1225+ return internalCallback .await (_signIn (username , password , validationData , clientMetadata , null , internalCallback ));
1226+ }
1227+
1228+ @ WorkerThread
1229+ public SignInResult signIn (final String username ,
1230+ final String password ,
1231+ final Map <String , String > validationData ,
1232+ final Map <String , String > clientMetadata ,
1233+ final AuthFlowType authFlowType ) throws Exception {
1234+
1235+ final InternalCallback <SignInResult > internalCallback = new InternalCallback <SignInResult >();
1236+ return internalCallback .await (_signIn (username , password , validationData , clientMetadata , authFlowType , internalCallback ));
12131237 }
12141238
12151239 private Runnable _signIn (final String username ,
12161240 final String password ,
12171241 final Map <String , String > validationData ,
12181242 final Map <String , String > clientMetadata ,
1243+ final AuthFlowType authFlowType ,
12191244 final Callback <SignInResult > callback ) {
12201245
12211246 this .signInCallback = callback ;
@@ -1264,18 +1289,19 @@ public void getAuthenticationDetails(AuthenticationContinuation authenticationCo
12641289 awsConfiguration .optJsonObject (AUTH_KEY ).has ("authenticationFlowType" );
12651290
12661291 try {
1267- String authFlowType = authFlowTypeInConfig ?
1268- awsConfiguration .optJsonObject (AUTH_KEY ).getString ("authenticationFlowType" ) :
1269- null ;
1270- if (authFlowTypeInConfig && AUTH_TYPE_INIT_CUSTOM_AUTH .equals (authFlowType )) {
1292+ String resolvedAuthFlowType = authFlowType != null ? authFlowType .name () : null ;
1293+ if (resolvedAuthFlowType == null && authFlowTypeInConfig ) {
1294+ resolvedAuthFlowType = awsConfiguration .optJsonObject (AUTH_KEY ).getString ("authenticationFlowType" );
1295+ }
1296+ if (resolvedAuthFlowType != null && AUTH_TYPE_INIT_CUSTOM_AUTH .equals (resolvedAuthFlowType )) {
12711297 // If there's a value in the config and it's CUSTOM_AUTH, we'll
12721298 // use one of the below constructors depending on what's passed in.
12731299 if (password != null ) {
12741300 authenticationContinuation .setAuthenticationDetails (new AuthenticationDetails (username , password , authParameters , validationData ));
12751301 } else {
12761302 authenticationContinuation .setAuthenticationDetails (new AuthenticationDetails (username , authParameters , validationData ));
12771303 }
1278- } else if (authFlowTypeInConfig && AUTH_TYPE_INIT_USER_PASSWORD .equals (authFlowType )) {
1304+ } else if (resolvedAuthFlowType != null && AUTH_TYPE_INIT_USER_PASSWORD .equals (resolvedAuthFlowType )) {
12791305 // If there's a value in the config and it's USER_PASSWORD_AUTH, set the auth type (challenge name)
12801306 // to be USER_PASSWORD.
12811307 AuthenticationDetails authenticationDetails = new AuthenticationDetails (username , password , validationData );
@@ -1703,7 +1729,7 @@ public void deleteUser(final Callback<Void> callback) {
17031729 final InternalCallback <Void > internalCallback = new InternalCallback <>(callback );
17041730 internalCallback .async (_deleteUser (internalCallback ));
17051731 }
1706-
1732+
17071733 private Runnable _deleteUser (final Callback <Void > callback ) {
17081734 return () -> {
17091735 if (userpool == null ) {
0 commit comments