Package com.tnsai.security
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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFactory for creating SecurityEnforcerHandle instances. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SecurityEnforcerHandleNo-op implementation used when tnsai-quality is absent. -
Method Summary
Modifier and TypeMethodDescriptionvoidaudit(ActionMetadata action, Role role, String callerAgentId, Map<String, Object> parameters, Object result, long durationMs) Logs audit information based on audit level.default voidenforceAccess(AccessRequest request) Canonical role-independent access evaluation.voidenforceAccessControl(ActionMetadata action, Role role, String callerAgentId, Set<String> callerRoles) Enforces access control based on @Security annotation.<T> TexecuteWithTimeout(ActionMetadata action, Role role, Callable<T> task) Executes an action with security timeout enforcement.processParameters(ActionMetadata action, Role role, Map<String, Object> parameters) Processes parameters based on security settings.processResult(ActionMetadata action, Role role, Object result) Processes the result based on security settings.
-
Field Details
-
NOOP
No-op implementation used when tnsai-quality is absent.
-
-
Method Details
-
enforceAccess
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 metadatarole- the role containing the actioncallerAgentId- 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 metadatarole- the role containing the actionparameters- the original parameters- Returns:
- processed parameters (encrypted if required)
-
executeWithTimeout
Executes an action with security timeout enforcement.- Type Parameters:
T- the result type- Parameters:
action- the action metadatarole- the role containing the actiontask- the task to execute- Returns:
- the execution result
-
processResult
Processes the result based on security settings.- Parameters:
action- the action metadatarole- the role containing the actionresult- 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 metadatarole- the role containing the actioncallerAgentId- the caller agent IDparameters- the action parametersresult- the action resultdurationMs- execution duration in milliseconds
-