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;
}
Aggregations