@Override
  public final List<Database> filterDatabaseObjects(List<Database> databases) throws MetaException {
    LOG.debug("==> HiveMetaStoreAuthorizer.filterDatabaseObjects()");
    if (CollectionUtils.isEmpty(databases)) {
      return Collections.emptyList();
    }

    try {
      DatabaseFilterContext databaseFilterContext = DatabaseFilterContext.createFromDatabases(databases);
      HiveMetaStoreAuthzInfo hiveMetaStoreAuthzInfo = databaseFilterContext.getAuthzContext();

      HiveAuthorizer hiveAuthorizer = createHiveMetaStoreAuthorizer();
      List<HivePrivilegeObject> hivePrivilegeObjects = hiveMetaStoreAuthzInfo.getInputHObjs();
      HiveAuthzContext hiveAuthzContext = hiveMetaStoreAuthzInfo.getHiveAuthzContext();

      List<HivePrivilegeObject> filteredHivePrivilegeObjects =
          hiveAuthorizer.filterListCmdObjects(hivePrivilegeObjects, hiveAuthzContext);

      if (CollectionUtils.isEmpty(filteredHivePrivilegeObjects)) {
        return Collections.emptyList();
      }

      Set<String> filteredDbNames = filteredHivePrivilegeObjects.stream()
          .map(HivePrivilegeObject::getDbname)
          .collect(Collectors.toSet());

      List<Database> result = databases.stream()
          .filter(db -> filteredDbNames.contains(db.getName()))
          .collect(Collectors.toList());

      LOG.info(String.format("Filtered %d database objects out of %d", result.size(), databases.size()));
      return result;
    } catch (Exception e) {
      LOG.error("Error in HiveMetaStoreAuthorizer.filterDatabaseObjects(): " + e.getMessage(), e);
      throw new MetaException("Error in HiveMetaStoreAuthorizer.filterDatabaseObjects(): " + e.getMessage());
    } finally {
      LOG.debug("<== HiveMetaStoreAuthorizer.filterDatabaseObjects()");
    }
  }
HiveMetaStoreAuthorizer :  Do authorization checks on MetaStore Events in MetaStorePreEventListener
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/HiveMetaStoreAuthorizer.java