private static PrincipalType getPrincipalType(ASTNode principal) {
    switch (principal.getType()) {
    case HiveParser.TOK_USER:
      return PrincipalType.USER;
    case HiveParser.TOK_GROUP:
      return PrincipalType.GROUP;
    case HiveParser.TOK_ROLE:
      return PrincipalType.ROLE;
    default:
      return null;
    }
  }
Utility functions for creating objects relevant for authorization operations
from AST
ql/src/java/org/apache/hadoop/hive/ql/parse/authorization/AuthorizationParseUtils.java