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);
}
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);
}
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);
}
};
}
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;
}
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;
}
Aggregations