@Test public void testRemoteAddrWithTrustedProxy() { assertEquals(clientAddr, getRemoteAddr(clientAddr, proxyAddr, true)); assertEquals(clientAddr, getRemoteAddr(chainedClientAddr, proxyAddr, true)); }
public static String getRemoteAddr(HttpServletRequest request) { String remoteAddr = request.getRemoteAddr(); String proxyHeader = request.getHeader("X-Forwarded-For"); if (proxyHeader != null && ProxyServers.isProxyServer(remoteAddr)) { final String clientAddr = proxyHeader.split(",")[0].trim(); if (!clientAddr.isEmpty()) { remoteAddr = clientAddr; } } return remoteAddr; }
JspHelper { public static String getRemoteAddr(HttpServletRequest request) { String remoteAddr = request.getRemoteAddr(); String proxyHeader = request.getHeader("X-Forwarded-For"); if (proxyHeader != null && ProxyServers.isProxyServer(remoteAddr)) { final String clientAddr = proxyHeader.split(",")[0].trim(); if (!clientAddr.isEmpty()) { remoteAddr = clientAddr; } } return remoteAddr; } }
JspHelper { public static String getRemoteAddr(HttpServletRequest request) { String remoteAddr = request.getRemoteAddr(); String proxyHeader = request.getHeader("X-Forwarded-For"); if (proxyHeader != null && ProxyServers.isProxyServer(remoteAddr)) { final String clientAddr = proxyHeader.split(",")[0].trim(); if (!clientAddr.isEmpty()) { remoteAddr = clientAddr; } } return remoteAddr; } private  JspHelper(); }
JspHelper { public static String getRemoteAddr(HttpServletRequest request) { String remoteAddr = request.getRemoteAddr(); String proxyHeader = request.getHeader("X-Forwarded-For"); if (proxyHeader != null && ProxyServers.isProxyServer(remoteAddr)) { final String clientAddr = proxyHeader.split(",")[0].trim(); if (!clientAddr.isEmpty()) { remoteAddr = clientAddr; } } return remoteAddr; } private  JspHelper(); static String canonicalize(String addr); static DatanodeInfo bestNode(LocatedBlocks blks, Configuration conf); static DatanodeInfo bestNode(LocatedBlock blk, Configuration conf); static void streamBlockInAscii(InetSocketAddress addr, String poolId,
      long blockId, final Token<BlockTokenIdentifier> blockToken, long genStamp,
      long blockSize, long offsetIntoBlock, long chunkSizeToView,
      JspWriter out, final Configuration conf, DFSClient.Conf dfsConf,
      final DFSClient dfs, final SaslDataTransferClient saslClient); static void addTableHeader(JspWriter out); static void addTableRow(JspWriter out, String[] columns); static void addTableRow(JspWriter out, String[] columns, int row); static void addTableFooter(JspWriter out); static void sortNodeList(final List<DatanodeDescriptor> nodes,
                           String field, String order); static void printPathWithLinks(String dir, JspWriter out, 
                                        int namenodeInfoPort,
                                        String tokenString,
                                        String nnAddress
                                        ); static void printGotoForm(JspWriter out,
                                   int namenodeInfoPort,
                                   String tokenString,
                                   String file,
                                   String nnAddress); static void createTitle(JspWriter out, 
                                 HttpServletRequest req, 
                                 String  file); static int string2ChunkSizeToView(String s, int defaultValue); static String getVersionTable(); static String validatePath(String p); static Long validateLong(String value); static String validateURL(String value); static UserGroupInformation getDefaultWebUser(Configuration conf
                                                       ); static UserGroupInformation getUGI(HttpServletRequest request,
      Configuration conf); static UserGroupInformation getUGI(ServletContext context,
      HttpServletRequest request, Configuration conf); static UserGroupInformation getUGI(ServletContext context,
      HttpServletRequest request, Configuration conf,
      final AuthenticationMethod secureAuthMethod,
      final boolean tryUgiParameter); static String getRemoteAddr(HttpServletRequest request); static String getDelegationTokenUrlParam(String tokenString); static String getUrlParam(String name, String val, String paramSeparator); static String getUrlParam(String name, String val, boolean firstParam); static String getUrlParam(String name, String val); }
JspHelper { public static String getRemoteAddr(HttpServletRequest request) { String remoteAddr = request.getRemoteAddr(); String proxyHeader = request.getHeader("X-Forwarded-For"); if (proxyHeader != null && ProxyServers.isProxyServer(remoteAddr)) { final String clientAddr = proxyHeader.split(",")[0].trim(); if (!clientAddr.isEmpty()) { remoteAddr = clientAddr; } } return remoteAddr; } private  JspHelper(); static String canonicalize(String addr); static DatanodeInfo bestNode(LocatedBlocks blks, Configuration conf); static DatanodeInfo bestNode(LocatedBlock blk, Configuration conf); static void streamBlockInAscii(InetSocketAddress addr, String poolId,
      long blockId, final Token<BlockTokenIdentifier> blockToken, long genStamp,
      long blockSize, long offsetIntoBlock, long chunkSizeToView,
      JspWriter out, final Configuration conf, DFSClient.Conf dfsConf,
      final DFSClient dfs, final SaslDataTransferClient saslClient); static void addTableHeader(JspWriter out); static void addTableRow(JspWriter out, String[] columns); static void addTableRow(JspWriter out, String[] columns, int row); static void addTableFooter(JspWriter out); static void sortNodeList(final List<DatanodeDescriptor> nodes,
                           String field, String order); static void printPathWithLinks(String dir, JspWriter out, 
                                        int namenodeInfoPort,
                                        String tokenString,
                                        String nnAddress
                                        ); static void printGotoForm(JspWriter out,
                                   int namenodeInfoPort,
                                   String tokenString,
                                   String file,
                                   String nnAddress); static void createTitle(JspWriter out, 
                                 HttpServletRequest req, 
                                 String  file); static int string2ChunkSizeToView(String s, int defaultValue); static String getVersionTable(); static String validatePath(String p); static Long validateLong(String value); static String validateURL(String value); static UserGroupInformation getDefaultWebUser(Configuration conf
                                                       ); static UserGroupInformation getUGI(HttpServletRequest request,
      Configuration conf); static UserGroupInformation getUGI(ServletContext context,
      HttpServletRequest request, Configuration conf); static UserGroupInformation getUGI(ServletContext context,
      HttpServletRequest request, Configuration conf,
      final AuthenticationMethod secureAuthMethod,
      final boolean tryUgiParameter); static String getRemoteAddr(HttpServletRequest request); static String getDelegationTokenUrlParam(String tokenString); static String getUrlParam(String name, String val, String paramSeparator); static String getUrlParam(String name, String val, boolean firstParam); static String getUrlParam(String name, String val); static final String CURRENT_CONF; static final String DELEGATION_PARAMETER_NAME; static final String NAMENODE_ADDRESS; }