[opencms-dev] Site group security setup

Shi Yusen shiys at langhua.cn
Mon Apr 17 17:36:58 CEST 2006


Hi Nick,

I can understand your puzzle, because it was my puzzle too.

The security of a user is calculated in a plus-minus method. In OpenCMS
version 5, it's plus preferred, and I can understand that easily. In current
version, it seems to be minus preferred.

It's said European is good at minus. From your question, I'm sure you are
not a European. ^_^

Is it a culture gap? I cannot understand the new method either. So I added a
piece of code in /org/opencms/security/CmsAccessControlList.java, then
everything is under control. Please try it.

    /**
     * Calculates the permissions of the given user and his groups from the
access control list.<p>
     *  
     * @param user the user
     * @param groups the groups of this user
     * 
     * @return the summarized permission set of the user
     */
    public CmsPermissionSetCustom getPermissions(CmsUser user, List groups)
{

        CmsPermissionSetCustom sum = new CmsPermissionSetCustom();
        ListIterator pIterator = null;
        if (groups != null) {
            pIterator = groups.listIterator();
        }
        I_CmsPrincipal principal = user;
        do {
            CmsPermissionSet permissions =
(CmsPermissionSet)m_permissions.get(principal.getId());
            if (permissions != null) {
                sum.addPermissions(permissions);
            }
            if (pIterator != null && pIterator.hasNext()) {
                principal = (I_CmsPrincipal)pIterator.next();
            } else {
                principal = null;
            }
        } while (principal != null);

        // added by Shi Yusen, shiys at langhua.cn
        if (sum.getAllowedPermissions() > 0)
            sum.setPermissions(sum.getAllowedPermissions(), 0);

        return sum;
    }

Regards,

Shi Yusen/Beijing Langhua Ltd.





More information about the opencms-dev mailing list