Search in sources :

Example 1 with VerifyPassCodeFactorRequest

use of com.okta.authn.sdk.resource.VerifyPassCodeFactorRequest in project okta-auth-java by okta.

the class EmailAuthenticationController method handlePost.

@RequestMapping(value = "/verify-email-authenticator", method = RequestMethod.POST)
public ModelAndView handlePost(@RequestParam(value = "passcode") final String passcode, @RequestParam(value = "factorId") final String factorId, @RequestParam(value = "stateToken") final String stateToken) {
    final ModelAndView modelAndView = new ModelAndView("home");
    final AuthenticationResponse authenticationResponse;
    try {
        final VerifyPassCodeFactorRequest verifyPassCodeFactorRequest = authenticationClient.instantiate(VerifyPassCodeFactorRequest.class);
        verifyPassCodeFactorRequest.setStateToken(stateToken);
        verifyPassCodeFactorRequest.setPassCode(passcode);
        RequestContext requestContext = new RequestContext();
        // false by default
        requestContext.addQuery("rememberDevice", "true");
        authenticationResponse = authenticationClient.verifyFactor(factorId, verifyPassCodeFactorRequest, requestContext, ignoringStateHandler);
    } catch (final AuthenticationException e) {
        logger.error("Verify Email Factor Error - Status: {}, Code: {}, Message: {}", e.getStatus(), e.getCode(), e.getMessage());
        final ModelAndView errorView = new ModelAndView();
        errorView.addObject("error", e.getStatus() + ":" + e.getCode() + ":" + e.getMessage());
        return errorView;
    }
    modelAndView.addObject("authenticationResponse", authenticationResponse);
    return modelAndView;
}
Also used : VerifyPassCodeFactorRequest(com.okta.authn.sdk.resource.VerifyPassCodeFactorRequest) AuthenticationException(com.okta.authn.sdk.AuthenticationException) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestContext(com.okta.authn.sdk.http.RequestContext) AuthenticationResponse(com.okta.authn.sdk.resource.AuthenticationResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AuthenticationException (com.okta.authn.sdk.AuthenticationException)1 RequestContext (com.okta.authn.sdk.http.RequestContext)1 AuthenticationResponse (com.okta.authn.sdk.resource.AuthenticationResponse)1 VerifyPassCodeFactorRequest (com.okta.authn.sdk.resource.VerifyPassCodeFactorRequest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1