@Test public void testListPrivilegesWildCard() { CommonPrivilege t1D1Select = create(new KeyValue("Server", "server1"), new KeyValue("db", "db1"), new KeyValue("table", "t1"), new KeyValue("action", "SELECT")); CommonPrivilege t1D2Select = create(new KeyValue("Server", "server1"), new KeyValue("db", "db2"), new KeyValue("table", "t1"), new KeyValue("action", "SELECT")); CommonPrivilege t2Select = create(new KeyValue("Server", "server1"), new KeyValue("db", "db1"), new KeyValue("table", "t2"), new KeyValue("action", "SELECT")); CommonPrivilege wildCardTable = create(new KeyValue("Server", "server1"), new KeyValue("db", "db1"), new KeyValue("table", "*"), new KeyValue("action", "SELECT")); CommonPrivilege allTable = create(new KeyValue("Server", "server1"), new KeyValue("db", "db1"), new KeyValue("table", "ALL"), new KeyValue("action", "SELECT")); CommonPrivilege allDatabase = create(new KeyValue("Server", "server1"), new KeyValue("db", "*")); CommonPrivilege colSelect = create(new KeyValue("Server", "server1"), new KeyValue("db", "db1"), new KeyValue("table", "t1"), new KeyValue("column", "c1"), new KeyValue("action", "SELECT")); TreePrivilegeCache cache = new TreePrivilegeCache(Sets.newHashSet(t1D1Select.toString(), t1D2Select.toString(), t2Select.toString(), wildCardTable.toString(), allTable.toString(), allDatabase.toString(), colSelect.toString()), null); assertEquals(0, cache.listPrivileges(null, null, null, new Server("server1")).size()); assertEquals(1, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db1")).size()); assertEquals(1, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db2")).size()); assertEquals(4, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db1"), new Table("t1")).size()); assertEquals(5, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db1"), new Table("*")).size()); assertEquals(5, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db1"), new Table("t1"), new Column("*")).size()); assertEquals(6, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db1"), new Table("*"), new Column("*")).size()); assertEquals(2, cache.listPrivileges(null, null, null, new Server("server1"), new Database("db2"), new Table("t1"), new Column("*")).size()); }
@Override public Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet) { return cachedPrivileges; }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet) { return cachedPrivileges; } }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet) { return cachedPrivileges; } TreePrivilegeCache(Set<String> cachedPrivileges, PrivilegeFactory inPrivilegeFactory); }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet) { return cachedPrivileges; } TreePrivilegeCache(Set<String> cachedPrivileges, PrivilegeFactory inPrivilegeFactory); @Override Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet,
    Authorizable... authorizationhierarchy); @Override Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users,
    ActiveRoleSet roleSet, Authorizable... authorizationhierarchy); @Override void close(); }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet) { return cachedPrivileges; } TreePrivilegeCache(Set<String> cachedPrivileges, PrivilegeFactory inPrivilegeFactory); @Override Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet,
    Authorizable... authorizationhierarchy); @Override Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users,
    ActiveRoleSet roleSet, Authorizable... authorizationhierarchy); @Override void close();  }