Java Code Examples for org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#setAuthorizationEnabled()

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl#setAuthorizationEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceAuthorizationProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeProcessEngine() {
  super.initializeProcessEngine();

  processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
  processEngineConfiguration.setResourceAuthorizationProvider(new MyResourceAuthorizationProvider());

  identityService = processEngineConfiguration.getIdentityService();
  authorizationService = processEngineConfiguration.getAuthorizationService();

  user = createUser(userId);
  group = createGroup(groupId);

  identityService.createMembership(userId, groupId);

  identityService.setAuthentication(userId, Arrays.asList(groupId));
  processEngineConfiguration.setAuthorizationEnabled(true);
}
 
Example 2
Source File: BatchMigrationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testMigrationJobsExecutionByJobExecutorWithAuthorizationEnabledAndTenant() {
  ProcessEngineConfigurationImpl processEngineConfiguration = engineRule.getProcessEngineConfiguration();

  processEngineConfiguration.setAuthorizationEnabled(true);

  try {
    Batch batch = helper.migrateProcessInstancesAsyncForTenant(10, "someTenantId");
    helper.completeSeedJobs(batch);

    testRule.waitForJobExecutorToProcessAllJobs();

    // then all process instances where migrated
    assertEquals(0, helper.countSourceProcessInstances());
    assertEquals(10, helper.countTargetProcessInstances());

  } finally {
    processEngineConfiguration.setAuthorizationEnabled(false);
  }

}
 
Example 3
Source File: LicenseKeyAuthTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
  processEngine = engineRule.getProcessEngine();
  processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
  managementService = processEngine.getManagementService();
  identityService = processEngine.getIdentityService();

  processEngineConfiguration.setAuthorizationEnabled(true);
}
 
Example 4
Source File: ModificationExecutionAsyncTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testModificationJobsExecutionByJobExecutorWithAuthorizationEnabledAndTenant() {
  ProcessEngineConfigurationImpl processEngineConfiguration = rule.getProcessEngineConfiguration();

  processEngineConfiguration.setAuthorizationEnabled(true);
  ProcessDefinition processDefinition = testRule.deployForTenantAndGetDefinition("tenantId", instance);

  try {
    Batch batch = helper.startAfterAsync("process1", 10, "user1", processDefinition.getId());
    helper.completeSeedJobs(batch);

    testRule.executeAvailableJobs();

    // then all process instances where modified
    for (String processInstanceId : helper.currentProcessInstances) {
      ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
      assertNotNull(updatedTree);
      assertEquals(processInstanceId, updatedTree.getProcessInstanceId());

      assertThat(updatedTree).hasStructure(
          describeActivityInstanceTree(
              processDefinition.getId())
          .activity("user1")
          .activity("user2")
          .done());
    }

  } finally {
    processEngineConfiguration.setAuthorizationEnabled(false);
  }

}
 
Example 5
Source File: RestartProcessInstanceAsyncTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Test
public void testJobsExecutionByJobExecutorWithAuthorizationEnabledAndTenant() {
  // given
  ProcessEngineConfigurationImpl processEngineConfiguration = engineRule.getProcessEngineConfiguration();

  processEngineConfiguration.setAuthorizationEnabled(true);
  ProcessDefinition processDefinition = testRule.deployForTenantAndGetDefinition("tenantId", ProcessModels.TWO_TASKS_PROCESS);

  try {
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");

    List<String> list = Arrays.asList(processInstance1.getId(), processInstance2.getId());

    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");

    // when
    Batch batch = runtimeService
        .restartProcessInstances(processDefinition.getId())
        .startTransition("flow1")
        .processInstanceIds(list)
        .executeAsync();
    helper.completeSeedJobs(batch);

    testRule.waitForJobExecutorToProcessAllJobs();

    List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).list();
    // then all process instances were restarted
    for (ProcessInstance restartedProcessInstance : restartedProcessInstances) {
      ActivityInstance updatedTree = runtimeService.getActivityInstance(restartedProcessInstance.getId());
      assertNotNull(updatedTree);
      assertEquals(restartedProcessInstance.getId(), updatedTree.getProcessInstanceId());
      assertEquals("tenantId", restartedProcessInstance.getTenantId());

      assertThat(updatedTree).hasStructure(
          describeActivityInstanceTree(
              processDefinition.getId())
          .activity("userTask2")
          .done());
    }

  } finally {
    processEngineConfiguration.setAuthorizationEnabled(false);
  }

}