Interface SecurityEnforcerHandle


public interface SecurityEnforcerHandle
SPI handle for security enforcement.

This interface defines the security enforcement contract that ActionExecutor uses. The concrete implementation (SecurityEnforcer) lives in tnsai-quality and is discovered via SpiLoader.

When tnsai-quality is not on the classpath, the factory returns a no-op handle that retains undeclared legacy behavior but rejects declared access policies.

  • Field Details

  • Method Details

    • enforceAccess

      default void enforceAccess(AccessRequest request)
      Canonical role-independent access evaluation. Implementations predating this contract cannot silently authorize declared policies. Optional providers stay outside core; the default is deliberately fail-closed.
    • enforceAccessControl

      void enforceAccessControl(ActionMetadata action, Role role, String callerAgentId, Set<String> callerRoles)
      Enforces access control based on @Security annotation.
      Parameters:
      action - the action metadata
      role - the role containing the action
      callerAgentId - the ID of the calling agent (null if unknown)
      callerRoles - the roles of the calling agent
      Throws:
      SecurityException - if access is denied
    • processParameters

      Map<String,Object> processParameters(ActionMetadata action, Role role, Map<String,Object> parameters)
      Processes parameters based on security settings.
      Parameters:
      action - the action metadata
      role - the role containing the action
      parameters - the original parameters
      Returns:
      processed parameters (encrypted if required)
    • executeWithTimeout

      <T> T executeWithTimeout(ActionMetadata action, Role role, Callable<T> task)
      Executes an action with security timeout enforcement.
      Type Parameters:
      T - the result type
      Parameters:
      action - the action metadata
      role - the role containing the action
      task - the task to execute
      Returns:
      the execution result
    • processResult

      Object processResult(ActionMetadata action, Role role, Object result)
      Processes the result based on security settings.
      Parameters:
      action - the action metadata
      role - the role containing the action
      result - the original result
      Returns:
      processed result (encrypted if required)
    • audit

      void audit(ActionMetadata action, Role role, String callerAgentId, Map<String,Object> parameters, Object result, long durationMs)
      Logs audit information based on audit level.
      Parameters:
      action - the action metadata
      role - the role containing the action
      callerAgentId - the caller agent ID
      parameters - the action parameters
      result - the action result
      durationMs - execution duration in milliseconds