Search in sources :

Example 6 with SimpleAccessControlEntry

use of org.alfresco.repo.security.permissions.SimpleAccessControlEntry in project alfresco-repository by Alfresco.

the class AclDAOImpl method deleteInheritedAccessControlEntries.

/**
 * {@inheritDoc}
 */
@Override
public List<AclChange> deleteInheritedAccessControlEntries(Long id) {
    List<AclChange> changes = new ArrayList<AclChange>();
    SimpleAccessControlEntry pattern = new SimpleAccessControlEntry();
    pattern.setPosition(Integer.valueOf(-1));
    // Will remove from the cache
    getWritable(id, null, Collections.singletonList(pattern), null, null, true, changes, WriteMode.COPY_UPDATE_AND_INHERIT);
    return changes;
}
Also used : ArrayList(java.util.ArrayList) AclChange(org.alfresco.repo.security.permissions.impl.AclChange) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Example 7 with SimpleAccessControlEntry

use of org.alfresco.repo.security.permissions.SimpleAccessControlEntry in project alfresco-repository by Alfresco.

the class AbstractPermissionsDaoComponentImpl method setPermission.

public void setPermission(StoreRef storeRef, String authority, PermissionReference permission, boolean allow) {
    Acl acl = getMutableAccessControlList(storeRef);
    SimpleAccessControlEntry entry = new SimpleAccessControlEntry();
    entry.setAuthority(authority);
    entry.setPermission(permission);
    entry.setAccessStatus(allow ? AccessStatus.ALLOWED : AccessStatus.DENIED);
    entry.setAceType(ACEType.ALL);
    entry.setPosition(Integer.valueOf(0));
    aclDaoComponent.setAccessControlEntry(acl.getId(), entry);
}
Also used : SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Example 8 with SimpleAccessControlEntry

use of org.alfresco.repo.security.permissions.SimpleAccessControlEntry in project alfresco-repository by Alfresco.

the class AbstractPermissionsDaoComponentImpl method setPermission.

public void setPermission(NodeRef nodeRef, String authority, PermissionReference permission, boolean allow) {
    CreationReport report = null;
    try {
        report = getMutableAccessControlList(nodeRef);
    } catch (InvalidNodeRefException e) {
        return;
    }
    if (report.getCreated() != null) {
        SimpleAccessControlEntry entry = new SimpleAccessControlEntry();
        entry.setAuthority(authority);
        entry.setPermission(permission);
        entry.setAccessStatus(allow ? AccessStatus.ALLOWED : AccessStatus.DENIED);
        entry.setAceType(ACEType.ALL);
        entry.setPosition(Integer.valueOf(0));
        List<AclChange> changes = aclDaoComponent.setAccessControlEntry(report.getCreated().getId(), entry);
        List<AclChange> all = new ArrayList<AclChange>(changes.size() + report.getChanges().size());
        all.addAll(report.getChanges());
        all.addAll(changes);
        getACLDAO(nodeRef).updateChangedAcls(nodeRef, all);
    }
}
Also used : ArrayList(java.util.ArrayList) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) AclChange(org.alfresco.repo.security.permissions.impl.AclChange) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Example 9 with SimpleAccessControlEntry

use of org.alfresco.repo.security.permissions.SimpleAccessControlEntry in project alfresco-repository by Alfresco.

the class AbstractPermissionsDaoComponentImpl method deletePermissions.

public void deletePermissions(StoreRef storeRef, String authority) {
    Acl acl = getAccessControlList(storeRef);
    if (acl == null) {
        return;
    }
    acl = getMutableAccessControlList(storeRef);
    SimpleAccessControlEntry pattern = new SimpleAccessControlEntry();
    pattern.setAuthority(authority);
    pattern.setPosition(Integer.valueOf(0));
    aclDaoComponent.deleteAccessControlEntries(acl.getId(), pattern);
}
Also used : SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Example 10 with SimpleAccessControlEntry

use of org.alfresco.repo.security.permissions.SimpleAccessControlEntry in project alfresco-repository by Alfresco.

the class AbstractPermissionsDaoComponentImpl method deletePermissions.

public void deletePermissions(NodeRef nodeRef, final String authority) {
    Acl acl = null;
    try {
        AccessControlListDAO aclDAO = getACLDAO(nodeRef);
        if (aclDAO == null) {
            return;
        }
        acl = aclDAO.getAccessControlList(nodeRef);
        if (acl == null) {
            return;
        }
    } catch (InvalidNodeRefException e) {
        return;
    }
    switch(acl.getAclType()) {
        case FIXED:
        case GLOBAL:
            throw new IllegalStateException("Can not delete from this acl in a node context " + acl.getAclType());
        case SHARED:
            // Nothing to do
            break;
        case DEFINING:
        case LAYERED:
        case OLD:
        default:
            CreationReport report = getMutableAccessControlList(nodeRef);
            SimpleAccessControlEntry pattern = new SimpleAccessControlEntry();
            pattern.setAuthority(authority);
            pattern.setPosition(Integer.valueOf(0));
            List<AclChange> changes = aclDaoComponent.deleteAccessControlEntries(report.getCreated().getId(), pattern);
            getACLDAO(nodeRef).updateChangedAcls(nodeRef, changes);
            break;
    }
}
Also used : InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) AclChange(org.alfresco.repo.security.permissions.impl.AclChange) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry)

Aggregations

SimpleAccessControlEntry (org.alfresco.repo.security.permissions.SimpleAccessControlEntry)21 SimpleAccessControlListProperties (org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)9 AclChange (org.alfresco.repo.security.permissions.impl.AclChange)9 ArrayList (java.util.ArrayList)8 AccessControlListProperties (org.alfresco.repo.security.permissions.AccessControlListProperties)4 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)3 HashSet (java.util.HashSet)2 AccessControlEntry (org.alfresco.repo.security.permissions.AccessControlEntry)2 AccessControlList (org.alfresco.repo.security.permissions.AccessControlList)2 SimplePermissionReference (org.alfresco.repo.security.permissions.impl.SimplePermissionReference)2 QName (org.alfresco.service.namespace.QName)2 Map (java.util.Map)1 NodePermissionEntry (org.alfresco.repo.security.permissions.NodePermissionEntry)1 PermissionEntry (org.alfresco.repo.security.permissions.PermissionEntry)1 SimpleAccessControlList (org.alfresco.repo.security.permissions.SimpleAccessControlList)1 SimpleNodePermissionEntry (org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry)1 SimplePermissionEntry (org.alfresco.repo.security.permissions.impl.SimplePermissionEntry)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1