protected MultifactorAuthenticationTokenResponse generateToken(final Credential credential, final Service givenService) throws Throwable {
        val authnSupport = applicationContext.getBean(AuthenticationSystemSupport.BEAN_NAME, AuthenticationSystemSupport.class);
        return authnSupport.handleInitialAuthenticationTransaction(givenService, credential)
            .getInitialAuthentication()
            .map(Unchecked.function(authentication -> {
                val token = createAndStoreToken(givenService, authentication);
                return new MultifactorAuthenticationTokenResponse(token.getId(),
                    authentication.getPrincipal().getId(),
                    givenService.getId(),
                    token.getExpirationPolicy().getTimeToLive(token));
            }))
            .orElseThrow(() -> new AuthenticationException("Unable to successfully authenticate the user and/or generate token"));
    }
Generate token and produce response entity.

@param service       the service
@param authorization the authorization
@return the response entity
support/cas-server-support-simple-mfa-core/src/main/java/org/apereo/cas/mfa/simple/web/CasSimpleMultifactorAuthenticationEndpoint.java