Consider the basic authorization structure with User and Group , where access to methods must be protected by checks that ensure that the user or group has the necessary PriviledgeLevel to execute the method and otherwise refuse.
I present something like this:
@AccessCheck(PriviledgeLevel.ADMINISTRATOR) public static void secureMethod(){ ... }
If code verification basically does
if(currentUser.getPriviledgeLevel >= PriviledgeLevel.ADMINISTRATOR || currentUser.getGroup.priviledgeLevel >= PriviledgeLevel.ADMINISTRATOR) // Allow access else // Deny access
Is it possible to implement it this way?
I did a little research, which points to some existing AspectJ- based things, mainly the Security Annotation Framework (SAF) and Spring Security .
I'm a little worried that SAF no longer seems active, and the documentation is not that useful.
I'm not sure about Spring's security, but it seems to be more focused on security issues in web themes.
The Java authentication and authorization service seems to be connected, but does not use the annotation approach.
Does it make sense to try to define these security requirements using this declarative approach?
Is there another library / framework that I am missing that already implements what I want, or some kind of technology that will be important here?
Or is there a completely different solution (for example, the implementation of my own ClassLoader , ...) that surpasses what I present (in terms of brevity and readability for the library user)?