private static String normalizeHostname(String name) {
    try {
      InetAddress address = InetAddress.getByName( 
          "localhost".equalsIgnoreCase(name) ? null : name);
      return address.getCanonicalHostName();
    }
    catch (UnknownHostException ex) {
      LOG.warn(MessageFormat.format("Unable to normalize hostname [{0}]", name));
      return null;
    }
  }
Verifies a that proxyUser is making the request from authorized host and that doAs user
belongs to one of the groups for which proxyUser is allowed to impersonate users.

@param proxyUser user name of the proxy (logged in) user.
@param proxyHost host the proxy user is making the request from.
@param doAsUser user the proxy user is impersonating.
@throws NotAuthorizedException thrown if the user is not allowed to perform the proxyuser request.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/ProxyUserSupport.java