Class AclHelper
java.lang.Object
com.illumon.iris.db.v2.permissions.AclHelper
This purely static class centralizes the logic around table row/column ACL application.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Table
applyAcls
(io.deephaven.enterprise.auth.UserContext userContext, Table table, String name, IrisGroupProvider groupProvider, String owner, Supplier<String[]> adminGroupSupplier) Apply both Row and Column ACLs to the specified table.static Table
applyUserPermissions
(Database database, String namespace, String tableName, Table table, boolean refreshing, PermissionFilterProvider permissionFilterProvider) Apply system-level table ACLs (both row and column based) to the specified table.static FilterGenerator.AccessType
checkAccess
(PermissionFilterProvider pfp, Database db, io.deephaven.enterprise.auth.UserContext userContext, String namespace, String tableName) Check if the user associated with thisPermissionFilterProvider
can access the specified table.static FilterGenerator.AccessType
checkAccess
(PermissionFilterProvider pfp, Collection<FilterGenerator> generators, Database db, io.deephaven.enterprise.auth.UserContext userContext, String namespace, String tableName, boolean isDisjunctive) Check if the user associated with thisPermissionFilterProvider
can access the specified table.createGroupToColumnToAclMap
(String namespace, String tableName, Map<String, List<com.fishlib.base.Pair<String, String>>> rawAcls) static Collection<SelectFilter>
generateFilterSetForACL
(PermissionFilterProvider provider, Database database, String namespace, String tableName, String acl, io.deephaven.enterprise.auth.UserContext effectiveUserContext) Generate the collection of filters for the specified ACL string.static ColumnACLDefinition
getColumnACLsForTable
(Database database, String namespace, String tableName, String[] columnNames, boolean isRefreshing, Map<String, List<com.fishlib.base.Pair<String, String>>> rawAcls, io.deephaven.enterprise.auth.UserContext userContext, PermissionFilterProvider provider) static boolean
hasTableAcls
(Table table) Check if the specified table has ACLs at the table level.static <ACL_DEF,
FILTER, RESULT>
RESULTmakeColumnACLs
(Map<String, Map<String, Collection<ACL_DEF>>> aclsByGroupAndColumn, Database database, PermissionFilterProvider provider, io.deephaven.enterprise.auth.UserContext context, String namespace, String tableName, String[] columnNames, boolean refreshing, AclHelper.FilterFactory<FILTER, ACL_DEF> filterFactory, BiFunction<Map<String, io.deephaven.shadow.fastutil.it.unimi.dsi.fastutil.ints.IntSet>, List<FILTER[]>, RESULT> resultFactory) Create aColumnACLDefinition
from a set of ACLs grouped by group, and then column.
-
Constructor Details
-
AclHelper
public AclHelper()
-
-
Method Details
-
applyUserPermissions
public static Table applyUserPermissions(@NotNull Database database, String namespace, String tableName, @NotNull Table table, boolean refreshing, @NotNull PermissionFilterProvider permissionFilterProvider) Apply system-level table ACLs (both row and column based) to the specified table.- Parameters:
database
- the database for the tablenamespace
- the namespace of the tabletableName
- the name of the tabletable
- the table to apply ACLs torefreshing
- if the table is refreshingpermissionFilterProvider
- a permission filter provider for the system's configured ACL store- Returns:
- the input table with ACLs applied
- Throws:
TableAccessException
- if the table may not be accessed.
-
hasTableAcls
Check if the specified table has ACLs at the table level.- Parameters:
table
- the table to check for ACLs- Returns:
- if the table has ACLs
-
applyAcls
public static Table applyAcls(@Nullable io.deephaven.enterprise.auth.UserContext userContext, @NotNull Table table, String name, @NotNull IrisGroupProvider groupProvider, @NotNull String owner, @NotNull Supplier<String[]> adminGroupSupplier) throws TableAccessException Apply both Row and Column ACLs to the specified table.- Parameters:
userContext
- the user trying to access the tabletable
- the tablename
- the name of the table (if any)groupProvider
- the source of group informationowner
- the owner of the sourceadminGroupSupplier
- a supplier to find admin groups- Returns:
- the table with ACLs applied, or the original table if there were no ACLs.
- Throws:
TableAccessException
- if the user may not access the table.
-
checkAccess
public static FilterGenerator.AccessType checkAccess(@NotNull PermissionFilterProvider pfp, @NotNull Database db, @NotNull io.deephaven.enterprise.auth.UserContext userContext, @NotNull String namespace, @NotNull String tableName) Check if the user associated with thisPermissionFilterProvider
can access the specified table.- Parameters:
pfp
- the PermissionFilterProvider to use for accessing ACL informationdb
- the database objectuserContext
- the user to check access fornamespace
- the namespacetableName
- the name of the table- Returns:
- the
FilterGenerator.AccessType
the user has for the specified table
-
checkAccess
public static FilterGenerator.AccessType checkAccess(@NotNull PermissionFilterProvider pfp, @NotNull Collection<FilterGenerator> generators, @NotNull Database db, @NotNull io.deephaven.enterprise.auth.UserContext userContext, @NotNull String namespace, @NotNull String tableName, boolean isDisjunctive) Check if the user associated with thisPermissionFilterProvider
can access the specified table.- Parameters:
db
- the database objectnamespace
- the namespacetableName
- the name of the table- Returns:
- the
FilterGenerator.AccessType
the user has for the specified table
-
generateFilterSetForACL
public static Collection<SelectFilter> generateFilterSetForACL(@NotNull PermissionFilterProvider provider, @NotNull Database database, String namespace, String tableName, @NotNull String acl, @NotNull io.deephaven.enterprise.auth.UserContext effectiveUserContext) Generate the collection of filters for the specified ACL string.- Parameters:
provider
- thePermissionFilterProvider
to usedatabase
- theDatabase
object for generationnamespace
- the namespace of the tabletableName
- the name of the tableacl
- the ACL stringeffectiveUserContext
- the user ACLs are being generated for- Returns:
- a collection of
SelectFilter
s representing the ACL filter for the specified user and ACL string.
-
getColumnACLsForTable
public static ColumnACLDefinition getColumnACLsForTable(@NotNull Database database, String namespace, String tableName, @NotNull String[] columnNames, boolean isRefreshing, @NotNull Map<String, List<com.fishlib.base.Pair<String, String>>> rawAcls, @NotNull io.deephaven.enterprise.auth.UserContext userContext, @NotNull PermissionFilterProvider provider) -
createGroupToColumnToAclMap
-
makeColumnACLs
public static <ACL_DEF,FILTER, RESULT makeColumnACLsRESULT> (@NotNull Map<String, Map<String, Collection<ACL_DEF>>> aclsByGroupAndColumn, @NotNull Database database, @NotNull PermissionFilterProvider provider, @NotNull io.deephaven.enterprise.auth.UserContext context, @Nullable String namespace, @Nullable String tableName, @NotNull String[] columnNames, boolean refreshing, @NotNull AclHelper.FilterFactory<FILTER, ACL_DEF> filterFactory, @NotNull BiFunction<Map<String, io.deephaven.shadow.fastutil.it.unimi.dsi.fastutil.ints.IntSet>, List<FILTER[]>, RESULT> resultFactory) Create aColumnACLDefinition
from a set of ACLs grouped by group, and then column. Users must provide a method to filter out undesired groups, as well as a method to interpret the input filter generator representation into an actualFilterGenerator
.- Parameters:
aclsByGroupAndColumn
- The ACLs grouped by group then column.database
- the databaseprovider
- the permission providercontext
- the user to get ACLs fornamespace
- the namespace of the tabletableName
- the name of the tablecolumnNames
- the column names to locate ACLs forrefreshing
- if the table is refreshing- Returns:
- a completed
ColumnACLDefinition
-