public static FilterTemplate newLdaptiveSearchFilter(final String filterQuery,
                                                         final List<String> paramName,
                                                         final List<String> values) {
        val filter = new FilterTemplate();
        if (ResourceUtils.doesResourceExist(filterQuery)) {
            ApplicationContextProvider.getScriptResourceCacheManager()
                .ifPresentOrElse(cacheMgr ->
                    FunctionUtils.doUnchecked(__ -> {
                        val cacheKey = cacheMgr.computeKey(filterQuery);
                        var script = (ExecutableCompiledScript) null;
                        if (cacheMgr.containsKey(cacheKey)) {
                            script = cacheMgr.get(cacheKey);
                            LOGGER.trace("Located cached groovy script [{}] for key [{}]", script, cacheKey);
                        } else {
                            val resource = Unchecked.supplier(() -> ResourceUtils.getRawResourceFrom(filterQuery)).get();
                            LOGGER.trace("Groovy script [{}] for key [{}] is not cached", resource, cacheKey);
                            val scriptFactory = ExecutableCompiledScriptFactory.getExecutableCompiledScriptFactory();
                            script = scriptFactory.fromResource(resource);
                            cacheMgr.put(cacheKey, script);
                            LOGGER.trace("Cached groovy script [{}] for key [{}]", script, cacheKey);
                        }
                        if (script != null) {
                            val parameters = IntStream.range(0, values.size())
                                .boxed()
                                .collect(Collectors.toMap(paramName::get, values::get, (a, b) -> b, LinkedHashMap::new));
                            val args = CollectionUtils.<String, Object>wrap("filter", filter,
                                "parameters", parameters,
                                "applicationContext", ApplicationContextProvider.getApplicationContext(),
                                "logger", LOGGER);
                            script.setBinding(args);
                            script.execute(args.values().toArray(), FilterTemplate.class);
                        }
                    }),
                    () -> {
                        throw new RuntimeException("Script cache manager unavailable to handle LDAP filter");
                    });
        } else {
            filter.setFilter(filterQuery);
            if (values != null) {
                IntStream.range(0, values.size()).forEach(i -> {
                    val value = values.get(i);
                    if (filter.getFilter().contains("{" + i + '}')) {
                        filter.setParameter(i, value);
                    }
                    val name = paramName.get(i);
                    if (filter.getFilter().contains('{' + name + '}')) {
                        filter.setParameter(name, value);
                    }
                });
            }
        }

        LOGGER.debug("Constructed LDAP search filter [{}]", filter.format());
        return filter;
    }
New ldaptive search filter search filter.

@param filterQuery the filter query
@param paramName   the param name
@param values      the params
@return the search filter
support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java