@Override
    public MultifactorAuthenticationProvider resolve(final Collection<MultifactorAuthenticationProvider> providers,
                                                     final RegisteredService service, final Principal principal) throws Throwable {
        val args = new Object[]{service, principal, providers, LOGGER};
        LOGGER.debug("Invoking Groovy script with service=[{}], principal=[{}], providers=[{}]", service, principal, providers);
        val provider = watchableScript.execute(args, String.class);
        if (StringUtils.isBlank(provider)) {
            LOGGER.debug("Multifactor provider selection script did not return a provider id");
            return null;
        }
        return providers
            .stream()
            .filter(p -> p.getId().equals(provider))
            .findFirst()
            .orElse(null);
    }
This is {@link GroovyScriptMultifactorAuthenticationProviderSelector}.

@author Misagh Moayyed
@since 5.1.0
core/cas-server-core-webflow-mfa-api/src/main/java/org/apereo/cas/web/flow/authentication/GroovyScriptMultifactorAuthenticationProviderSelector.java