Search in sources :

Example 1 with SimpleAccessControlList

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

the class AclDAOImpl method getAccessControlList.

/**
 * {@inheritDoc}
 */
@Override
public AccessControlList getAccessControlList(Long id) {
    // Used the cached properties as our cache key
    AccessControlListProperties properties = getAccessControlListProperties(id);
    if (properties == null) {
        return null;
    }
    AccessControlList aclCached = aclCache.get((Serializable) properties);
    if (aclCached != null) {
        return aclCached;
    }
    SimpleAccessControlList acl = new SimpleAccessControlList();
    acl.setProperties(properties);
    List<Map<String, Object>> results = aclCrudDAO.getAcesAndAuthoritiesByAcl(id);
    List<AccessControlEntry> entries = new ArrayList<AccessControlEntry>(results.size());
    for (Map<String, Object> result : results) // for (AclMemberEntity member : members)
    {
        Boolean aceIsAllowed = (Boolean) result.get("allowed");
        Integer aceType = (Integer) result.get("applies");
        String authority = (String) result.get("authority");
        Long permissionId = (Long) result.get("permissionId");
        Integer position = (Integer) result.get("pos");
        // Long result_aclmemId = (Long) result.get("aclmemId"); // not used here
        SimpleAccessControlEntry sacEntry = new SimpleAccessControlEntry();
        sacEntry.setAccessStatus(aceIsAllowed ? AccessStatus.ALLOWED : AccessStatus.DENIED);
        sacEntry.setAceType(ACEType.getACETypeFromId(aceType));
        sacEntry.setAuthority(authority);
        // if (entry.getContext() != null)
        // {
        // SimpleAccessControlEntryContext context = new SimpleAccessControlEntryContext();
        // context.setClassContext(entry.getContext().getClassContext());
        // context.setKVPContext(entry.getContext().getKvpContext());
        // context.setPropertyContext(entry.getContext().getPropertyContext());
        // sacEntry.setContext(context);
        // }
        Permission perm = aclCrudDAO.getPermission(permissionId);
        // Has an ID so must exist
        QName permTypeQName = qnameDAO.getQName(perm.getTypeQNameId()).getSecond();
        SimplePermissionReference permissionRefernce = SimplePermissionReference.getPermissionReference(permTypeQName, perm.getName());
        sacEntry.setPermission(permissionRefernce);
        sacEntry.setPosition(position);
        entries.add(sacEntry);
    }
    Collections.sort(entries);
    acl.setEntries(entries);
    // Cache it for next time
    aclCache.put((Serializable) properties, acl);
    return acl;
}
Also used : AccessControlList(org.alfresco.repo.security.permissions.AccessControlList) SimpleAccessControlList(org.alfresco.repo.security.permissions.SimpleAccessControlList) SimpleAccessControlList(org.alfresco.repo.security.permissions.SimpleAccessControlList) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) AccessControlListProperties(org.alfresco.repo.security.permissions.AccessControlListProperties) SimpleAccessControlListProperties(org.alfresco.repo.security.permissions.SimpleAccessControlListProperties) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry) AccessControlEntry(org.alfresco.repo.security.permissions.AccessControlEntry) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry) SimplePermissionReference(org.alfresco.repo.security.permissions.impl.SimplePermissionReference) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AccessControlEntry (org.alfresco.repo.security.permissions.AccessControlEntry)1 AccessControlList (org.alfresco.repo.security.permissions.AccessControlList)1 AccessControlListProperties (org.alfresco.repo.security.permissions.AccessControlListProperties)1 SimpleAccessControlEntry (org.alfresco.repo.security.permissions.SimpleAccessControlEntry)1 SimpleAccessControlList (org.alfresco.repo.security.permissions.SimpleAccessControlList)1 SimpleAccessControlListProperties (org.alfresco.repo.security.permissions.SimpleAccessControlListProperties)1 SimplePermissionReference (org.alfresco.repo.security.permissions.impl.SimplePermissionReference)1 QName (org.alfresco.service.namespace.QName)1