code: public boolean shouldRedirectToHttps(WebRequest webRequest) {
          HttpServletRequest req = webRequest.getHttpServletRequest();
          return !req.isSecure() && webRequest.isSSLRequired();
      }
docs: Determines if HTTPS redirect is required for this request.
  
  @param webRequest
  @return {@code true} if the request requires SSL but the request is not secure, {@code false} otherwise.