Alex Edwards
Alex Edwards

Reputation: 1673

Coding user hierachy java

I am designing some software that contains different users with different privileges, these are not related to the underlying os they are within my program.

Is there a design pattern for this sort of thing?

Ideally i would like it possible to create users with multiple groups as you can in unix. For example user A is in user group A and user group C user B is in user group A and user group B

Upvotes: 1

Views: 106

Answers (1)

Nishant
Nishant

Reputation: 55866

The easiest would be to have a database of all possible privileges and then assign appropriate privileges to users. Before you write any action that requires a privilege, have a handy method something like boolean isAuthorized(User user, PrivilegeType privilege) to test.

There are many authentication and authorization frameworks in Java. I personally prefer Apache Shiro for it's simplicity and small learning curve.

Hope this helps.

Upvotes: 2

Related Questions