public String getRealUsername(ViewContext context) {
    String username = context.getProperties().get("webhdfs.proxyuser");
    if (username == null || username.isEmpty())
      try {
        username = UserGroupInformation.getCurrentUser().getShortUserName();
      } catch (IOException e) {
        throw new ServiceFormattedException("HdfsApi connection failed. Can't get current user", e);
      }
    return username;
  }
Get proxyuser username to use in HDFS
@param context View Context instance
@return user name
contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/HdfsService.java