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