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 Details

    • hasPermission

      boolean hasPermission(String agentId, String permission)
      Checks whether an agent has a specific permission.
      Parameters:
      agentId - the agent to check
      permission - the permission name
      Returns:
      true if the agent has the permission
    • getPermissions

      Set<String> getPermissions(String agentId)
      Returns all permissions granted to an agent.
      Parameters:
      agentId - the agent to query
      Returns:
      set of permission names (never null, may be empty)
    • discover

      static PermissionProvider discover()
      Discovers a PermissionProvider via ServiceLoader.
      Returns:
      discovered provider, or null if none on classpath