コード例 #1
0
  @Override
  public DmnDecisionTableResult execute(CommandContext commandContext) {
    ensureNotNull("decision definition id is null", "processDefinitionId", decisionDefinitionId);

    ProcessEngineConfigurationImpl processEngineConfiguration =
        commandContext.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();

    DecisionDefinitionEntity decisionDefinition =
        deploymentCache.findDeployedDecisionDefinitionById(decisionDefinitionId);

    // check authorization
    AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
    authorizationManager.checkEvaluateDecision(decisionDefinition.getKey());

    return doEvaluateDecision(decisionDefinition, variables);
  }
コード例 #2
0
  public TaskFormData execute(CommandContext commandContext) {
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("No task found for taskId '" + taskId + "'", "task", task);

    AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();
    authorizationManager.checkReadTask(task);

    if (task.getTaskDefinition() != null) {
      TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
      ensureNotNull(
          "No taskFormHandler specified for task '" + taskId + "'",
          "taskFormHandler",
          taskFormHandler);

      return taskFormHandler.createTaskForm(task);
    } else {
      // Standalone task, no TaskFormData available
      return null;
    }
  }
コード例 #3
0
  protected void checkAuthorization(CommandContext commandContext) {
    AuthorizationManager authorizationManager = commandContext.getAuthorizationManager();

    if (jobId != null) {

      JobManager jobManager = commandContext.getJobManager();
      JobEntity job = jobManager.findJobById(jobId);

      if (job != null) {

        String processInstanceId = job.getProcessInstanceId();
        if (processInstanceId != null) {
          authorizationManager.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) {
            authorizationManager.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();
        authorizationManager.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
      }

    } else if (processInstanceId != null) {
      authorizationManager.checkUpdateProcessInstanceById(processInstanceId);
    } else if (processDefinitionId != null) {
      authorizationManager.checkUpdateProcessInstanceByProcessDefinitionId(processDefinitionId);
    } else if (processDefinitionKey != null) {
      authorizationManager.checkUpdateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
    }
  }