use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method toolPermission.
public boolean toolPermission(RepositoryTool repoTool, String permissionName) {
if (!repoTool.getRegistered()) {
return true;
}
AbstractSecuredEntity tool = repoTool.getTool();
if (tool == null) {
return true;
}
boolean allowed = permissionEvaluator.hasPermission(SecurityContextHolder.getContext().getAuthentication(), tool, permissionName);
if (allowed) {
tool.setMask(getPermissionsMask(tool, true, true));
repoTool.setMask(tool.getMask());
}
return allowed;
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method deletePermissions.
@Transactional(propagation = Propagation.REQUIRED)
public AclSecuredEntry deletePermissions(Long id, AclClass aclClass, String user, boolean isPrincipal) {
AbstractSecuredEntity entity = entityManager.load(aclClass, id);
Assert.isTrue(!entity.isLocked(), messageHelper.getMessage(MessageConstants.ERROR_ENTITY_IS_LOCKED, entity.getAclClass(), entity.getId()));
MutableAcl acl = aclService.getOrCreateObjectIdentity(entity);
Sid sid = aclService.getSid(user.toUpperCase(), isPrincipal);
int sidEntryIndex = findSidEntry(acl, sid);
if (sidEntryIndex != -1) {
acl.deleteAce(sidEntryIndex);
acl = aclService.updateAcl(acl);
}
AclSecuredEntry aclSecuredEntry = convertAclToEntryForUser(entity, acl, sid);
updateEventsWithChildrenAndIssues(entity);
return aclSecuredEntry;
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method setPermissions.
@Transactional(propagation = Propagation.REQUIRED)
public AclSecuredEntry setPermissions(PermissionGrantVO grantVO) {
validateParameters(grantVO);
AbstractSecuredEntity entity = entityManager.load(grantVO.getAclClass(), grantVO.getId());
Assert.isTrue(!entity.isLocked(), messageHelper.getMessage(MessageConstants.ERROR_ENTITY_IS_LOCKED, entity.getAclClass(), entity.getId()));
MutableAcl acl = aclService.getOrCreateObjectIdentity(entity);
Permission permission = permissionFactory.buildFromMask(grantVO.getMask());
String sidName = grantVO.getUserName().toUpperCase();
Sid sid = aclService.createOrGetSid(sidName, grantVO.getPrincipal());
LOGGER.debug("Granting permissions for sid {}", sid);
int sidEntryIndex = findSidEntry(acl, sid);
if (sidEntryIndex != -1) {
acl.deleteAce(sidEntryIndex);
}
acl.insertAce(Math.max(sidEntryIndex, 0), permission, sid, true);
MutableAcl updatedAcl = aclService.updateAcl(acl);
AclSecuredEntry aclSecuredEntry = convertAclToEntryForUser(entity, updatedAcl, sid);
updateEventsWithChildrenAndIssues(entity);
return aclSecuredEntry;
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class GrantPermissionManager method mergeWithParentPermissions.
private void mergeWithParentPermissions(Map<AclSid, Integer> mergedPermissions, AbstractSecuredEntity parent, Map<AbstractSecuredEntity, List<AclPermissionEntry>> allPermissions) {
AbstractSecuredEntity currentParent = parent;
while (currentParent != null) {
mergePermissions(mergedPermissions, allPermissions.get(currentParent));
currentParent = currentParent.getParent();
}
}
use of com.epam.pipeline.entity.AbstractSecuredEntity in project cloud-pipeline by epam.
the class IssueManager method ensureEntityExists.
private AbstractSecuredEntity ensureEntityExists(EntityVO entityVO) {
AbstractSecuredEntity entity = entityManager.load(entityVO.getEntityClass(), entityVO.getEntityId());
Assert.notNull(entity, messageHelper.getMessage(MessageConstants.ERROR_ENTITY_NOT_FOUND, entityVO.getEntityId(), entityVO.getEntityClass()));
return entity;
}
Aggregations