class FactorEnrollmentAPIController {

    @RequestMapping(value = "activate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public Factor activateFactor(@RequestBody ActivateRequestDTO activateRequestDTO, Authentication auth)
            throws OktaException
    {
        Preconditions.checkNotNull(activateRequestDTO, "activateRequestDTO is null");
        Preconditions.checkNotNull(activateRequestDTO.getFactorId(), "factor id is null");
        Preconditions.checkNotNull(activateRequestDTO.getActivationCode(), "activation code is null");

        try
        {
            LOGGER.info("Activating factor [{}] for user [{}]", activateRequestDTO.getFactorId(), auth.getName());
            OktaUser user = getOktaUserService().getUser(auth.getName());
            return getFactorLifecycleService().activate(activateRequestDTO.getFactorId(), activateRequestDTO.getActivationCode(), user);
        }
        catch (Exception e)
        {
            LOGGER.error("Failed to activate factor [{}] for user [{}]", activateRequestDTO.getFactorId(), auth.getName(), e);
            throw new OktaException(e.getMessage(), e);
        }
    }

}