@Test public void testFilterDatabasesRestrictDefaultDatabase() { final String USER1 = "user1"; MetastoreAuthzObjectFilter filter; restrictDatabaseNamesOnBinding(USER1, Arrays.asList("db1", "default")); restrictDefaultDatabase(true); filter = new MetastoreAuthzObjectFilter<String>(mockBinding, DB_NAME_EXTRACTOR); assertThat(filter.filterDatabases(USER1, Arrays.asList("db1", "default", "db4"))) .containsExactly("db4"); restrictDefaultDatabase(false); filter = new MetastoreAuthzObjectFilter<String>(mockBinding, DB_NAME_EXTRACTOR); assertThat(filter.filterDatabases(USER1, Arrays.asList("db1", "default", "db4"))) .containsExactly("default", "db4"); restrictDefaultDatabase(true); filter = new MetastoreAuthzObjectFilter(mockBinding, HIVE_OBJECT_EXTRACTOR); assertThat(filter.filterDatabases(USER1, createHivePrivilegeDatabaseList("db1", "default", "db4"))) .extracting(HiveObjectExtractor.objectName()).containsExactly("db4"); restrictDefaultDatabase(false); filter = new MetastoreAuthzObjectFilter(mockBinding, HIVE_OBJECT_EXTRACTOR); assertThat(filter.filterDatabases(USER1, createHivePrivilegeDatabaseList("db1", "default", "db4"))) .extracting(HiveObjectExtractor.objectName()).containsExactly("default", "db4"); }
public List<T> filterDatabases(String username, List<T> dbNames) { if (dbNames == null) { return Collections.emptyList(); } List<T> filteredDatabases = Lists.newArrayList(); for (T dbName : dbNames) { String objName = extractor.getDatabaseName(dbName); if (Strings.isEmpty(objName) || authorizeDatabase(username, objName)) { filteredDatabases.add(dbName); } } return filteredDatabases; }
MetastoreAuthzObjectFilter { public List<T> filterDatabases(String username, List<T> dbNames) { if (dbNames == null) { return Collections.emptyList(); } List<T> filteredDatabases = Lists.newArrayList(); for (T dbName : dbNames) { String objName = extractor.getDatabaseName(dbName); if (Strings.isEmpty(objName) || authorizeDatabase(username, objName)) { filteredDatabases.add(dbName); } } return filteredDatabases; } }
MetastoreAuthzObjectFilter { public List<T> filterDatabases(String username, List<T> dbNames) { if (dbNames == null) { return Collections.emptyList(); } List<T> filteredDatabases = Lists.newArrayList(); for (T dbName : dbNames) { String objName = extractor.getDatabaseName(dbName); if (Strings.isEmpty(objName) || authorizeDatabase(username, objName)) { filteredDatabases.add(dbName); } } return filteredDatabases; } MetastoreAuthzObjectFilter(HiveAuthzBinding authzBinding, ObjectExtractor extractor); }
MetastoreAuthzObjectFilter { public List<T> filterDatabases(String username, List<T> dbNames) { if (dbNames == null) { return Collections.emptyList(); } List<T> filteredDatabases = Lists.newArrayList(); for (T dbName : dbNames) { String objName = extractor.getDatabaseName(dbName); if (Strings.isEmpty(objName) || authorizeDatabase(username, objName)) { filteredDatabases.add(dbName); } } return filteredDatabases; } MetastoreAuthzObjectFilter(HiveAuthzBinding authzBinding, ObjectExtractor extractor); static HiveAuthzPrivileges getListDatabasesPrivileges(); HiveAuthzPrivileges getListTablePrivileges(); List<T> filterDatabases(String username, List<T> dbNames); List<T> filterTables(String username, List<T> tables); }
MetastoreAuthzObjectFilter { public List<T> filterDatabases(String username, List<T> dbNames) { if (dbNames == null) { return Collections.emptyList(); } List<T> filteredDatabases = Lists.newArrayList(); for (T dbName : dbNames) { String objName = extractor.getDatabaseName(dbName); if (Strings.isEmpty(objName) || authorizeDatabase(username, objName)) { filteredDatabases.add(dbName); } } return filteredDatabases; } MetastoreAuthzObjectFilter(HiveAuthzBinding authzBinding, ObjectExtractor extractor); static HiveAuthzPrivileges getListDatabasesPrivileges(); HiveAuthzPrivileges getListTablePrivileges(); List<T> filterDatabases(String username, List<T> dbNames); List<T> filterTables(String username, List<T> tables);  }