Search in sources :

Example 16 with IdentityService

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;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto) LockedExternalTaskDto(org.camunda.bpm.engine.rest.dto.externaltask.LockedExternalTaskDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 17 with IdentityService

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);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ManagementService(org.camunda.bpm.engine.ManagementService) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) FormService(org.camunda.bpm.engine.FormService) FilterService(org.camunda.bpm.engine.FilterService) HistoryService(org.camunda.bpm.engine.HistoryService) CaseService(org.camunda.bpm.engine.CaseService) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 18 with IdentityService

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);
    }
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) ProcessApplicationService(org.camunda.bpm.ProcessApplicationService) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo)

Example 19 with IdentityService

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);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) User(org.camunda.bpm.engine.identity.User) UserProfileDto(org.camunda.bpm.engine.rest.dto.identity.UserProfileDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 20 with IdentityService

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;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ResourceOptionsDto(org.camunda.bpm.engine.rest.dto.ResourceOptionsDto) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI)

Aggregations

IdentityService (org.camunda.bpm.engine.IdentityService)32 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)9 User (org.camunda.bpm.engine.identity.User)8 Group (org.camunda.bpm.engine.identity.Group)7 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 RuntimeService (org.camunda.bpm.engine.RuntimeService)6 ArrayList (java.util.ArrayList)4 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)4 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 Authorization (org.camunda.bpm.engine.authorization.Authorization)3 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)3 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)3 URI (java.net.URI)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 FilterService (org.camunda.bpm.engine.FilterService)2 FormService (org.camunda.bpm.engine.FormService)2 TaskService (org.camunda.bpm.engine.TaskService)2 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)2