开发者

Coding user hierachy java

开发者 https://www.devze.com 2023-02-23 10:17 出处:网络
I 开发者_如何学JAVAam designing some software that contains different users with different privileges, these are not related to the underlying os they are within my program.

I 开发者_如何学JAVAam 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消