HiveMetaStoreAuthzInfo buildAuthzContext(PreEventContext preEventContext) throws MetaException {
    LOG.debug("==> HiveMetaStoreAuthorizer.buildAuthzContext(): EventType=" + preEventContext.getEventType());

    HiveMetaStoreAuthorizableEvent authzEvent = null;

    if (preEventContext != null) {

      switch (preEventContext.getEventType()) {
        case CREATE_DATABASE:
          authzEvent = new CreateDatabaseEvent(preEventContext);
          break;
        case ALTER_DATABASE:
          authzEvent = new AlterDatabaseEvent(preEventContext);
          break;
        case DROP_DATABASE:
          authzEvent = new DropDatabaseEvent(preEventContext);
          break;
        case CREATE_TABLE:
          authzEvent = new CreateTableEvent(preEventContext);
          if (isViewOperation(preEventContext) && (!isSuperUser(getCurrentUser(authzEvent)))) {
            //we allow view to be created, but mark it as having not been authorized
            PreCreateTableEvent pcte = (PreCreateTableEvent)preEventContext;
            Map<String, String> params = pcte.getTable().getParameters();
            params.put("Authorized", "false");
          }
          break;
        case ALTER_TABLE:
          authzEvent = new AlterTableEvent(preEventContext);
          if (isViewOperation(preEventContext) && (!isSuperUser(getCurrentUser(authzEvent)))) {
            //we allow view to be altered, but mark it as having not been authorized
            PreAlterTableEvent pcte = (PreAlterTableEvent)preEventContext;
            Map<String, String> params = pcte.getNewTable().getParameters();
            params.put("Authorized", "false");
          }
          break;
        case DROP_TABLE:
          authzEvent = new DropTableEvent(preEventContext);
          if (isViewOperation(preEventContext) && (!isSuperUser(getCurrentUser(authzEvent)))) {
            //TODO: do we need to check Authorized flag?
          }
          break;
        case ADD_PARTITION:
          authzEvent = new AddPartitionEvent(preEventContext);
          break;
        case ALTER_PARTITION:
          authzEvent = new AlterPartitionEvent(preEventContext);
          break;
        case LOAD_PARTITION_DONE:
          authzEvent = new LoadPartitionDoneEvent(preEventContext);
          break;
        case DROP_PARTITION:
          authzEvent = new DropPartitionEvent(preEventContext);
          break;
        case READ_TABLE:
          authzEvent = new ReadTableEvent(preEventContext);
          break;
        case READ_DATABASE:
          authzEvent = new ReadDatabaseEvent(preEventContext);
          break;
        case CREATE_FUNCTION:
          authzEvent = new CreateFunctionEvent(preEventContext);
          break;
        case DROP_FUNCTION:
          authzEvent = new DropFunctionEvent(preEventContext);
          break;
        case CREATE_DATACONNECTOR:
          authzEvent = new CreateDataConnectorEvent(preEventContext);
          break;
        case ALTER_DATACONNECTOR:
          authzEvent = new AlterDataConnectorEvent(preEventContext);
          break;
        case DROP_DATACONNECTOR:
          authzEvent = new DropDataConnectorEvent(preEventContext);
          break;
        case AUTHORIZATION_API_CALL:
        case READ_ISCHEMA:
        case CREATE_ISCHEMA:
        case DROP_ISCHEMA:
        case ALTER_ISCHEMA:
        case ADD_SCHEMA_VERSION:
        case ALTER_SCHEMA_VERSION:
        case DROP_SCHEMA_VERSION:
        case READ_SCHEMA_VERSION:
        case CREATE_CATALOG:
        case ALTER_CATALOG:
        case DROP_CATALOG:
          if (!isSuperUser(getCurrentUser())) {
            throw new MetaException(getErrorMessage(preEventContext, getCurrentUser()));
          }
          break;
        default:
          break;
       }
    }

    HiveMetaStoreAuthzInfo ret = authzEvent != null ? authzEvent.getAuthzContext() : null;

    LOG.debug("<== HiveMetaStoreAuthorizer.buildAuthzContext(): EventType=" + preEventContext.getEventType() + "; ret=" + ret);

    return ret;
  }
HiveMetaStoreAuthorizer :  Do authorization checks on MetaStore Events in MetaStorePreEventListener
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/HiveMetaStoreAuthorizer.java