I have a Java program involving several users who need to have different privileges. I currently have a class with basic CRUD methods; each of which requires that the current user has permission to call that method. For example, a user may have permission to call the "update" and "create" methods, but not "delete". All users have the ability to call the "read" method.
I'd like to give each user some arbitrary combination of permissions to use methods, so I think each method should check the users permission. However, what's the best way to do this? Should the user object be passed as a parameter into the methods each time they're called, or is there a better way?
I've taken a look at the SecurityManager
class in Java, but it appears to be targeted towards applets and file-system privileges (neither of which are applicable in my case). Is that correct, or have I missed something here?