public void chacc(
        String resourceName,
        String principalType,
        String principalName,
        int allowedPermissions,
        int deniedPermissions,
        int flags)
    throws CmsException {

        CmsResource res = readResource(resourceName, CmsResourceFilter.ALL);

        CmsAccessControlEntry acEntry = null;
        try {
            I_CmsPrincipal principal = CmsPrincipal.readPrincipal(this, principalType, principalName);
            acEntry = new CmsAccessControlEntry(
                res.getResourceId(),
                principal.getId(),
                allowedPermissions,
                deniedPermissions,
                flags);
            acEntry.setFlagsForPrincipal(principal);
        } catch (CmsDbEntryNotFoundException e) {
            // check for special ids
            if (principalName.equalsIgnoreCase(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME)) {
                acEntry = new CmsAccessControlEntry(
                    res.getResourceId(),
                    CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID,
                    allowedPermissions,
                    deniedPermissions,
                    flags);
                acEntry.setFlags(CmsAccessControlEntry.ACCESS_FLAGS_ALLOTHERS);
            } else if (principalName.equalsIgnoreCase(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME)) {
                acEntry = new CmsAccessControlEntry(
                    res.getResourceId(),
                    CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID,
                    allowedPermissions,
                    deniedPermissions,
                    flags);
                acEntry.setFlags(CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE_ALL);
            } else if (principalType.equalsIgnoreCase(CmsRole.PRINCIPAL_ROLE)) {
                // only vfs managers can set role based permissions
                m_securityManager.checkRoleForResource(m_context, CmsRole.VFS_MANAGER, res);
                // check for role
                CmsRole role = CmsRole.valueOfRoleName(principalName);
                // role based permissions can only be set in the system folder
                if (role == null) {
                    throw e;
                }
                acEntry = new CmsAccessControlEntry(
                    res.getResourceId(),
                    role.getId(),
                    allowedPermissions,
                    deniedPermissions,
                    flags);
                acEntry.setFlags(CmsAccessControlEntry.ACCESS_FLAGS_ROLE);
            } else {
                throw e;
            }
        }

        m_securityManager.writeAccessControlEntry(m_context, res, acEntry);
    }
public void chacc ( String resourceName , String principalType , String principalName , int allowedPermissions , int deniedPermissions , int flags ) throws CmsException { CmsResource res = readResource ( resourceName , CmsResourceFilter . ALL ) ; CmsAccessControlEntry acEntry = null ; try { I_CmsPrincipal principal = CmsPrincipal . readPrincipal ( this , principalType , principalName ) ; acEntry = new CmsAccessControlEntry ( res . getResourceId ( ) , principal . getId ( ) , allowedPermissions , deniedPermissions , flags ) ; acEntry . setFlagsForPrincipal ( principal ) ; } catch ( CmsDbEntryNotFoundException e ) { if ( principalName . equalsIgnoreCase ( CmsAccessControlEntry . PRINCIPAL_ALL_OTHERS_NAME ) ) { acEntry = new CmsAccessControlEntry ( res . getResourceId ( ) , CmsAccessControlEntry . PRINCIPAL_ALL_OTHERS_ID , allowedPermissions , deniedPermissions , flags ) ; acEntry . setFlags ( CmsAccessControlEntry . ACCESS_FLAGS_ALLOTHERS ) ; } else if ( principalName . equalsIgnoreCase ( CmsAccessControlEntry . PRINCIPAL_OVERWRITE_ALL_NAME ) ) { acEntry = new CmsAccessControlEntry ( res . getResourceId ( ) , CmsAccessControlEntry . PRINCIPAL_OVERWRITE_ALL_ID , allowedPermissions , deniedPermissions , flags ) ; acEntry . setFlags ( CmsAccessControlEntry . ACCESS_FLAGS_OVERWRITE_ALL ) ; } else if ( principalType . equalsIgnoreCase ( CmsRole . PRINCIPAL_ROLE ) ) { m_securityManager . checkRoleForResource ( m_context , CmsRole . VFS_MANAGER , res ) ; CmsRole role = CmsRole . valueOfRoleName ( principalName ) ; if ( role == null ) { throw e ; } acEntry = new CmsAccessControlEntry ( res . getResourceId ( ) , role . getId ( ) , allowedPermissions , deniedPermissions , flags ) ; acEntry . setFlags ( CmsAccessControlEntry . ACCESS_FLAGS_ROLE ) ; } else { throw e ; } } m_securityManager . writeAccessControlEntry ( m_context , res , acEntry ) ; }
Changes the access control for a given resource and a given principal(user/group).<p>

@param resourceName name of the resource
@param principalType the type of the principal (currently group or user):
<ul>
<li><code>{@link I_CmsPrincipal#PRINCIPAL_USER}</code></li>
<li><code>{@link I_CmsPrincipal#PRINCIPAL_GROUP}</code></li>
</ul>
@param principalName name of the principal
@param allowedPermissions bit set of allowed permissions
@param deniedPermissions bit set of denied permissions
@param flags additional flags of the access control entry

@throws CmsException if something goes wrong