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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论