public class AccessControlList extends java.lang.Object implements AccessControlEngine<java.lang.String,java.lang.String,java.lang.Object>
AccessControlEngine
that uses a user ID, an access mode (read, write, ...) and a Java
object as resource to list all permissions per user for each resource controlled in a user-defined database.Constructor and Description |
---|
AccessControlList()
Constructs the engine with an empty policy stored in the memory (
PackedMap ). |
AccessControlList(AclDataAccess database)
Constructs the engine with the given database.
|
Modifier and Type | Method and Description |
---|---|
void |
addPermission(java.lang.String user,
java.lang.Object resource,
java.lang.String... actions)
Adds a new permission for
user to access resource with all actions in actions . |
boolean |
isAuthorized(java.lang.String user,
java.lang.String action,
java.lang.Object resource)
Computes whether or not the
user can, in the environment , access the resource . |
public AccessControlList()
PackedMap
).AclInMemoryDatabase
public AccessControlList(AclDataAccess database)
To define new resources and permissions, use addPermission(String, Object, String...)
.
database
- the database that stores the policy (lists of permissions).public void addPermission(java.lang.String user, java.lang.Object resource, java.lang.String... actions)
user
to access resource
with all actions in actions
.user
- the user to give permissions to.resource
- the resource that is authorized being access to by this permission.actions
- the actions of the request authorized by this permission.public boolean isAuthorized(java.lang.String user, java.lang.String action, java.lang.Object resource)
AccessControlEngine
user
can, in the environment
, access the resource
.isAuthorized
in interface AccessControlEngine<java.lang.String,java.lang.String,java.lang.Object>
user
- the initiator of the request.action
- the context of the request.resource
- the target of the request.true
if the request is authorized by the policy, false
otherwise.