Interface RuleComponentRestrictionService
- All Known Implementing Classes:
JiraRuleComponentRestrictionService
public interface RuleComponentRestrictionService
Service for managing and evaluating instance-wide rule component restrictions.
Read operations require global admin permissions. Write operations require system admin permissions. Per-user restriction evaluation does not require admin permissions.
Permission violations throw SecurityException.
Invalid input throws IllegalArgumentException.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteRestrictions(ApplicationUser user, TenantContext context, String ruleComponentKey) Deletes the restriction for a component key (making it unrestricted).getAllRestrictionConfigs(ApplicationUser user, TenantContext context) Returns all restriction configs (including group allow-lists and metadata).getRestrictedComponentsForUser(TenantContext context, ApplicationUser user) Evaluates which rule components are restricted for the specified user.getRestrictionConfig(ApplicationUser user, TenantContext context, String ruleComponentKey) Returns restriction config for a specific component key.replaceAllRestrictions(ApplicationUser user, TenantContext context, Map<String, Set<String>> restrictions) Replaces all restrictions with the provided map.setRestrictions(ApplicationUser user, TenantContext context, String ruleComponentKey, Set<String> groupNames) Creates or updates a restriction for a component key.validateRuleForUser(TenantContext context, ApplicationUser user, com.codebarrel.automation.api.config.RuleConfigBean rule, String operation) Validates that the given rule does not contain any restricted components for the user.
-
Method Details
-
getAllRestrictionConfigs
Map<String,RuleComponentRestrictionConfig> getAllRestrictionConfigs(ApplicationUser user, TenantContext context) Returns all restriction configs (including group allow-lists and metadata).- Parameters:
user- user requesting the configurationcontext- tenant context- Returns:
- the restriction configs
- Throws:
SecurityException- if user lacks permission to view restrictions
-
getRestrictionConfig
Optional<RuleComponentRestrictionConfig> getRestrictionConfig(ApplicationUser user, TenantContext context, String ruleComponentKey) Returns restriction config for a specific component key.- Parameters:
user- user requesting the configurationcontext- tenant contextruleComponentKey- rule component key (e.g., "jira.issue.created")- Returns:
- the config (empty if none exists)
- Throws:
SecurityException- if user lacks permission to view restrictionsIllegalArgumentException- if ruleComponentKey is invalid
-
getRestrictedComponentsForUser
Evaluates which rule components are restricted for the specified user.- Parameters:
context- tenant contextuser- user to evaluate restrictions for- Returns:
- restricted component keys for the user
-
setRestrictions
RuleComponentRestrictionConfig setRestrictions(ApplicationUser user, TenantContext context, String ruleComponentKey, Set<String> groupNames) Creates or updates a restriction for a component key.- Parameters:
user- user attempting to modify the configurationcontext- tenant contextruleComponentKey- rule component key (e.g., "jira.issue.created")groupNames- allowed group names (empty = fully restricted)- Returns:
- the updated restriction config
- Throws:
SecurityException- if user lacks system admin permissionIllegalArgumentException- if ruleComponentKey is invalid or groupNames contain invalid groups
-
deleteRestrictions
Deletes the restriction for a component key (making it unrestricted).- Parameters:
user- user attempting to modify the configurationcontext- tenant contextruleComponentKey- rule component key- Throws:
SecurityException- if user lacks system admin permissionIllegalArgumentException- if ruleComponentKey is invalid
-
replaceAllRestrictions
Map<String,RuleComponentRestrictionConfig> replaceAllRestrictions(ApplicationUser user, TenantContext context, Map<String, Set<String>> restrictions) Replaces all restrictions with the provided map.- Parameters:
user- user attempting to modify the configurationcontext- tenant contextrestrictions- map of component key to allowed groups (empty set = fully restricted)- Returns:
- the updated configs
- Throws:
SecurityException- if user lacks system admin permissionIllegalArgumentException- if any component key or group name is invalid
-
validateRuleForUser
Optional<ComponentRestrictionViolation> validateRuleForUser(TenantContext context, ApplicationUser user, com.codebarrel.automation.api.config.RuleConfigBean rule, String operation) Validates that the given rule does not contain any restricted components for the user.Returns empty if the user is allowed to interact with the rule (no restricted components found in the rule). Returns a violation if the rule contains components that are restricted for the user.
This method also emits an audit event if a violation is detected.
- Parameters:
context- tenant contextuser- the user attempting the operation (must not be null)rule- the rule configuration to validateoperation- the operation being attempted (e.g., "CREATE", "UPDATE", "ENABLE")- Returns:
- empty if validation passes, or a violation containing restricted component details
- Throws:
NullPointerException- if user is null
-