Search in sources :

Example 41 with CommandChecker

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;
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 42 with CommandChecker

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;
}
Also used : InputStream(java.io.InputStream) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) GetDeploymentResourceCmd(org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 43 with CommandChecker

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);
            }
        }
    }
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 44 with CommandChecker

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);
        }
    }
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) JobDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager) JobManager(org.camunda.bpm.engine.impl.persistence.entity.JobManager) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 45 with CommandChecker

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);
}
Also used : UserOperationLogManager(org.camunda.bpm.engine.impl.persistence.entity.UserOperationLogManager) ProcessDefinitionManager(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionManager) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Aggregations

CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)59 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)14 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)10 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)8 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)7 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)6 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)6 InputStream (java.io.InputStream)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)3 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)3 JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)3 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2