public static String getUserNameFromPrincipal(String principal) {
    // Based on SecurityUtil.
    if (principal == null) return null;
    String[] components = principal.split("[/@]");
    return (components == null || components.length != 3) ? principal : components[0];
  }
Login using kerberos and also updates the current logged in user

@param principal  - kerberos principal
@param keytabFile - keytab file
@throws IOException - if keytab file cannot be found
llap-common/src/java/org/apache/hadoop/hive/llap/LlapUtil.java