@Override
        public void invoke(final Request request, final Response response) throws IOException, ServletException {
            val valve = casProperties.getServer().getTomcat().getRemoteUserValve();
            val username = request.getHeader(valve.getRemoteUserHeader());
            LOGGER.trace("Received remote user [{}] from [{}]", username, request.getRemoteAddr());
            if (StringUtils.isNotBlank(username) && RegexUtils.matchesIpAddress(valve.getAllowedIpAddressRegex(), request.getRemoteAddr())) {
                val principal = new GenericPrincipal(username);
                request.setUserPrincipal(principal);
                response.setHeader("X-Remote-User", username);
            }
            getNext().invoke(request, response);
        }
This is {@link CasTomcatServletWebServerFactoryCustomizer}.

@author Misagh Moayyed
@since 6.1.0
webapp/cas-server-webapp-init-tomcat/src/main/java/org/apereo/cas/tomcat/CasTomcatServletWebServerFactoryCustomizer.java