Java Code Examples for org.camunda.bpm.engine.ProcessEngine#getIdentityService()
The following examples show how to use
org.camunda.bpm.engine.ProcessEngine#getIdentityService() .
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: ApplicationContextPathUtil.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public static String getApplicationPathForDeployment(ProcessEngine engine, String deploymentId) { // get the name of the process application that made the deployment String processApplicationName = null; IdentityService identityService = engine.getIdentityService(); Authentication currentAuthentication = identityService.getCurrentAuthentication(); try { identityService.clearAuthentication(); processApplicationName = engine.getManagementService().getProcessApplicationForDeployment(deploymentId); } finally { identityService.setAuthentication(currentAuthentication); } if (processApplicationName == null) { // no a process application deployment return null; } else { ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService(); ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(processApplicationName); return processApplicationInfo.getProperties().get(ProcessApplicationInfo.PROP_SERVLET_CONTEXT_PATH); } }
Example 2
Source File: SuspendProcessDefinitionDeleteScenario.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@DescribesScenario("createUserOperationLogEntriesForDelete") public static ScenarioSetup createUserOperationLogEntries() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { String processInstanceBusinessKey = "SuspendProcessDefinitionDeleteScenario"; ProcessInstance processInstance1 = engine.getRuntimeService().startProcessInstanceByKey("timerBoundaryProcess", processInstanceBusinessKey); ProcessInstance processInstance2 = engine.getRuntimeService().startProcessInstanceByKey("timerBoundaryProcess", processInstanceBusinessKey); ProcessInstance processInstance3 = engine.getRuntimeService().startProcessInstanceByKey("timerBoundaryProcess", processInstanceBusinessKey); IdentityService identityService = engine.getIdentityService(); identityService.setAuthentication("jane01", null); engine.getProcessEngineConfiguration().setAuthorizationEnabled(false); ClockUtil.setCurrentTime(new Date(1549000000000l)); engine.getRuntimeService().suspendProcessInstanceById(processInstance1.getId()); ClockUtil.setCurrentTime(new Date(1549100000000l)); engine.getRuntimeService().suspendProcessInstanceById(processInstance2.getId()); ClockUtil.setCurrentTime(new Date(1549200000000l)); engine.getRuntimeService().suspendProcessInstanceById(processInstance3.getId()); ClockUtil.reset(); identityService.clearAuthentication(); } }; }
Example 3
Source File: CreateStandaloneTaskScenario.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@DescribesScenario("createUserOperationLogEntries") public static ScenarioSetup createUserOperationLogEntries() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { IdentityService identityService = engine.getIdentityService(); identityService.setAuthentication("jane02", null); TaskService taskService = engine.getTaskService(); String taskId = "myTaskForUserOperationLog"; Task task = taskService.newTask(taskId); taskService.saveTask(task); identityService.clearAuthentication(); } }; }
Example 4
Source File: SetAssigneeProcessInstanceTaskScenario.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@DescribesScenario("createUserOperationLogEntries") public static ScenarioSetup createUserOperationLogEntries() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { IdentityService identityService = engine.getIdentityService(); String processInstanceBusinessKey = "SetAssigneeProcessInstanceTaskScenario"; engine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess_userOpLog", processInstanceBusinessKey); identityService.setAuthentication("mary02", null); TaskService taskService = engine.getTaskService(); List<Task> list = taskService.createTaskQuery().processInstanceBusinessKey(processInstanceBusinessKey).list(); Task task = list.get(0); taskService.setAssignee(task.getId(), "john"); identityService.clearAuthentication(); } }; }
Example 5
Source File: CreateStandaloneTaskDeleteScenario.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@DescribesScenario("createUserOperationLogEntriesForDelete") public static ScenarioSetup createUserOperationLogEntries() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { IdentityService identityService = engine.getIdentityService(); identityService.setAuthentication("mary01", null); TaskService taskService = engine.getTaskService(); String taskId = "myTaskForUserOperationLogDel"; Task task = taskService.newTask(taskId); taskService.saveTask(task); identityService.clearAuthentication(); } }; }
Example 6
Source File: DeployUserWithoutSaltForPasswordHashingScenario.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@DescribesScenario("initUser") @Times(1) public static ScenarioSetup initUser() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { // given IdentityService identityService = engine.getIdentityService(); User user = identityService.newUser(USER_NAME); user.setPassword(USER_PWD); // when identityService.saveUser(user); } }; }
Example 7
Source File: CreateAdminUserConfiguration.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Override public void postProcessEngineBuild(final ProcessEngine processEngine) { requireNonNull(adminUser); final IdentityService identityService = processEngine.getIdentityService(); final AuthorizationService authorizationService = processEngine.getAuthorizationService(); if (userAlreadyExists(identityService, adminUser)) { return; } createUser(identityService, adminUser); // create group if (identityService.createGroupQuery().groupId(CAMUNDA_ADMIN).count() == 0) { Group camundaAdminGroup = identityService.newGroup(CAMUNDA_ADMIN); camundaAdminGroup.setName("camunda BPM Administrators"); camundaAdminGroup.setType(Groups.GROUP_TYPE_SYSTEM); identityService.saveGroup(camundaAdminGroup); } // create ADMIN authorizations on all built-in resources for (Resource resource : Resources.values()) { if (authorizationService.createAuthorizationQuery().groupIdIn(CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) { AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); userAdminAuth.setGroupId(CAMUNDA_ADMIN); userAdminAuth.setResource(resource); userAdminAuth.setResourceId(ANY); userAdminAuth.addPermission(ALL); authorizationService.saveAuthorization(userAdminAuth); } } identityService.createMembership(adminUser.getId(), CAMUNDA_ADMIN); LOG.creatingInitialAdminUser(adminUser); }
Example 8
Source File: CreateAdminUserConfiguration.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void postProcessEngineBuild(final ProcessEngine processEngine) { requireNonNull(adminUser); final IdentityService identityService = processEngine.getIdentityService(); final AuthorizationService authorizationService = processEngine.getAuthorizationService(); if (userAlreadyExists(identityService, adminUser)) { return; } createUser(identityService, adminUser); // create group if (identityService.createGroupQuery().groupId(CAMUNDA_ADMIN).count() == 0) { Group camundaAdminGroup = identityService.newGroup(CAMUNDA_ADMIN); camundaAdminGroup.setName("camunda BPM Administrators"); camundaAdminGroup.setType(Groups.GROUP_TYPE_SYSTEM); identityService.saveGroup(camundaAdminGroup); } // create ADMIN authorizations on all built-in resources for (Resource resource : Resources.values()) { if (authorizationService.createAuthorizationQuery().groupIdIn(CAMUNDA_ADMIN).resourceType(resource).resourceId(ANY).count() == 0) { AuthorizationEntity userAdminAuth = new AuthorizationEntity(AUTH_TYPE_GRANT); userAdminAuth.setGroupId(CAMUNDA_ADMIN); userAdminAuth.setResource(resource); userAdminAuth.setResourceId(ANY); userAdminAuth.addPermission(ALL); authorizationService.saveAuthorization(userAdminAuth); } } identityService.createMembership(adminUser.getId(), CAMUNDA_ADMIN); LOG.creatingInitialAdminUser(adminUser); }
Example 9
Source File: FetchAndLockHandlerImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected FetchAndLockResult tryFetchAndLock(FetchAndLockRequest request) { ProcessEngine processEngine = null; IdentityService identityService = null; FetchAndLockResult result = null; try { processEngine = getProcessEngine(request); identityService = processEngine.getIdentityService(); identityService.setAuthentication(request.getAuthentication()); FetchExternalTasksExtendedDto fetchingDto = request.getDto(); List<LockedExternalTaskDto> lockedTasks = executeFetchAndLock(fetchingDto, processEngine); result = FetchAndLockResult.successful(lockedTasks); } catch (Exception e) { result = FetchAndLockResult.failed(e); } finally { if (identityService != null) { identityService.clearAuthentication(); } } return result; }
Example 10
Source File: HalGroupResolver.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) { IdentityService identityService = processEngine.getIdentityService(); List<Group> groups = identityService.createGroupQuery() .groupIdIn(linkedIds) .listPage(0, linkedIds.length); List<HalResource<?>> resolvedGroups = new ArrayList<HalResource<?>>(); for (Group group : groups) { resolvedGroups.add(HalGroup.fromGroup(group)); } return resolvedGroups; }
Example 11
Source File: HalUserResolver.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) { IdentityService identityService = processEngine.getIdentityService(); List<User> users = identityService.createUserQuery() .userIdIn(linkedIds) .listPage(0, linkedIds.length); List<HalResource<?>> resolvedUsers = new ArrayList<HalResource<?>>(); for (User user : users) { resolvedUsers.add(HalUser.fromUser(user)); } return resolvedUsers; }
Example 12
Source File: UserLockExpTimeScenario.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@DescribesScenario("initUserLockExpirationTime") @Times(1) public static ScenarioSetup initUserLockExpirationTime() { return new ScenarioSetup() { @Override public void execute(ProcessEngine processEngine, String s) { final IdentityService identityService = processEngine.getIdentityService(); User user = identityService.newUser(USER_ID); user.setPassword(PASSWORD); identityService.saveUser(user); ((ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration()).getCommandExecutorTxRequired().execute(new Command<Void>() { @Override public Void execute(CommandContext context) { IdentityInfoManager identityInfoManager = Context.getCommandContext() .getSession(IdentityInfoManager.class); UserEntity userEntity = (UserEntity) identityService.createUserQuery() .userId(USER_ID) .singleResult(); identityInfoManager.updateUserLock(userEntity, 10, TIMESTAMP); return null; } }); } }; }
Example 13
Source File: EngineDataGenerator.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public EngineDataGenerator(final ProcessEngine processEngine, final int optimizePageSize) { this.processEngine = processEngine; this.identityService = processEngine.getIdentityService(); this.decisionService = processEngine.getDecisionService(); this.repositoryService = processEngine.getRepositoryService(); this.runtimeService = processEngine.getRuntimeService(); this.taskService = processEngine.getTaskService(); // we double the amount of instances to generate to make sure that there are at least two pages // of each entity available numberOfInstancesToGenerate = optimizePageSize * 2; }
Example 14
Source File: AuthorizationScenario.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@DescribesScenario("startProcessInstance") @Times(1) public static ScenarioSetup startProcessInstance() { return new ScenarioSetup() { public void execute(ProcessEngine engine, String scenarioName) { IdentityService identityService = engine.getIdentityService(); String userId = USER_ID + scenarioName; String groupid = GROUP_ID + scenarioName; // create an user User user = identityService.newUser(userId); identityService.saveUser(user); // create group Group group = identityService.newGroup(groupid); identityService.saveGroup(group); // create membership identityService.createMembership(userId, groupid); //create full authorization AuthorizationService authorizationService = engine.getAuthorizationService(); //authorization for process definition Authorization authProcDef = createAuthorization(authorizationService, Permissions.ALL, Resources.PROCESS_DEFINITION, userId); engine.getAuthorizationService().saveAuthorization(authProcDef); //authorization for deployment Authorization authDeployment = createAuthorization(authorizationService, Permissions.ALL, Resources.DEPLOYMENT, userId); engine.getAuthorizationService().saveAuthorization(authDeployment); //authorization for process instance create Authorization authProcessInstance = createAuthorization(authorizationService, Permissions.CREATE, Resources.PROCESS_INSTANCE, userId); engine.getAuthorizationService().saveAuthorization(authProcessInstance); // start a process instance engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName); } }; }
Example 15
Source File: FetchAndLockHandlerImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void addPendingRequest(FetchExternalTasksExtendedDto dto, AsyncResponse asyncResponse, ProcessEngine processEngine) { Long asyncResponseTimeout = dto.getAsyncResponseTimeout(); if (asyncResponseTimeout != null && asyncResponseTimeout > MAX_REQUEST_TIMEOUT) { asyncResponse.resume(new InvalidRequestException(Status.BAD_REQUEST, "The asynchronous response timeout cannot be set to a value greater than " + MAX_REQUEST_TIMEOUT + " milliseconds")); return; } IdentityService identityService = processEngine.getIdentityService(); Authentication authentication = identityService.getCurrentAuthentication(); String processEngineName = processEngine.getName(); FetchAndLockRequest incomingRequest = new FetchAndLockRequest() .setProcessEngineName(processEngineName) .setAsyncResponse(asyncResponse) .setAuthentication(authentication) .setDto(dto); LOG.log(Level.FINEST, "New request: {0}", incomingRequest); FetchAndLockResult result = tryFetchAndLock(incomingRequest); LOG.log(Level.FINEST, "Fetch and lock result: {0}", result); if (result.wasSuccessful()) { List<LockedExternalTaskDto> lockedTasks = result.getTasks(); if (!lockedTasks.isEmpty() || dto.getAsyncResponseTimeout() == null) { // response immediately if tasks available asyncResponse.resume(lockedTasks); LOG.log(Level.FINEST, "Resuming request with {0}", lockedTasks); } else { addRequest(incomingRequest); LOG.log(Level.FINEST, "Deferred request"); } } else { Throwable processEngineException = result.getThrowable(); asyncResponse.resume(processEngineException); LOG.log(Level.FINEST, "Resuming request with error {0}", processEngineException); } }