code: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          ServletRequest xRequest;
          if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
              if (!request.isSecure() && matchesOne(request.getRemoteAddr(), securedRemoteAddresses)) {
                  xRequest = new HttpServletRequestWrapper((HttpServletRequest) request) {
                      @Override
                      public boolean isSecure() {
                          return true;
                      }
                  };
              } else {
                  xRequest = request;
              }
              if (logger.isDebugEnabled()) {
                  logger.debug("Incoming request uri=" + ((HttpServletRequest) request).getRequestURI() + " with originalSecure='"
                          + request.isSecure() + "', remoteAddr='" + request.getRemoteAddr() + "' will be seen with newSecure='"
                          + xRequest.isSecure() + "'");
              }
          } else {
              xRequest = request;
          }
  
          chain.doFilter(xRequest, response);
      }
docs: If incoming remote address matches one of the declared IP pattern, wraps
  the incoming {@link HttpServletRequest} to override
  {@link HttpServletRequest#isSecure()} to set it to <code>true</code>.