@Override
    public Optional<MultifactorAuthenticationProvider> isActivated(final Authentication authentication,
                                                                   final RegisteredService registeredService,
                                                                   final HttpServletRequest httpServletRequest,
                                                                   final HttpServletResponse response,
                                                                   final Service service) {
        if (authentication == null) {
            LOGGER.debug("No authentication is available to determine event for principal");
            return Optional.empty();
        }

        val principal = getPrincipalForMultifactorAuthentication(authentication);
        val result = resolveMultifactorAuthenticationProvider(Optional.empty(), registeredService, service, principal);
        if (result != null && !result.isEmpty()) {
            val id = CollectionUtils.firstElement(result);
            return id.flatMap(o -> MultifactorAuthenticationUtils.getMultifactorAuthenticationProviderById(o.toString(), applicationContext));
        }

        return Optional.empty();
    }
This is {@link PrincipalAttributeMultifactorAuthenticationTrigger}.

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