use of com.okta.idx.sdk.api.model.VerifyAuthenticatorAnswer in project okta-idx-java by okta.
the class LoginController method verify.
/**
* Handle authenticator verification functionality.
*
* @param code the verification code
* @param securityQuestionKey the security question key
* @param session the session
* @return the view associated with authentication response.
*/
@PostMapping("/verify")
public ModelAndView verify(@RequestParam("code") final String code, @RequestParam(value = "security_question_key", required = false) final String securityQuestionKey, final HttpSession session) {
logger.info(":: Verify Code :: {}", code);
ProceedContext proceedContext = Util.getProceedContextFromSession(session);
AuthenticationResponse authenticationResponse;
if (!Strings.isEmpty(securityQuestionKey)) {
authenticationResponse = idxAuthenticationWrapper.verifyAuthenticator(proceedContext, new VerifyAuthenticatorAnswer(code, securityQuestionKey));
} else if ("totp".equals(String.valueOf(session.getAttribute("totp")))) {
authenticationResponse = idxAuthenticationWrapper.verifyAuthenticator(proceedContext, new VerifyChannelDataOptions("totp", code));
} else {
VerifyAuthenticatorOptions verifyAuthenticatorOptions = new VerifyAuthenticatorOptions(code);
authenticationResponse = idxAuthenticationWrapper.verifyAuthenticator(proceedContext, verifyAuthenticatorOptions);
}
if (responseHandler.needsToShowErrors(authenticationResponse)) {
ModelAndView modelAndView = new ModelAndView("verify");
modelAndView.addObject("errors", authenticationResponse.getErrors());
return modelAndView;
}
return responseHandler.handleKnownTransitions(authenticationResponse, session);
}
Aggregations