User permission settings and composite mode

Source: Internet
Author: User
  • Address: http://www.cnblogs.com/WhiteCloud/archive/2006/07/31/464484.html
  • Reference: http://www.cnblogs.com/WhiteCloud/services/trackbacks/464484.aspx

This design is very elegant. You can add group and user in group ...... The son has grandchildren and grandchildren, and the son has grandchildren ...... However, in practice, the relationship between users and user groups is not as simple as this. Whether a user has certain permissions depends on itself (rather than the group) do you have this permission explicitly? If you have this permission explicitly, it certainly has this permission; if you explicitly refuse, it certainly does not have this permission; if you do not have this permission or reject it, in other words:This permission is inherited from the user group only when a user does not explicitly possess or reject a permission..

In this regard, the "user" and "User Group" classes have different behaviors. Simply put, the Group class only has grantpurview behavior, the user class also has the denypurview and clearpurview actions. When you use them, you must know the difference between group and user and the specific subclass of the group. The intention of applying the composite mode is to "ensure consistency in the use of a single object and a composite object", while group and user are completely different classes, if users must find out which specific subclass they are using, there is no consistency. In other words, if the userbase interface also has denypurview and clearpurview, it must be a degradation function in the implementation of the Group. (The addchild method in user throws an exception, which can be weighed in terms of security and transparency ).

Ah, let's say it again. It's just a digress. It doesn't mean porn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.