@Override
    public Optional<MultifactorAuthenticationProvider> isActivated(final Authentication authentication,
                                                                   final RegisteredService registeredService,
                                                                   final HttpServletRequest request,
                                                                   final HttpServletResponse response,
                                                                   final Service service) throws Throwable {

        if (authentication == null) {
            LOGGER.debug("No authentication is available to determine event for principal");
            return Optional.empty();
        }

        val globalProviderIds = findGlobalProviderIds(request);
        if (globalProviderIds == null || globalProviderIds.isEmpty()) {
            LOGGER.trace("No value could be found for for the global provider id");
            return Optional.empty();
        }
        LOGGER.debug("Attempting to globally activate [{}]", globalProviderIds);
        val providerMap = MultifactorAuthenticationUtils.getAvailableMultifactorAuthenticationProviders(this.applicationContext);
        if (providerMap.isEmpty()) {
            LOGGER.error("No multifactor authentication providers are available in the application context to handle [{}]", globalProviderIds);
            throw new AuthenticationException(new MultifactorAuthenticationProviderAbsentException());
        }

        val resolvedProviders = globalProviderIds.stream()
            .map(provider -> MultifactorAuthenticationUtils.resolveProvider(providerMap, provider))
            .filter(Optional::isPresent)
            .map(Optional::get)
            .sorted(Comparator.comparing(MultifactorAuthenticationProvider::getOrder))
            .collect(Collectors.toList());

        if (resolvedProviders.size() != globalProviderIds.size()) {
            handleAbsentMultifactorProvider(globalProviderIds, resolvedProviders);
        }

        if (resolvedProviders.size() == 1) {
            return resolveSingleMultifactorProvider(resolvedProviders.getFirst());
        }

        return resolveMultifactorProvider(authentication, registeredService, resolvedProviders);
    }
This is {@link GlobalMultifactorAuthenticationTrigger}.

@author Misagh Moayyed
@since 6.0.0
core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/mfa/trigger/GlobalMultifactorAuthenticationTrigger.java