public UserGroupInformation getCurrentUGIWithConf(String authMethod)
      throws IOException {
    UserGroupInformation ugi;
    try {
      ugi = UserGroupInformation.getCurrentUser();
    } catch(IOException e) {
      throw new IllegalStateException("Unable to get current user: " + e, e);
    }
    if (loginUserHasCurrentAuthMethod(ugi, authMethod)) {
      LOG.debug("Not setting UGI conf as passed-in authMethod of {} = current",
          authMethod);
      return ugi;
    } else {
      LOG.debug("Setting UGI conf as passed-in authMethod of {} != current",
          authMethod);
      Configuration conf = new Configuration();
      conf.set(HADOOP_SECURITY_AUTHENTICATION, authMethod);
      UserGroupInformation.setConfiguration(conf);
      return UserGroupInformation.getCurrentUser();
    }
  }
Method to get canonical-ized hostname, given a hostname (possibly a CNAME).
This should allow for service-principals to use simplified CNAMEs.
@param hostName The hostname to be canonical-ized.
@return Given a CNAME, the canonical-ized hostname is returned. If not found, the original hostname is returned.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java