|
18 | 18 | import com.loginradius.sdk.models.requestmodels.PINAuthEventBasedAuthModelWithLockout;
|
19 | 19 | import com.loginradius.sdk.models.requestmodels.PasswordEventBasedAuthModelWithLockout;
|
20 | 20 | import com.loginradius.sdk.models.requestmodels.ReauthByBackupCodeModel;
|
| 21 | +import com.loginradius.sdk.models.requestmodels.ReauthByEmailOtpModel; |
21 | 22 | import com.loginradius.sdk.models.requestmodels.ReauthByGoogleAuthenticatorCodeModel;
|
22 | 23 | import com.loginradius.sdk.models.requestmodels.ReauthByOtpModel;
|
| 24 | +import com.loginradius.sdk.models.requestmodels.SecurityQuestionAnswerUpdateModel; |
23 | 25 | import com.loginradius.sdk.models.responsemodels.EventBasedMultiFactorAuthenticationToken;
|
24 | 26 | import com.loginradius.sdk.models.responsemodels.MultiFactorAuthenticationSettingsResponse;
|
| 27 | +import com.loginradius.sdk.models.responsemodels.otherobjects.PostResponse; |
25 | 28 | import com.loginradius.sdk.models.responsemodels.otherobjects.PostValidationResponse;
|
26 | 29 | import com.loginradius.sdk.util.AsyncHandler;
|
27 | 30 | import com.loginradius.sdk.util.ErrorResponse;
|
@@ -419,4 +422,134 @@ public void onFailure(ErrorResponse errorResponse) {
|
419 | 422 | }
|
420 | 423 | });
|
421 | 424 | }
|
| 425 | + |
| 426 | + // <summary> |
| 427 | + // This API is used to validate the triggered MFA authentication flow with an Email OTP. |
| 428 | + // </summary> |
| 429 | + // <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param> |
| 430 | + // <param name="reauthByEmailOtpModel">payload</param> |
| 431 | + // <returns>Response containing Definition response of MFA reauthentication</returns> |
| 432 | + // 42.14 |
| 433 | + |
| 434 | + |
| 435 | + public void reAuthValidateEmailOtp(String accessToken, ReauthByEmailOtpModel reauthByEmailOtpModel, final AsyncHandler<EventBasedMultiFactorAuthenticationToken> handler) { |
| 436 | + |
| 437 | + if (LoginRadiusValidator.isNullOrWhiteSpace(accessToken)) { |
| 438 | + throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("accessToken")); |
| 439 | + } |
| 440 | + |
| 441 | + if (reauthByEmailOtpModel == null) { |
| 442 | + throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("reauthByEmailOtpModel")); |
| 443 | + } |
| 444 | + |
| 445 | + Map<String, String> queryParameters = new HashMap<String, String>(); |
| 446 | + queryParameters.put("access_token", accessToken); |
| 447 | + queryParameters.put("apiKey", LoginRadiusSDK.getApiKey()); |
| 448 | + |
| 449 | + String resourcePath = "identity/v2/auth/account/reauth/2fa/otp/email/verify"; |
| 450 | + |
| 451 | + LoginRadiusRequest.execute("PUT", resourcePath, queryParameters, gson.toJson(reauthByEmailOtpModel), new AsyncHandler<String>() { |
| 452 | + |
| 453 | + @Override |
| 454 | + public void onSuccess(String response) { |
| 455 | + TypeToken<EventBasedMultiFactorAuthenticationToken> typeToken = new TypeToken<EventBasedMultiFactorAuthenticationToken>() {}; |
| 456 | + EventBasedMultiFactorAuthenticationToken successResponse = JsonDeserializer.deserializeJson(response,typeToken); |
| 457 | + handler.onSuccess(successResponse); |
| 458 | + } |
| 459 | + |
| 460 | + @Override |
| 461 | + public void onFailure(ErrorResponse errorResponse) { |
| 462 | + handler.onFailure(errorResponse); |
| 463 | + } |
| 464 | + }); |
| 465 | + } |
| 466 | + |
| 467 | + // <summary> |
| 468 | + // This API is used to send the MFA Email OTP to the email for Re-authentication |
| 469 | + // </summary> |
| 470 | + // <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param> |
| 471 | + // <param name="emailId">EmailId</param> |
| 472 | + // <param name="emailTemplate2FA">EmailTemplate2FA</param> |
| 473 | + // <returns>Response containing Definition of Complete Validation data</returns> |
| 474 | + // 42.15 |
| 475 | + |
| 476 | + |
| 477 | + public void reAuthSendEmailOtp(String accessToken, String emailId, |
| 478 | + String emailTemplate2FA, final AsyncHandler<PostResponse> handler) { |
| 479 | + |
| 480 | + if (LoginRadiusValidator.isNullOrWhiteSpace(accessToken)) { |
| 481 | + throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("accessToken")); |
| 482 | + } |
| 483 | + |
| 484 | + if (LoginRadiusValidator.isNullOrWhiteSpace(emailId)) { |
| 485 | + throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("emailId")); |
| 486 | + } |
| 487 | + |
| 488 | + Map<String, String> queryParameters = new HashMap<String, String>(); |
| 489 | + queryParameters.put("access_token", accessToken); |
| 490 | + queryParameters.put("apiKey", LoginRadiusSDK.getApiKey()); |
| 491 | + queryParameters.put("emailId", emailId); |
| 492 | + |
| 493 | + if (!LoginRadiusValidator.isNullOrWhiteSpace(emailTemplate2FA)) { |
| 494 | + queryParameters.put("emailTemplate2FA", emailTemplate2FA); |
| 495 | + } |
| 496 | + |
| 497 | + String resourcePath = "identity/v2/auth/account/reauth/2fa/otp/email"; |
| 498 | + |
| 499 | + LoginRadiusRequest.execute("GET", resourcePath, queryParameters, null, new AsyncHandler<String>() { |
| 500 | + |
| 501 | + @Override |
| 502 | + public void onSuccess(String response) { |
| 503 | + TypeToken<PostResponse> typeToken = new TypeToken<PostResponse>() {}; |
| 504 | + PostResponse successResponse = JsonDeserializer.deserializeJson(response,typeToken); |
| 505 | + handler.onSuccess(successResponse); |
| 506 | + } |
| 507 | + |
| 508 | + @Override |
| 509 | + public void onFailure(ErrorResponse errorResponse) { |
| 510 | + handler.onFailure(errorResponse); |
| 511 | + } |
| 512 | + }); |
| 513 | + } |
| 514 | + |
| 515 | + // <summary> |
| 516 | + // This API is used to validate the triggered MFA re-authentication flow with security questions answers. |
| 517 | + // </summary> |
| 518 | + // <param name="accessToken">Uniquely generated identifier key by LoginRadius that is activated after successful authentication.</param> |
| 519 | + // <param name="securityQuestionAnswerUpdateModel">payload</param> |
| 520 | + // <returns>Response containing Definition response of MFA reauthentication</returns> |
| 521 | + // 42.16 |
| 522 | + |
| 523 | + |
| 524 | + public void reAuthBySecurityQuestion(String accessToken, SecurityQuestionAnswerUpdateModel securityQuestionAnswerUpdateModel, final AsyncHandler<EventBasedMultiFactorAuthenticationToken> handler) { |
| 525 | + |
| 526 | + if (LoginRadiusValidator.isNullOrWhiteSpace(accessToken)) { |
| 527 | + throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("accessToken")); |
| 528 | + } |
| 529 | + |
| 530 | + if (securityQuestionAnswerUpdateModel == null) { |
| 531 | + throw new IllegalArgumentException(LoginRadiusValidator.getValidationMessage("securityQuestionAnswerUpdateModel")); |
| 532 | + } |
| 533 | + |
| 534 | + Map<String, String> queryParameters = new HashMap<String, String>(); |
| 535 | + queryParameters.put("access_token", accessToken); |
| 536 | + queryParameters.put("apiKey", LoginRadiusSDK.getApiKey()); |
| 537 | + |
| 538 | + String resourcePath = "identity/v2/auth/account/reauth/2fa/securityquestionanswer/verify"; |
| 539 | + |
| 540 | + LoginRadiusRequest.execute("POST", resourcePath, queryParameters, gson.toJson(securityQuestionAnswerUpdateModel), new AsyncHandler<String>() { |
| 541 | + |
| 542 | + @Override |
| 543 | + public void onSuccess(String response) { |
| 544 | + TypeToken<EventBasedMultiFactorAuthenticationToken> typeToken = new TypeToken<EventBasedMultiFactorAuthenticationToken>() {}; |
| 545 | + EventBasedMultiFactorAuthenticationToken successResponse = JsonDeserializer.deserializeJson(response,typeToken); |
| 546 | + handler.onSuccess(successResponse); |
| 547 | + } |
| 548 | + |
| 549 | + @Override |
| 550 | + public void onFailure(ErrorResponse errorResponse) { |
| 551 | + handler.onFailure(errorResponse); |
| 552 | + } |
| 553 | + }); |
| 554 | + } |
422 | 555 | }
|
0 commit comments