Package com.tnsai.security
Interface PermissionProvider
public interface PermissionProvider
SPI for resolving agent permissions at runtime.
Used by SecurityEnforcer to evaluate
Security.requiredPermissions().
When no provider is on the classpath, permission checks are skipped.
Implementing a Provider
public class DefaultPermissionProvider implements PermissionProvider {
public boolean hasPermission(String agentId, String permission) {
return getPermissions(agentId).contains(permission);
}
public Set<String> getPermissions(String agentId) {
// look up from config, database, etc.
}
}
Registration
Register in META-INF/services/com.tnsai.security.PermissionProvider
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic PermissionProviderdiscover()Discovers a PermissionProvider via ServiceLoader.getPermissions(String agentId) Returns all permissions granted to an agent.booleanhasPermission(String agentId, String permission) Checks whether an agent has a specific permission.
-
Method Details
-
hasPermission
Checks whether an agent has a specific permission.- Parameters:
agentId- the agent to checkpermission- the permission name- Returns:
- true if the agent has the permission
-
getPermissions
Returns all permissions granted to an agent.- Parameters:
agentId- the agent to query- Returns:
- set of permission names (never null, may be empty)
-
discover
Discovers a PermissionProvider via ServiceLoader.- Returns:
- discovered provider, or null if none on classpath
-