@@ -2330,7 +2330,12 @@ private Runnable startWithUserSrpAuth(final AuthenticationDetails authentication
23302330 .equals (initiateAuthResult .getChallengeName ())) {
23312331 if (authenticationDetails .getPassword () != null ) {
23322332 final RespondToAuthChallengeRequest challengeRequest = userSrpAuthRequest (
2333- initiateAuthResult , authenticationDetails , authenticationHelper );
2333+ initiateAuthResult .getChallengeParameters (),
2334+ initiateAuthResult .getChallengeName (),
2335+ initiateAuthResult .getSession (),
2336+ authenticationDetails .getPassword (),
2337+ authenticationHelper
2338+ );
23342339 return respondToChallenge (challengeRequest , callback , runInBackground );
23352340 }
23362341 }
@@ -2481,14 +2486,10 @@ public void run() {
24812486 pool .getUserPoolId ());
24822487 final Map <String , String > challengeParameters = challenge .getChallengeParameters ();
24832488 cognitoIdentityProviderClient .respondToAuthChallenge (userSrpAuthRequest (
2484- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_USERNAME ),
2485- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_USER_ID_FOR_SRP ),
2486- authenticationDetails .getPassword (),
2487- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SRP_B ),
2488- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SALT ),
2489- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SECRET_BLOCK ),
2489+ challengeParameters ,
24902490 challenge .getChallengeName (),
24912491 challenge .getSession (),
2492+ authenticationDetails .getPassword (),
24922493 authenticationHelper
24932494 ));
24942495 }
@@ -2862,55 +2863,25 @@ private InitiateAuthRequest initiateRefreshTokenAuthRequest(CognitoUserSession c
28622863 }
28632864
28642865 /**
2865- * Creates response for the second step of the SRP authentication.
28662866 *
2867- * @param challenge REQUIRED: {@link InitiateAuthResult} contains next
2868- * challenge.
2869- * @param authenticationDetails REQUIRED: {@link AuthenticationDetails} user
2870- * authentication details.
2871- * @param authenticationHelper REQUIRED: Internal helper class for SRP
2872- * calculations.
2873- * @return {@link RespondToAuthChallengeRequest}.
2874- */
2875- private RespondToAuthChallengeRequest userSrpAuthRequest (InitiateAuthResult challenge ,
2876- AuthenticationDetails authenticationDetails ,
2877- AuthenticationHelper authenticationHelper ) {
2878- final Map <String , String > challengeParameters = challenge .getChallengeParameters ();
2879- return userSrpAuthRequest (
2880- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_USERNAME ),
2881- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_USER_ID_FOR_SRP ),
2882- authenticationDetails .getPassword (),
2883- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SRP_B ),
2884- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SALT ),
2885- challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SECRET_BLOCK ),
2886- challenge .getChallengeName (),
2887- challenge .getSession (),
2888- authenticationHelper
2889- );
2890- }
2891-
2892- /**
2893- * Creates response for the second step of the SRP authentication.
2894- *
2895- * @param userId returned by service
2896- * @param userIdForSRP returned by service
2867+ * @param challengeParameters returned by service
28972868 * @param password maintained locally
2898- * @param srpBString returned by service
2899- * @param saltString returned by service
2900- * @param secretBlockString returned by service
29012869 * @param challengeName returned by service
29022870 * @param session returned by service
2903- * @return {@link RespondToAuthChallengeRequest}.
2871+ * @param authenticationHelper
2872+ * @return
29042873 */
2905- private RespondToAuthChallengeRequest userSrpAuthRequest (final String userId ,
2906- final String userIdForSRP ,
2874+ private RespondToAuthChallengeRequest userSrpAuthRequest (final Map <String , String > challengeParameters ,
29072875 final String password ,
2908- final String srpBString ,
2909- final String saltString ,
2910- final String secretBlockString ,
29112876 final String challengeName ,
29122877 final String session ,
29132878 final AuthenticationHelper authenticationHelper ) {
2879+ final String userId = challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_USERNAME );
2880+ final String userIdForSRP = challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_USER_ID_FOR_SRP );
2881+ final String srpBString = challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SRP_B );
2882+ final String saltString = challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SALT );
2883+ final String secretBlockString = challengeParameters .get (CognitoServiceConstants .CHLG_PARAM_SECRET_BLOCK );
2884+
29142885 this .usernameInternal = userId ;
29152886 this .deviceKey = CognitoDeviceHelper .getDeviceKey (usernameInternal , pool .getUserPoolId (),
29162887 context );
0 commit comments