use of org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry in project alfresco-repository by Alfresco.
the class VirtualPermissionServiceExtension method getSetPermissions.
@Override
public NodePermissionEntry getSetPermissions(NodeRef nodeRef) {
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getSetPermissions(nodeRef);
} else {
NodePermissionEntry virtualSetPermissions = smartStore.getSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
List<? extends PermissionEntry> actualPermissionEntries;
boolean inheritPermissions = false;
if (nodeToAdhereTo != null) {
NodePermissionEntry actualSetPermissions = theTrait.getSetPermissions(nodeToAdhereTo);
actualPermissionEntries = actualSetPermissions.getPermissionEntries();
inheritPermissions = actualSetPermissions.inheritPermissions();
} else {
actualPermissionEntries = Collections.emptyList();
inheritPermissions = false;
}
List<PermissionEntry> mergedEntries = new LinkedList<>();
List<? extends PermissionEntry> virtualPermissionEntries = virtualSetPermissions.getPermissionEntries();
Set<QName> overridenPermissions = new HashSet<>();
for (PermissionEntry permissionEntry : virtualPermissionEntries) {
overridenPermissions.add(permissionEntry.getPermissionReference().getQName());
mergedEntries.add(permissionEntry);
}
for (PermissionEntry permissionEntry : actualPermissionEntries) {
if (!overridenPermissions.contains(permissionEntry.getPermissionReference().getQName())) {
mergedEntries.add(permissionEntry);
}
}
return new SimpleNodePermissionEntry(nodeRef, inheritPermissions, mergedEntries);
}
}
use of org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry in project alfresco-repository by Alfresco.
the class GetSetPermissionsMethod method execute.
private NodePermissionEntry execute(Reference reference, Set<String> toAllow, Set<String> toDeny) {
NodeRef rNodeRef = reference.toNodeRef();
List<PermissionEntry> permissions = new LinkedList<>();
for (String permission : toAllow) {
PermissionReference permissionReference = PermissionReferenceImpl.getPermissionReference(userPermissions.getPermissionTypeQName(), permission);
permissions.add(new SimplePermissionEntry(rNodeRef, permissionReference, authority, AccessStatus.ALLOWED));
}
for (String permission : toDeny) {
PermissionReference permissionReference = PermissionReferenceImpl.getPermissionReference(userPermissions.getPermissionTypeQName(), permission);
permissions.add(new SimplePermissionEntry(rNodeRef, permissionReference, authority, AccessStatus.DENIED));
}
return new SimpleNodePermissionEntry(rNodeRef, false, permissions);
}
use of org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method createSimpleNodePermissionEntry.
private SimpleNodePermissionEntry createSimpleNodePermissionEntry(StoreRef storeRef) {
Acl acl = getACLDAO(storeRef).getAccessControlList(storeRef);
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());
return snpe;
} else {
AccessControlList info = aclDaoComponent.getAccessControlList(acl.getId());
ArrayList<SimplePermissionEntry> spes = new ArrayList<SimplePermissionEntry>(info.getEntries().size());
for (AccessControlEntry entry : info.getEntries()) {
SimplePermissionEntry spe = new SimplePermissionEntry(null, entry.getPermission(), entry.getAuthority(), entry.getAccessStatus(), entry.getPosition());
spes.add(spe);
}
SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(null, acl.getInherits(), spes);
return snpe;
}
}
use of org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method createSimpleNodePermissionEntry.
// Utility methods to create simple detached objects for the outside world
// We do not pass out the hibernate objects
private SimpleNodePermissionEntry createSimpleNodePermissionEntry(NodeRef nodeRef) {
Acl acl = getACLDAO(nodeRef).getAccessControlList(nodeRef);
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());
return snpe;
} else {
AccessControlList info = aclDaoComponent.getAccessControlList(acl.getId());
SimpleNodePermissionEntry cached = info.getCachedSimpleNodePermissionEntry();
if (cached != null) {
return cached;
}
ArrayList<SimplePermissionEntry> spes = new ArrayList<SimplePermissionEntry>(info.getEntries().size());
for (AccessControlEntry entry : info.getEntries()) {
SimplePermissionEntry spe = new SimplePermissionEntry(nodeRef, entry.getPermission(), entry.getAuthority(), entry.getAccessStatus(), entry.getPosition());
spes.add(spe);
}
SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(nodeRef, acl.getInherits(), spes);
info.setCachedSimpleNodePermissionEntry(snpe);
return snpe;
}
}
use of org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry 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;
}
Aggregations