Search in sources :

Example 96 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class ModelInstanceCache method loadAndCacheBpmnModelInstance.

protected InstanceType loadAndCacheBpmnModelInstance(final DefinitionType definitionEntity) {
    final CommandContext commandContext = Context.getCommandContext();
    InputStream bpmnResourceInputStream = commandContext.runWithoutAuthorization(new Callable<InputStream>() {

        public InputStream call() throws Exception {
            return new GetDeploymentResourceCmd(definitionEntity.getDeploymentId(), definitionEntity.getResourceName()).execute(commandContext);
        }
    });
    try {
        InstanceType bpmnModelInstance = readModelFromStream(bpmnResourceInputStream);
        instanceCache.put(definitionEntity.getId(), bpmnModelInstance);
        return bpmnModelInstance;
    } catch (Exception e) {
        throwLoadModelException(definitionEntity.getId(), e);
    }
    return null;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) InputStream(java.io.InputStream) GetDeploymentResourceCmd(org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)

Example 97 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class ResourceDefinitionCache method findDeployedDefinitionByKeyVersionAndTenantId.

public T findDeployedDefinitionByKeyVersionAndTenantId(final String definitionKey, final Integer definitionVersion, final String tenantId) {
    final CommandContext commandContext = Context.getCommandContext();
    T definition = commandContext.runWithoutAuthorization(new Callable<T>() {

        public T call() throws Exception {
            return getManager().findDefinitionByKeyVersionAndTenantId(definitionKey, definitionVersion, tenantId);
        }
    });
    checkInvalidDefinitionByKeyVersionAndTenantId(definitionKey, definitionVersion, tenantId, definition);
    definition = resolveDefinition(definition);
    return definition;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 98 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class AuthorizationManager method isAuthCheckExecuted.

protected boolean isAuthCheckExecuted() {
    Authentication currentAuthentication = getCurrentAuthentication();
    CommandContext commandContext = Context.getCommandContext();
    return isAuthorizationEnabled() && commandContext.isAuthorizationCheckEnabled() && currentAuthentication != null && currentAuthentication.getUserId() != null;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Authentication(org.camunda.bpm.engine.impl.identity.Authentication)

Example 99 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class AuthorizationManager method addPermissionCheck.

protected void addPermissionCheck(ListQueryParameterObject query, Resource resource, String queryParam, Permission permission) {
    CommandContext commandContext = getCommandContext();
    if (isAuthorizationEnabled() && getCurrentAuthentication() != null && commandContext.isAuthorizationCheckEnabled()) {
        PermissionCheck permCheck = newPermissionCheck();
        permCheck.setResource(resource);
        permCheck.setResourceIdQueryParam(queryParam);
        permCheck.setPermission(permission);
        query.getAuthCheck().addAtomicPermissionCheck(permCheck);
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) PermissionCheck(org.camunda.bpm.engine.impl.db.PermissionCheck) CompositePermissionCheck(org.camunda.bpm.engine.impl.db.CompositePermissionCheck)

Example 100 with CommandContext

use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.

the class HistoricStatisticsManager method ensureHistoryReadOnProcessDefinition.

protected boolean ensureHistoryReadOnProcessDefinition(HistoricActivityStatisticsQueryImpl query) {
    CommandContext commandContext = getCommandContext();
    if (isAuthorizationEnabled() && getCurrentAuthentication() != null && commandContext.isAuthorizationCheckEnabled()) {
        String processDefinitionId = query.getProcessDefinitionId();
        ProcessDefinitionEntity definition = getProcessDefinitionManager().findLatestProcessDefinitionById(processDefinitionId);
        if (definition == null) {
            return false;
        }
        return getAuthorizationManager().isAuthorized(READ_HISTORY, PROCESS_DEFINITION, definition.getKey());
    }
    return true;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext)

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