Search in sources :

Example 26 with IdentityService

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

the class MyTaskFormHandler method submitFormVariables.

public void submitFormVariables(VariableMap properties, VariableScope variableScope) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    IdentityService identityService = processEngineConfiguration.getIdentityService();
    RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
    logAuthentication(identityService);
    logInstancesCount(runtimeService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) RuntimeService(org.camunda.bpm.engine.RuntimeService) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 27 with IdentityService

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

the class MyStartFormHandler method submitFormVariables.

public void submitFormVariables(VariableMap properties, VariableScope variableScope) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    IdentityService identityService = processEngineConfiguration.getIdentityService();
    RuntimeService runtimeService = processEngineConfiguration.getRuntimeService();
    logAuthentication(identityService);
    logInstancesCount(runtimeService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) RuntimeService(org.camunda.bpm.engine.RuntimeService) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 28 with IdentityService

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

the class AuthorizationScenario method startProcessInstance.

@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);
        }
    };
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authorization(org.camunda.bpm.engine.authorization.Authorization) Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User) AuthorizationService(org.camunda.bpm.engine.AuthorizationService) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario) Times(org.camunda.bpm.qa.upgrade.Times)

Example 29 with IdentityService

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

the class DefaultAuthorizationProvider method newDeployment.

// Deployment ///////////////////////////////////////////////
public AuthorizationEntity[] newDeployment(Deployment deployment) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    IdentityService identityService = processEngineConfiguration.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    if (currentAuthentication != null && currentAuthentication.getUserId() != null) {
        String userId = currentAuthentication.getUserId();
        String deploymentId = deployment.getId();
        AuthorizationEntity authorization = createGrantAuthorization(userId, null, DEPLOYMENT, deploymentId, READ, DELETE);
        return new AuthorizationEntity[] { authorization };
    }
    return null;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 30 with IdentityService

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

the class ExecuteJobsCmd method execute.

public Void execute(CommandContext commandContext) {
    ensureNotNull("jobId", jobId);
    final JobEntity job = commandContext.getDbEntityManager().selectById(JobEntity.class, jobId);
    final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    final IdentityService identityService = processEngineConfiguration.getIdentityService();
    final JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();
    if (job == null) {
        if (jobExecutorContext != null) {
            // CAM-1842
            // Job was acquired but does not exist anymore. This is not a problem.
            // It usually means that the job has been deleted after it was acquired which can happen if the
            // the activity instance corresponding to the job is cancelled.
            LOG.debugAcquiredJobNotFound(jobId);
            return null;
        } else {
            throw LOG.jobNotFoundException(jobId);
        }
    }
    jobFailureCollector.setJob(job);
    if (jobExecutorContext == null) {
        // if null, then we are not called by the job executor
        for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
            checker.checkUpdateJob(job);
        }
    } else {
        jobExecutorContext.setCurrentJob(job);
        // if the job is called by the job executor then set the tenant id of the job
        // as authenticated tenant to enable tenant checks
        String tenantId = job.getTenantId();
        if (tenantId != null) {
            identityService.setAuthentication(null, null, Collections.singletonList(tenantId));
        }
    }
    try {
        // register as command context close lister to intercept exceptions on flush
        commandContext.registerCommandContextListener(jobFailureCollector);
        commandContext.setCurrentJob(job);
        job.execute(commandContext);
    } finally {
        if (jobExecutorContext != null) {
            jobExecutorContext.setCurrentJob(null);
            identityService.clearAuthentication();
        }
    }
    return null;
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) IdentityService(org.camunda.bpm.engine.IdentityService) JobExecutorContext(org.camunda.bpm.engine.impl.jobexecutor.JobExecutorContext) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

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