@Override
    public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {
        try {
            if (request instanceof final HttpServletRequest httpServletRequest) {
                val parameterMap = httpServletRequest.getParameterMap();

                blockRequestIfNecessary(httpServletRequest);

                val parametersToCheckHere = new HashSet<String>();
                if (this.parametersToCheck.isEmpty()) {
                    parametersToCheckHere.addAll(parameterMap.keySet());
                } else {
                    parametersToCheckHere.addAll(this.parametersToCheck);
                }

                if (!this.allowMultiValueParameters) {
                    requireNotMultiValued(parametersToCheckHere, parameterMap);
                }

                enforceParameterContentCharacterRestrictions(parametersToCheckHere,
                    this.charactersToForbid, parameterMap);

                checkOnlyPostParameters(httpServletRequest.getMethod(), parameterMap, this.onlyPostParameters);
            }
        } catch (final Exception e) {
            throwException(new ServletException("This request is blocked: %s".formatted(e.getMessage()), e));
        }

        chain.doFilter(request, response);
    }
Check that some parameters should only be in POST requests (according to the configuration).

@param method             the method of the request
@param parameterMap       all the request parameters
@param onlyPostParameters parameters that should only be in POST requests
core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/filters/RequestParameterPolicyEnforcementFilter.java