use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.
the class FetchAndLockHandlerImpl method tryFetchAndLock.
protected FetchAndLockResult tryFetchAndLock(FetchAndLockRequest request) {
ProcessEngine processEngine = request.getProcessEngine();
IdentityService identityService = processEngine.getIdentityService();
FetchAndLockResult result;
try {
identityService.setAuthentication(request.getAuthentication());
FetchExternalTasksExtendedDto fetchingDto = request.getDto();
List<LockedExternalTaskDto> lockedTasks = executeFetchAndLock(fetchingDto, processEngine);
result = FetchAndLockResult.successful(lockedTasks);
} catch (ProcessEngineException e) {
result = FetchAndLockResult.failed(e);
} finally {
identityService.clearAuthentication();
}
return result;
}
use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.
the class MockedProcessEngineProvider method mockServices.
private void mockServices(ProcessEngine engine) {
RepositoryService repoService = mock(RepositoryService.class);
IdentityService identityService = mock(IdentityService.class);
TaskService taskService = mock(TaskService.class);
RuntimeService runtimeService = mock(RuntimeService.class);
FormService formService = mock(FormService.class);
HistoryService historyService = mock(HistoryService.class);
ManagementService managementService = mock(ManagementService.class);
CaseService caseService = mock(CaseService.class);
FilterService filterService = mock(FilterService.class);
ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
when(engine.getRepositoryService()).thenReturn(repoService);
when(engine.getIdentityService()).thenReturn(identityService);
when(engine.getTaskService()).thenReturn(taskService);
when(engine.getRuntimeService()).thenReturn(runtimeService);
when(engine.getFormService()).thenReturn(formService);
when(engine.getHistoryService()).thenReturn(historyService);
when(engine.getManagementService()).thenReturn(managementService);
when(engine.getCaseService()).thenReturn(caseService);
when(engine.getFilterService()).thenReturn(filterService);
when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.
the class ApplicationContextPathUtil method getApplicationPathForDeployment.
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);
}
}
use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.
the class UserRestServiceImpl method createUser.
public void createUser(UserDto userDto) {
final IdentityService identityService = getIdentityService();
if (identityService.isReadOnly()) {
throw new InvalidRequestException(Status.FORBIDDEN, "Identity service implementation is read-only.");
}
UserProfileDto profile = userDto.getProfile();
if (profile == null || profile.getId() == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "request object must provide profile information with valid id.");
}
User newUser = identityService.newUser(profile.getId());
profile.update(newUser);
if (userDto.getCredentials() != null) {
newUser.setPassword(userDto.getCredentials().getPassword());
}
identityService.saveUser(newUser);
}
use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.
the class UserRestServiceImpl method availableOperations.
public ResourceOptionsDto availableOperations(UriInfo context) {
final IdentityService identityService = getIdentityService();
UriBuilder baseUriBuilder = context.getBaseUriBuilder().path(relativeRootResourcePath).path(UserRestService.PATH);
ResourceOptionsDto resourceOptionsDto = new ResourceOptionsDto();
// GET /
URI baseUri = baseUriBuilder.build();
resourceOptionsDto.addReflexiveLink(baseUri, HttpMethod.GET, "list");
// GET /count
URI countUri = baseUriBuilder.clone().path("/count").build();
resourceOptionsDto.addReflexiveLink(countUri, HttpMethod.GET, "count");
// POST /create
if (!identityService.isReadOnly() && isAuthorized(CREATE)) {
URI createUri = baseUriBuilder.clone().path("/create").build();
resourceOptionsDto.addReflexiveLink(createUri, HttpMethod.POST, "create");
}
return resourceOptionsDto;
}
Aggregations