use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationTest 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 AuthorizationScenarioInstance method init.
public void init(AuthorizationService authorizationService, Map<String, String> resourceBindings) {
for (AuthorizationSpec authorizationSpec : scenario.getGivenAuthorizations()) {
Authorization authorization = authorizationSpec.instantiate(authorizationService, resourceBindings);
authorizationService.saveAuthorization(authorization);
createdAuthorizations.add(authorization);
}
for (AuthorizationSpec authorizationSpec : scenario.getMissingAuthorizations()) {
Authorization authorization = authorizationSpec.instantiate(authorizationService, resourceBindings);
missingAuthorizations.add(authorization);
}
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationSpec method instantiate.
public Authorization instantiate(AuthorizationService authorizationService, Map<String, String> replacements) {
Authorization authorization = authorizationService.createNewAuthorization(type);
// TODO: group id is missing
authorization.setResource(resource);
if (replacements.containsKey(resourceId)) {
authorization.setResourceId(replacements.get(resourceId));
} else {
authorization.setResourceId(resourceId);
}
authorization.setUserId(userId);
authorization.setPermissions(permissions);
return authorization;
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class ProcessDefinitionAuthorizationTest method testQueryWithGroupAuthorizationRevokedReadPermission.
public void testQueryWithGroupAuthorizationRevokedReadPermission() {
// given
// given user gets all permissions on any process definition
Authorization authorization = createGrantAuthorization(PROCESS_DEFINITION, ANY);
authorization.setGroupId(groupId);
authorization.addPermission(ALL);
saveAuthorization(authorization);
authorization = createRevokeAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY);
authorization.setGroupId(groupId);
authorization.removePermission(READ);
saveAuthorization(authorization);
// when
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
// then
verifyQueryResults(query, 1);
ProcessDefinition definition = query.singleResult();
assertNotNull(definition);
assertEquals(TWO_TASKS_PROCESS_KEY, definition.getKey());
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceSyncQueryTest method grantAuthorization.
protected void grantAuthorization(String userId, Resource resource, String resourceId, Permission permission) {
Authorization authorization = engineRule.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
authorization.setResource(resource);
authorization.setResourceId(resourceId);
authorization.addPermission(permission);
authorization.setUserId(userId);
engineRule.getAuthorizationService().saveAuthorization(authorization);
authorizations.add(authorization);
}
Aggregations