code: public static String getUserFromRequest(HttpServletRequest httpRequest) {
          String user = httpRequest.getRemoteUser();
          if (!StringUtils.isEmpty(user)) {
              return user;
          }
  
          user = httpRequest.getParameter("user.name"); // available in query-param
          if (!StringUtils.isEmpty(user)) {
              return user;
          }
  
          user = httpRequest.getHeader("Remote-User"); // backwards-compatibility
          if (!StringUtils.isEmpty(user)) {
              return user;
          }
  
          user = getDoAsUser(httpRequest);
          if (!StringUtils.isEmpty(user)) {
              return user;
          }
  
          return null;
      }
docs: Returns the user of the given request.
  
  @param httpRequest    an HTTP servlet request
  @return the user