use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class JobResourceImpl method setJobRetries.
@Override
public void setJobRetries(RetriesDto dto) {
try {
ManagementService managementService = engine.getManagementService();
managementService.setJobRetries(jobId, dto.getRetries());
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
public void checkAuthorization(List<PermissionCheck> permissionChecks) {
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
String userId = currentAuthentication.getUserId();
boolean isAuthorized = isAuthorized(userId, currentAuthentication.getGroupIds(), permissionChecks);
if (!isAuthorized) {
List<MissingAuthorization> missingAuthorizations = new ArrayList<MissingAuthorization>();
for (PermissionCheck check : permissionChecks) {
missingAuthorizations.add(new MissingAuthorization(check.getPermission().getName(), check.getResource().resourceName(), check.getResourceId()));
}
throw new AuthorizationException(userId, missingAuthorizations);
}
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class AuthorizationManager method checkAuthorization.
public void checkAuthorization(CompositePermissionCheck compositePermissionCheck) {
if (isAuthCheckExecuted()) {
Authentication currentAuthentication = getCurrentAuthentication();
String userId = currentAuthentication.getUserId();
boolean isAuthorized = isAuthorized(compositePermissionCheck);
if (!isAuthorized) {
List<MissingAuthorization> missingAuthorizations = new ArrayList<MissingAuthorization>();
for (PermissionCheck check : compositePermissionCheck.getAllPermissionChecks()) {
missingAuthorizations.add(new MissingAuthorization(check.getPermission().getName(), check.getResource().resourceName(), check.getResourceId()));
}
throw new AuthorizationException(userId, missingAuthorizations);
}
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class DeploymentAuthorizationTest method testRegisterProcessApplicationWithoutAuthorization.
// register process application ///////////////////////////////////
public void testRegisterProcessApplicationWithoutAuthorization() {
// given
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();
ProcessApplicationReference reference = processApplication.getReference();
String deploymentId = createDeployment(null, FIRST_RESOURCE).getId();
try {
// when
managementService.registerProcessApplication(deploymentId, reference);
fail("Exception expected: It should not be possible to register a process application");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent("ENGINE-03029 Required authenticated group 'camunda-admin'", message);
}
deleteDeployment(deploymentId);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testExecuteJobWithoutAuthorization.
// execute job ////////////////////////////////////////////////
public void testExecuteJobWithoutAuthorization() {
// given
Job job = selectAnyJob();
String jobId = job.getId();
try {
// when
managementService.executeJob(jobId);
fail("Exception expected: It should not be possible to execute the job");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(UPDATE.getName(), message);
assertTextPresent(PROCESS_INSTANCE.resourceName(), message);
assertTextPresent(UPDATE_INSTANCE.getName(), message);
assertTextPresent(job.getProcessDefinitionKey(), message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
Aggregations