use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkCamundaAdmin.
// predefined authorization checks
/* MEMBER OF CAMUNDA_ADMIN */
/**
* Checks if the current authentication contains the group
* {@link Groups#CAMUNDA_ADMIN}. The check is ignored if the authorization is
* disabled or no authentication exists.
*
* @throws AuthorizationException
*/
public void checkCamundaAdmin() {
final Authentication currentAuthentication = getCurrentAuthentication();
CommandContext commandContext = Context.getCommandContext();
if (isAuthorizationEnabled() && commandContext.isAuthorizationCheckEnabled() && currentAuthentication != null && !isCamundaAdmin(currentAuthentication)) {
throw LOG.requiredCamundaAdminException();
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class BpmnModelInstanceCache method getAllDefinitionsForDeployment.
@Override
protected List<ProcessDefinition> getAllDefinitionsForDeployment(final String deploymentId) {
final CommandContext commandContext = Context.getCommandContext();
List<ProcessDefinition> allDefinitionsForDeployment = commandContext.runWithoutAuthorization(new Callable<List<ProcessDefinition>>() {
public List<ProcessDefinition> call() throws Exception {
return new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list();
}
});
return allDefinitionsForDeployment;
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class IncidentAuthorizationTest method clearDatabase.
protected void clearDatabase() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
HistoryLevel historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel();
if (historyLevel.equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
List<HistoricIncident> incidents = Context.getProcessEngineConfiguration().getHistoryService().createHistoricIncidentQuery().list();
for (HistoricIncident incident : incidents) {
commandContext.getHistoricIncidentManager().delete((HistoricIncidentEntity) incident);
}
}
return null;
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class RedeploymentRegistrationTest method caseDefinitionTestProvider.
protected static TestProvider caseDefinitionTestProvider() {
return new TestProvider() {
@Override
public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
return new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
CaseDefinitionEntity definition = deploymentCache.findDeployedCaseDefinitionById(definitionId);
return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
}
};
}
@Override
public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
return repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult().getId();
}
};
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class DatabaseHistoryPropertyAutoTest method usesDefaultValueAuditWhenNoValueIsConfigured.
@Test
public void usesDefaultValueAuditWhenNoValueIsConfigured() {
final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO);
ProcessEngineImpl processEngine = buildEngine(config);
final Integer level = config.getCommandExecutorSchemaOperations().execute(new Command<Integer>() {
@Override
public Integer execute(CommandContext commandContext) {
return HistoryLevelSetupCommand.databaseHistoryLevel(commandContext);
}
});
assertThat(level, equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT.getId()));
assertThat(processEngine.getProcessEngineConfiguration().getHistoryLevel(), equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT));
}
Aggregations