private String getRequestingUser() {
    if (theSecurityContext == null) {
      return null;
    }
    String userName = null;
    if (theSecurityContext.getUserPrincipal() == null) {
      userName = Main.UserNameHandler.getUserName(request);
    }
    else {
      userName = theSecurityContext.getUserPrincipal().getName();
    }
    if(userName == null) {
      return null;
    }
    //map hue/foo.bar@something.com->hue since user group checks
    // and config files are in terms of short name
    return UserGroupInformation.createRemoteUser(userName).getShortUserName();
  }
Get the user name from the security context, i.e. the user making the HTTP request.
With simple/pseudo security mode this should return the
value of user.name query param, in kerberos mode it's the kinit'ed user.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java