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 TableapplyAcls(UserContext userContext, Table table, String name, IrisGroupProvider groupProvider, String owner, Supplier<String[]> adminGroupSupplier) Apply both Row and Column ACLs to the specified table.static TableapplyUserPermissions(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.AccessTypecheckAccess(PermissionFilterProvider pfp, Database db, UserContext userContext, String namespace, String tableName) Check if the user associated with thisPermissionFilterProvidercan access the specified table.static FilterGenerator.AccessTypecheckAccess(PermissionFilterProvider pfp, Collection<FilterGenerator> generators, Database db, UserContext userContext, String namespace, String tableName, boolean isDisjunctive) Check if the user associated with thisPermissionFilterProvidercan access the specified table.createGroupToColumnToAclMap(UserContext userContext, String namespace, String tableName, Map<String, List<com.fishlib.base.Pair<String, String>>> rawAcls) Given a mapping from group to list of Column ACL definitions, produce a mapping of groups to ACLs by column set.static Collection<SelectFilter>generateFilterSetForACL(PermissionFilterProvider provider, Database database, String namespace, String tableName, String acl, UserContext effectiveUserContext) Generate the collection of filters for the specified ACL string.static ColumnACLDefinitiongetColumnACLsForTable(Database database, String namespace, String tableName, String[] columnNames, boolean isRefreshing, Map<String, List<com.fishlib.base.Pair<String, String>>> rawAcls, UserContext userContext, PermissionFilterProvider provider) static booleanhasTableAcls(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, 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 aColumnACLDefinitionfrom 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 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 UserContext userContext, @NotNull String namespace, @NotNull String tableName) Check if the user associated with thisPermissionFilterProvidercan 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.AccessTypethe user has for the specified table
-
checkAccess
public static FilterGenerator.AccessType checkAccess(@NotNull PermissionFilterProvider pfp, @NotNull Collection<FilterGenerator> generators, @NotNull Database db, @NotNull UserContext userContext, @NotNull String namespace, @NotNull String tableName, boolean isDisjunctive) Check if the user associated with thisPermissionFilterProvidercan access the specified table.- Parameters:
db- the database objectnamespace- the namespacetableName- the name of the table- Returns:
- the
FilterGenerator.AccessTypethe 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 UserContext effectiveUserContext) Generate the collection of filters for the specified ACL string.- Parameters:
provider- thePermissionFilterProviderto usedatabase- theDatabaseobject 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
SelectFilters 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 UserContext userContext, @NotNull PermissionFilterProvider provider) -
createGroupToColumnToAclMap
@NotNull public static Map<String,Map<String, createGroupToColumnToAclMapCollection<String>>> (UserContext userContext, String namespace, String tableName, Map<String, List<com.fishlib.base.Pair<String, String>>> rawAcls) Given a mapping from group to list of Column ACL definitions, produce a mapping of groups to ACLs by column set.- Parameters:
userContext- the user fetching the ACLnamespace- the namespace of the tabletableName- the table namerawAcls- the raw ACLs by group.- Returns:
- a new mapping of group to map(Columns to ACLs)
-
makeColumnACLs
public static <ACL_DEF,FILTER, RESULT makeColumnACLsRESULT> (@NotNull Map<String, Map<String, Collection<ACL_DEF>>> aclsByGroupAndColumn, @NotNull Database database, @NotNull PermissionFilterProvider provider, @NotNull 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 aColumnACLDefinitionfrom 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
-