private static boolean checkUserAgentOrClientIp(final String clientIp, final String agent,
                                                    final String mfaMethod, final String pattern) {
        if (StringUtils.isNotBlank(agent) && RegexUtils.find(pattern, agent)) {
            LOGGER.debug("Current user agent [{}] at [{}] matches the provided pattern [{}] for "
                    + "adaptive authentication and is required to use [{}]",
                agent, clientIp, pattern, mfaMethod);
            return true;
        }

        if (StringUtils.isNotBlank(clientIp) && RegexUtils.find(pattern, clientIp)) {
            LOGGER.debug("Current client IP [{}] matches the provided pattern [{}] for "
                    + "adaptive authentication and is required to use [{}]",
                clientIp, pattern, mfaMethod);
            return true;
        }
        return false;
    }
This is {@link AdaptiveMultifactorAuthenticationTrigger}.

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