use of org.alfresco.repo.security.permissions.impl.AclChange in project alfresco-repository by Alfresco.
the class AclDAOImpl method getInheritedAccessControlList.
/**
* {@inheritDoc}
*/
@Override
public Long getInheritedAccessControlList(Long id) {
AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id);
if (acl.getAclType() == ACLType.OLD) {
return null;
}
if ((acl.getInheritedAcl() != null) && (acl.getInheritedAcl() != -1)) {
return acl.getInheritedAcl();
}
Long inheritedAclId = null;
if ((acl.getAclType() == ACLType.DEFINING) || (acl.getAclType() == ACLType.LAYERED)) {
List<AclChange> changes = new ArrayList<AclChange>();
// created shared acl
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.SHARED);
properties.setInherits(Boolean.TRUE);
properties.setVersioned(acl.isVersioned());
Long sharedId = createAccessControlList(properties, null, null).getId();
getWritable(sharedId, id, null, null, id, true, changes, WriteMode.ADD_INHERITED);
acl.setInheritedAcl(sharedId);
inheritedAclId = sharedId;
} else {
acl.setInheritedAcl(acl.getId());
inheritedAclId = acl.getId();
}
acl.setAclChangeSetId(getCurrentChangeSetId());
aclCrudDAO.updateAcl(acl);
return inheritedAclId;
}
use of org.alfresco.repo.security.permissions.impl.AclChange in project alfresco-repository by Alfresco.
the class ADMPermissionsDaoComponentImpl method replaceWithCleanDefiningAcl.
/**
* @param nodeRef NodeRef
* @param acl Acl
*/
private void replaceWithCleanDefiningAcl(NodeRef nodeRef, Acl acl) {
// TODO: could just clear out existing
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties();
properties = new SimpleAccessControlListProperties();
properties.setAclType(ACLType.DEFINING);
properties.setInherits(Boolean.FALSE);
properties.setVersioned(false);
Acl newAcl = aclDaoComponent.createAccessControlList(properties);
long id = newAcl.getId();
getACLDAO(nodeRef).setAccessControlList(nodeRef, newAcl);
List<AclChange> changes = new ArrayList<AclChange>();
changes.addAll(getACLDAO(nodeRef).setInheritanceForChildren(nodeRef, id, acl.getInheritedAcl()));
getACLDAO(nodeRef).updateChangedAcls(nodeRef, changes);
aclDaoComponent.deleteAccessControlList(acl.getId());
}
use of org.alfresco.repo.security.permissions.impl.AclChange 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);
}
}
use of org.alfresco.repo.security.permissions.impl.AclChange 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;
}
}
use of org.alfresco.repo.security.permissions.impl.AclChange in project alfresco-repository by Alfresco.
the class AbstractPermissionsDaoComponentImpl method deletePermission.
/**
* Deletes all permission entries (access control list entries) that match the given criteria. Note that the access
* control list for the node is not deleted.
*/
public void deletePermission(NodeRef nodeRef, String authority, PermissionReference permission) {
Acl acl = null;
try {
AccessControlListDAO aclDAO = getACLDAO(nodeRef);
if (aclDAO == null) {
return;
}
acl = aclDAO.getAccessControlList(nodeRef);
if (acl == null) {
return;
}
} catch (InvalidNodeRefException e) {
return;
}
// avoid NullPointerException if it was not created
if (acl == null) {
return;
}
switch(acl.getAclType()) {
case FIXED:
case GLOBAL:
case SHARED:
throw new IllegalStateException("Can not delete from this acl in a node context " + acl.getAclType());
case DEFINING:
case LAYERED:
case OLD:
default:
CreationReport report = getMutableAccessControlList(nodeRef);
SimpleAccessControlEntry pattern = new SimpleAccessControlEntry();
pattern.setAuthority(authority);
pattern.setPermission(permission);
pattern.setPosition(Integer.valueOf(0));
List<AclChange> changes = aclDaoComponent.deleteAccessControlEntries(report.getCreated().getId(), pattern);
getACLDAO(nodeRef).updateChangedAcls(nodeRef, changes);
break;
}
}
Aggregations