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 getDefaultWebUserName(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 void checkUsername(final String expected, final String name
      ); static final String CURRENT_CONF; static final String DELEGATION_PARAMETER_NAME; static final String NAMENODE_ADDRESS; }
@Test public void testRemoteAddr() { assertEquals(clientAddr, getRemoteAddr(clientAddr, null, false)); }
@Test public void testRemoteAddrWithUntrustedProxy() { assertEquals(proxyAddr, getRemoteAddr(clientAddr, proxyAddr, false)); }
@Test public void testRemoteAddrWithTrustedProxy() { assertEquals(clientAddr, getRemoteAddr(clientAddr, proxyAddr, true)); assertEquals(clientAddr, getRemoteAddr(chainedClientAddr, proxyAddr, true)); }
@Test public void testRemoteAddrWithTrustedProxyAndEmptyClient() { assertEquals(proxyAddr, getRemoteAddr(null, proxyAddr, true)); assertEquals(proxyAddr, getRemoteAddr("", proxyAddr, true)); }