use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class ResourceAuthorizationProviderTest method createGrantAuthorization.
// authorization ///////////////////////////////////////////////////////
protected void createGrantAuthorization(Resource resource, String resourceId, Permission permission, String userId) {
Authorization authorization = createGrantAuthorization(resource, resourceId);
authorization.setUserId(userId);
authorization.addPermission(permission);
saveAuthorization(authorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class ResourceAuthorizationProviderTest method createAuthorization.
protected Authorization createAuthorization(int type, Resource resource, String resourceId) {
Authorization authorization = authorizationService.createNewAuthorization(type);
authorization.setResource(resource);
if (resourceId != null) {
authorization.setResourceId(resourceId);
}
return authorization;
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class ResourceAuthorizationProviderTest method createUser.
// user ////////////////////////////////////////////////////////////////
protected User createUser(String userId) {
User user = identityService.newUser(userId);
identityService.saveUser(user);
// give user all permission to manipulate authorizations
Authorization authorization = createGrantAuthorization(AUTHORIZATION, ANY);
authorization.setUserId(userId);
authorization.addPermission(ALL);
saveAuthorization(authorization);
// give user all permission to manipulate users
authorization = createGrantAuthorization(USER, ANY);
authorization.setUserId(userId);
authorization.addPermission(Permissions.ALL);
saveAuthorization(authorization);
return user;
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testClearProcessInstanceAuthorization.
// clear process instance authorization ////////////////////////
public void testClearProcessInstanceAuthorization() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, ALL);
createGrantAuthorization(TASK, ANY, userId, ALL);
disableAuthorization();
Authorization authorization = authorizationService.createAuthorizationQuery().resourceId(processInstanceId).singleResult();
enableAuthorization();
assertNotNull(authorization);
String taskId = selectSingleTask().getId();
// when
taskService.complete(taskId);
// then
disableAuthorization();
authorization = authorizationService.createAuthorizationQuery().resourceId(processInstanceId).singleResult();
enableAuthorization();
assertNull(authorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationServiceWithEnabledAuthorizationTest method testUserOverrideGlobalRevokeAuthorizationCheck.
public void testUserOverrideGlobalRevokeAuthorizationCheck() {
TestResource resource1 = new TestResource("resource1", 100);
// create global authorization which revokes all permissions to all users (on resource1):
Authorization globalGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
globalGrant.setResource(resource1);
globalGrant.setResourceId(ANY);
globalGrant.removePermission(ALL);
authorizationService.saveAuthorization(globalGrant);
// add READ for jonny
Authorization localRevoke = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
localRevoke.setUserId("jonny");
localRevoke.setResource(resource1);
localRevoke.setResourceId(ANY);
localRevoke.addPermission(READ);
authorizationService.saveAuthorization(localRevoke);
// jonny does not have ALL permissions
assertFalse(authorizationService.isUserAuthorized("jonny", null, ALL, resource1));
// jonny can read
assertTrue(authorizationService.isUserAuthorized("jonny", null, READ, resource1));
// jonny can't delete
assertFalse(authorizationService.isUserAuthorized("jonny", null, DELETE, resource1));
// someone else can't do anything
assertFalse(authorizationService.isUserAuthorized("someone else", null, ALL, resource1));
assertFalse(authorizationService.isUserAuthorized("someone else", null, READ, resource1));
assertFalse(authorizationService.isUserAuthorized("someone else", null, DELETE, resource1));
}
Aggregations