Search in sources :

Example 11 with CommandContext

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();
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Authentication(org.camunda.bpm.engine.impl.identity.Authentication)

Example 12 with CommandContext

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;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessDefinitionQueryImpl(org.camunda.bpm.engine.impl.ProcessDefinitionQueryImpl) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) List(java.util.List)

Example 13 with CommandContext

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;
        }
    });
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) List(java.util.List)

Example 14 with CommandContext

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();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 15 with CommandContext

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));
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl) Test(org.junit.Test)

Aggregations

CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)120 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)31 List (java.util.List)17 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)17 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 ArrayList (java.util.ArrayList)10 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)10 Date (java.util.Date)9 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)8 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)8 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)8 Command (org.camunda.bpm.engine.impl.interceptor.Command)6 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)6 After (org.junit.After)6 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)5 RepositoryService (org.camunda.bpm.engine.RepositoryService)5 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)5 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)5 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)4