use of com.epam.pipeline.entity.security.acl.EntityPermission in project cloud-pipeline by epam.
the class GrantPermissionManager method loadEntityPermission.
public EntityPermissionVO loadEntityPermission(final AclClass entityClass, final Long id) {
AbstractSecuredEntity entity = entityManager.loadEntityWithParents(entityClass, id);
Assert.notNull(entity, messageHelper.getMessage(MessageConstants.ERROR_ENTITY_NOT_FOUND, id, entityClass));
AbstractSecuredEntity aclEntity = getAclEntity(entity);
Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions = getEntitiesPermissions(Collections.singleton(aclEntity));
EntityPermission entityPermission = getEntityPermission(allPermissions, entity);
return entityPermissionMapper.toEntityPermissionVO(entityPermission);
}
use of com.epam.pipeline.entity.security.acl.EntityPermission in project cloud-pipeline by epam.
the class GrantPermissionManager method loadAllEntitiesPermissions.
public EntityWithPermissionVO loadAllEntitiesPermissions(AclClass aclClass, Integer page, Integer pageSize, boolean expandGroups, Integer filterMask) {
EntityWithPermissionVO result = new EntityWithPermissionVO();
Collection<? extends AbstractSecuredEntity> entities = entityManager.loadAllWithParents(aclClass, page, pageSize);
Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions = getEntitiesPermissions(entities);
result.setTotalCount(entityManager.loadTotalCount(aclClass));
List<EntityPermission> permissions = entities.stream().distinct().sorted(Comparator.comparingLong(BaseEntity::getId)).map(entity -> getEntityPermission(allPermissions, entity)).collect(toList());
if (expandGroups) {
expandGroups(permissions);
if (filterMask != null) {
permissions.forEach(entry -> {
Set<AclPermissionEntry> filtered = SetUtils.emptyIfNull(entry.getPermissions()).stream().filter(permission -> permissionsService.isMaskBitSet(permission.getMask(), filterMask)).collect(toSet());
entry.setPermissions(filtered);
});
}
}
result.setEntityPermissions(permissions);
return result;
}
use of com.epam.pipeline.entity.security.acl.EntityPermission in project cloud-pipeline by epam.
the class GrantPermissionManager method getEntityPermission.
private EntityPermission getEntityPermission(Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions, AbstractSecuredEntity entity) {
AbstractSecuredEntity aclEntity = getAclEntity(entity);
Map<AclSid, Integer> mergedPermissions = getEntityPermissions(aclEntity, allPermissions);
mergeWithParentPermissions(mergedPermissions, entity.getParent(), allPermissions);
Set<AclPermissionEntry> merged = buildAclPermissionEntries(mergedPermissions);
// clear parent, not to return full hierarchy
entity.clearParent();
EntityPermission entityPermission = new EntityPermission();
entityPermission.setEntity(entity);
entityPermission.setPermissions(merged);
return entityPermission;
}
Aggregations