Search in sources :

Example 6 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method getForm.

@Override
public FormDto getForm() {
    FormService formService = engine.getFormService();
    Task task = getTaskById(taskId);
    FormData formData;
    try {
        formData = formService.getTaskFormData(taskId);
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new RestException(Status.BAD_REQUEST, e, "Cannot get form for task " + taskId);
    }
    FormDto dto = FormDto.fromFormData(formData);
    if (dto.getKey() == null || dto.getKey().isEmpty()) {
        if (formData != null && formData.getFormFields() != null && !formData.getFormFields().isEmpty()) {
            dto.setKey("embedded:engine://engine/:engine/task/" + taskId + "/rendered-form");
        }
    }
    // to get the application context path it is necessary to
    // execute it without authentication (tries to fetch the
    // process definition), because:
    // - user 'demo' has READ permission on a specific task resource
    // - user 'demo' does not have a READ permission on the corresponding
    // process definition
    // -> running the following lines with authorization would lead
    // to an AuthorizationException because the user 'demo' does not
    // have READ permission on the corresponding process definition
    IdentityService identityService = engine.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    try {
        identityService.clearAuthentication();
        String processDefinitionId = task.getProcessDefinitionId();
        String caseDefinitionId = task.getCaseDefinitionId();
        if (processDefinitionId != null) {
            dto.setContextPath(ApplicationContextPathUtil.getApplicationPathByProcessDefinitionId(engine, processDefinitionId));
        } else if (caseDefinitionId != null) {
            dto.setContextPath(ApplicationContextPathUtil.getApplicationPathByCaseDefinitionId(engine, caseDefinitionId));
        }
    } finally {
        identityService.setAuthentication(currentAuthentication);
    }
    return dto;
}
Also used : FormData(org.camunda.bpm.engine.form.FormData) IdentityService(org.camunda.bpm.engine.IdentityService) Task(org.camunda.bpm.engine.task.Task) HalTask(org.camunda.bpm.engine.rest.hal.task.HalTask) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) FormService(org.camunda.bpm.engine.FormService) RestException(org.camunda.bpm.engine.rest.exception.RestException) FormDto(org.camunda.bpm.engine.rest.dto.task.FormDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 7 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class TaskAttachmentResourceImpl method isHistoryEnabled.

private boolean isHistoryEnabled() {
    IdentityService identityService = engine.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    try {
        identityService.clearAuthentication();
        int historyLevel = engine.getManagementService().getHistoryLevel();
        return historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE;
    } finally {
        identityService.setAuthentication(currentAuthentication);
    }
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication)

Example 8 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class MyFormFieldValidator method validate.

public boolean validate(Object submittedValue, FormFieldValidatorContext validatorContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    IdentityService identityService = processEngineConfiguration.getIdentityService();
    RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
    logAuthentication(identityService);
    logInstancesCount(runtimeService);
    return true;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) RuntimeService(org.camunda.bpm.engine.RuntimeService) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 9 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class MyTaskFormHandler method createTaskForm.

public TaskFormData createTaskForm(TaskEntity task) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    IdentityService identityService = processEngineConfiguration.getIdentityService();
    RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
    logAuthentication(identityService);
    logInstancesCount(runtimeService);
    TaskFormDataImpl result = new TaskFormDataImpl();
    result.setTask(task);
    return result;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) TaskFormDataImpl(org.camunda.bpm.engine.impl.form.TaskFormDataImpl) RuntimeService(org.camunda.bpm.engine.RuntimeService) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 10 with IdentityService

use of org.camunda.bpm.engine.IdentityService in project camunda-bpm-platform by camunda.

the class MyDelegationService method logAuthentication.

protected void logAuthentication(ProcessEngineServices services) {
    IdentityService identityService = services.getIdentityService();
    logAuthentication(identityService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService)

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