use of org.camunda.bpm.engine.impl.db.PermissionCheck in project camunda-bpm-platform by camunda.
the class AuthorizationCommandChecker method checkUpdateTask.
public void checkUpdateTask(TaskEntity task) {
String taskId = task.getId();
String executionId = task.getExecutionId();
if (executionId != null) {
// if task exists in context of a process instance
// then check the following permissions:
// - UPDATE on TASK
// - UPDATE_TASK on PROCESS_DEFINITION
ExecutionEntity execution = task.getExecution();
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
PermissionCheck updatePermissionCheck = new PermissionCheck();
updatePermissionCheck.setPermission(UPDATE);
updatePermissionCheck.setResource(TASK);
updatePermissionCheck.setResourceId(taskId);
PermissionCheck updateTaskPermissionCheck = new PermissionCheck();
updateTaskPermissionCheck.setPermission(UPDATE_TASK);
updateTaskPermissionCheck.setResource(PROCESS_DEFINITION);
updateTaskPermissionCheck.setResourceId(processDefinition.getKey());
updateTaskPermissionCheck.setAuthorizationNotFoundReturnValue(0l);
getAuthorizationManager().checkAuthorization(updatePermissionCheck, updateTaskPermissionCheck);
} else {
// if task does not exist in context of process
// instance, then it is either a (a) standalone task
// or (b) it exists in context of a case instance.
// (a) standalone task: check following permission
// - READ on TASK
// (b) task in context of a case instance, in this
// case it is not necessary to check any permission,
// because such tasks can always be updated
String caseExecutionId = task.getCaseExecutionId();
if (caseExecutionId == null) {
// standalone task
getAuthorizationManager().checkAuthorization(UPDATE, TASK, taskId);
}
}
}
use of org.camunda.bpm.engine.impl.db.PermissionCheck in project camunda-bpm-platform by camunda.
the class AuthorizationCommandChecker method checkUpdateProcessInstanceByProcessDefinitionKey.
@Override
public void checkUpdateProcessInstanceByProcessDefinitionKey(String processDefinitionKey) {
// necessary permissions:
// - UPDATE on ANY PROCESS_INSTANCE
PermissionCheck firstCheck = new PermissionCheck();
firstCheck.setPermission(UPDATE);
firstCheck.setResource(PROCESS_INSTANCE);
// ... OR ...
// - UPDATE_INSTANCE on PROCESS_DEFINITION
PermissionCheck secondCheck = new PermissionCheck();
secondCheck.setPermission(UPDATE_INSTANCE);
secondCheck.setResource(PROCESS_DEFINITION);
secondCheck.setResourceId(processDefinitionKey);
secondCheck.setAuthorizationNotFoundReturnValue(0l);
getAuthorizationManager().checkAuthorization(firstCheck, secondCheck);
}
use of org.camunda.bpm.engine.impl.db.PermissionCheck in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
public void checkAuthorization(List<PermissionCheck> permissionChecks) {
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
String userId = currentAuthentication.getUserId();
boolean isAuthorized = isAuthorized(userId, currentAuthentication.getGroupIds(), permissionChecks);
if (!isAuthorized) {
List<MissingAuthorization> missingAuthorizations = new ArrayList<MissingAuthorization>();
for (PermissionCheck check : permissionChecks) {
missingAuthorizations.add(new MissingAuthorization(check.getPermission().getName(), check.getResource().resourceName(), check.getResourceId()));
}
throw new AuthorizationException(userId, missingAuthorizations);
}
}
}
use of org.camunda.bpm.engine.impl.db.PermissionCheck in project camunda-bpm-platform by camunda.
the class AuthorizationManager method isAuthorized.
public boolean isAuthorized(String userId, List<String> groupIds, Permission permission, Resource resource, String resourceId) {
PermissionCheck permCheck = newPermissionCheck();
permCheck.setPermission(permission);
permCheck.setResource(resource);
permCheck.setResourceId(resourceId);
ArrayList<PermissionCheck> permissionChecks = new ArrayList<PermissionCheck>();
permissionChecks.add(permCheck);
return isAuthorized(userId, groupIds, permissionChecks);
}
use of org.camunda.bpm.engine.impl.db.PermissionCheck in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
// authorization checks ///////////////////////////////////////////
public void checkAuthorization(PermissionCheck... permissionChecks) {
ensureNotNull("permissionChecks", (Object[]) permissionChecks);
for (PermissionCheck permissionCheck : permissionChecks) {
ensureNotNull("permissionCheck", permissionCheck);
}
checkAuthorization(CollectionUtil.asArrayList(permissionChecks));
}
Aggregations