use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeploymentCaseDefinitionCmd method execute.
public CaseDefinition execute(CommandContext commandContext) {
ensureNotNull("caseDefinitionId", caseDefinitionId);
CaseDefinitionEntity caseDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedCaseDefinitionById(caseDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadCaseDefinition(caseDefinition);
}
return caseDefinition;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeploymentCaseModelCmd method execute.
public InputStream execute(final CommandContext commandContext) {
ensureNotNull("caseDefinitionId", caseDefinitionId);
CaseDefinitionEntity caseDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedCaseDefinitionById(caseDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadCaseDefinition(caseDefinition);
}
final String deploymentId = caseDefinition.getDeploymentId();
final String resourceName = caseDefinition.getResourceName();
InputStream inputStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {
public InputStream call() throws Exception {
return new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
}
});
return inputStream;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class AbstractSetJobDefinitionStateCmd method checkAuthorization.
@Override
protected void checkAuthorization(CommandContext commandContext) {
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
if (jobDefinitionId != null) {
JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
if (jobDefinition != null && jobDefinition.getProcessDefinitionKey() != null) {
String processDefinitionKey = jobDefinition.getProcessDefinitionKey();
checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);
if (includeSubResources) {
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
}
} else if (processDefinitionId != null) {
checker.checkUpdateProcessDefinitionById(processDefinitionId);
if (includeSubResources) {
checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
}
} else if (processDefinitionKey != null) {
checker.checkUpdateProcessDefinitionByKey(processDefinitionKey);
if (includeSubResources) {
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
}
}
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class AbstractSetJobStateCmd method checkAuthorization.
@Override
protected void checkAuthorization(CommandContext commandContext) {
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
if (jobId != null) {
JobManager jobManager = commandContext.getJobManager();
JobEntity job = jobManager.findJobById(jobId);
if (job != null) {
String processInstanceId = job.getProcessInstanceId();
if (processInstanceId != null) {
checker.checkUpdateProcessInstanceById(processInstanceId);
} else {
// start timer job is not assigned to a specific process
// instance, that's why we have to check whether there
// exists a UPDATE_INSTANCES permission on process definition or
// a UPDATE permission on any process instance
String processDefinitionKey = job.getProcessDefinitionKey();
if (processDefinitionKey != null) {
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
}
// if (processInstanceId == null && processDefinitionKey == null):
// job is not assigned to any process instance nor process definition
// then it is always possible to activate/suspend the corresponding job
// -> no authorization check necessary
}
} else if (jobDefinitionId != null) {
JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager();
JobDefinitionEntity jobDefinition = jobDefinitionManager.findById(jobDefinitionId);
if (jobDefinition != null) {
String processDefinitionKey = jobDefinition.getProcessDefinitionKey();
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
} else if (processInstanceId != null) {
checker.checkUpdateProcessInstanceById(processInstanceId);
} else if (processDefinitionId != null) {
checker.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
} else if (processDefinitionKey != null) {
checker.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
}
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class AbstractDeleteProcessDefinitionCmd method deleteProcessDefinitionCmd.
protected void deleteProcessDefinitionCmd(CommandContext commandContext, String processDefinitionId, boolean cascade, boolean skipCustomListeners) {
ensureNotNull("processDefinitionId", processDefinitionId);
ProcessDefinition processDefinition = commandContext.getProcessDefinitionManager().findLatestProcessDefinitionById(processDefinitionId);
ensureNotNull(NotFoundException.class, "No process definition found with id '" + processDefinitionId + "'", "processDefinition", processDefinition);
List<CommandChecker> commandCheckers = commandContext.getProcessEngineConfiguration().getCommandCheckers();
for (CommandChecker checker : commandCheckers) {
checker.checkDeleteProcessDefinitionById(processDefinitionId);
}
UserOperationLogManager userOperationLogManager = commandContext.getOperationLogManager();
userOperationLogManager.logProcessDefinitionOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, processDefinitionId, processDefinition.getKey(), new PropertyChange("cascade", false, cascade));
ProcessDefinitionManager definitionManager = commandContext.getProcessDefinitionManager();
definitionManager.deleteProcessDefinition(processDefinition, processDefinitionId, cascade, cascade, skipCustomListeners);
}
Aggregations