use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method setPermission.
public void setPermission(NodePermissionEntry nodePermissionEntry) {
NodeRef nodeRef = nodePermissionEntry.getNodeRef();
// Get the access control list
// Note the logic here requires to know whether it was created or not
Acl existing = getAccessControlList(nodeRef);
if (existing != null) {
deletePermissions(nodeRef);
}
// create the access control list
existing = getAccessControlList(nodeRef);
CreationReport report = createAccessControlList(nodeRef, nodePermissionEntry.inheritPermissions(), existing);
// add all entries
for (PermissionEntry pe : nodePermissionEntry.getPermissionEntries()) {
SimpleAccessControlEntry entry = new SimpleAccessControlEntry();
entry.setAuthority(pe.getAuthority());
entry.setPermission(pe.getPermissionReference());
entry.setAccessStatus(pe.isAllowed() ? 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);
}
}
use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method getPermissions.
public NodePermissionEntry getPermissions(StoreRef storeRef) {
// Create the object if it is not found.
// Null objects are not cached in hibernate
// If the object does not exist it will repeatedly query to check its
// non existence.
NodePermissionEntry npe = null;
Acl acl = null;
try {
acl = getAccessControlList(storeRef);
} catch (InvalidNodeRefException e) {
// Do nothing.
}
if (acl == null) {
// there isn't an access control list for the node - spoof a null one
SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(null, true, Collections.<SimplePermissionEntry>emptyList());
npe = snpe;
} else {
npe = createSimpleNodePermissionEntry(storeRef);
}
return npe;
}
use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method getPermissions.
public NodePermissionEntry getPermissions(NodeRef nodeRef) {
// Create the object if it is not found.
// Null objects are not cached in hibernate
// If the object does not exist it will repeatedly query to check its
// non existence.
NodePermissionEntry npe = null;
Acl acl = null;
try {
acl = getAccessControlList(nodeRef);
} catch (InvalidNodeRefException e) {
// Do nothing.
}
if (acl == null) {
// there isn't an access control list for the node - spoof a null one
SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(nodeRef, true, Collections.<SimplePermissionEntry>emptyList());
npe = snpe;
} else {
npe = createSimpleNodePermissionEntry(nodeRef);
}
// done
if (logger.isDebugEnabled()) {
logger.debug("Got NodePermissionEntry for node: \n" + " node: " + nodeRef + "\n" + " acl: " + npe);
}
return npe;
}
use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.
the class PermissionServiceTest method testSimplePermissionOnStore.
public void testSimplePermissionOnStore() {
runAs("andy");
NodePermissionEntry entry = permissionService.getSetPermissions(testStoreRef);
assertNotNull(entry);
assertEquals(0, entry.getPermissionEntries().size());
assertEquals(0, permissionService.getAllSetPermissions(testStoreRef).size());
// Test Nulls
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(null, getPermission(PermissionService.READ)));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(rootNodeRef, (PermissionReference) null));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(new NodeRef(testStoreRef, "I don't exist"), getPermission(PermissionService.READ)));
}
Aggregations