Search in sources :

Example 1 with VerifyAuthenticatorAnswer

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);
}
Also used : VerifyAuthenticatorAnswer(com.okta.idx.sdk.api.model.VerifyAuthenticatorAnswer) VerifyAuthenticatorOptions(com.okta.idx.sdk.api.model.VerifyAuthenticatorOptions) VerifyChannelDataOptions(com.okta.idx.sdk.api.model.VerifyChannelDataOptions) ModelAndView(org.springframework.web.servlet.ModelAndView) AuthenticationResponse(com.okta.idx.sdk.api.response.AuthenticationResponse) ProceedContext(com.okta.idx.sdk.api.client.ProceedContext) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

ProceedContext (com.okta.idx.sdk.api.client.ProceedContext)1 VerifyAuthenticatorAnswer (com.okta.idx.sdk.api.model.VerifyAuthenticatorAnswer)1 VerifyAuthenticatorOptions (com.okta.idx.sdk.api.model.VerifyAuthenticatorOptions)1 VerifyChannelDataOptions (com.okta.idx.sdk.api.model.VerifyChannelDataOptions)1 AuthenticationResponse (com.okta.idx.sdk.api.response.AuthenticationResponse)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1