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

        val mfa = casProperties.getAuthn().getMfa().getTriggers().getAuthentication();
        val globalAuthenticationAttributeValueRegex = mfa.getGlobalAuthenticationAttributeValueRegex();
        val attributeNames = commaDelimitedListToSet(mfa.getGlobalAuthenticationAttributeNameTriggers());

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

        if (attributeNames.isEmpty()) {
            LOGGER.trace("Authentication attribute name to determine event is not configured");
            return Optional.empty();
        }

        val providerMap = MultifactorAuthenticationUtils.getAvailableMultifactorAuthenticationProviders(applicationContext);
        if (providerMap.isEmpty()) {
            LOGGER.error("No multifactor authentication providers are available in the application context");
            return Optional.empty();
        }

        val providers = providerMap.values();
        if (providers.size() == 1 && StringUtils.isNotBlank(globalAuthenticationAttributeValueRegex)) {
            val provider = providers.iterator().next();
            LOGGER.debug("Found a single multifactor provider [{}] in the application context", provider);
            val result = multifactorAuthenticationProviderResolver.resolveEventViaAuthenticationAttribute(
                authentication, attributeNames, registeredService, service, Optional.empty(), providers,
                (attributeValue, mfaProvider) -> attributeValue != null && attributeValue.matches(globalAuthenticationAttributeValueRegex));
            if (result != null && !result.isEmpty()) {
                return Optional.of(provider);
            }
        }

        val result = multifactorAuthenticationProviderResolver.resolveEventViaAuthenticationAttribute(authentication, attributeNames,
            registeredService, service, Optional.empty(), providers,
            (attributeValue, mfaProvider) -> attributeValue != null && mfaProvider.matches(attributeValue));
        if (result != null && !result.isEmpty()) {
            val id = CollectionUtils.firstElement(result);
            return id.flatMap(value -> MultifactorAuthenticationUtils.getMultifactorAuthenticationProviderById(value.toString(), applicationContext));
        }
        return Optional.empty();
    }
This is {@link AuthenticationAttributeMultifactorAuthenticationTrigger}.

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