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 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 configuration
      context - 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 configuration
      context - tenant context
      ruleComponentKey - rule component key (e.g., "jira.issue.created")
      Returns:
      the config (empty if none exists)
      Throws:
      SecurityException - if user lacks permission to view restrictions
      IllegalArgumentException - if ruleComponentKey is invalid
    • getRestrictedComponentsForUser

      Set<String> getRestrictedComponentsForUser(TenantContext context, ApplicationUser user)
      Evaluates which rule components are restricted for the specified user.
      Parameters:
      context - tenant context
      user - 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 configuration
      context - tenant context
      ruleComponentKey - 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 permission
      IllegalArgumentException - if ruleComponentKey is invalid or groupNames contain invalid groups
    • deleteRestrictions

      void deleteRestrictions(ApplicationUser user, TenantContext context, String ruleComponentKey)
      Deletes the restriction for a component key (making it unrestricted).
      Parameters:
      user - user attempting to modify the configuration
      context - tenant context
      ruleComponentKey - rule component key
      Throws:
      SecurityException - if user lacks system admin permission
      IllegalArgumentException - 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 configuration
      context - tenant context
      restrictions - map of component key to allowed groups (empty set = fully restricted)
      Returns:
      the updated configs
      Throws:
      SecurityException - if user lacks system admin permission
      IllegalArgumentException - 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 context
      user - the user attempting the operation (must not be null)
      rule - the rule configuration to validate
      operation - 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