use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationTestBaseRule method createGrantAuthorization.
public void createGrantAuthorization(Resource resource, String resourceId, String userId, Permission... permissions) {
Authorization authorization = createAuthorization(Authorization.AUTH_TYPE_GRANT, resource, resourceId);
authorization.setUserId(userId);
for (Permission permission : permissions) {
authorization.addPermission(permission);
}
engineRule.getAuthorizationService().saveAuthorization(authorization);
manageAuthorization(authorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationTestBaseRule method createAuthorization.
protected Authorization createAuthorization(int type, Resource resource, String resourceId) {
Authorization authorization = engineRule.getAuthorizationService().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 CdiBeanResolutionTwoEnginesTest method createAuthorizations.
private void createAuthorizations(ProcessEngine processEngine1) {
Authorization newAuthorization = processEngine1.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL);
newAuthorization.setResource(Resources.PROCESS_INSTANCE);
newAuthorization.setResourceId("*");
newAuthorization.setPermissions(new Permission[] { Permissions.CREATE });
processEngine1.getAuthorizationService().saveAuthorization(newAuthorization);
newAuthorization = processEngine1.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL);
newAuthorization.setResource(Resources.PROCESS_DEFINITION);
newAuthorization.setResourceId("*");
newAuthorization.setPermissions(new Permission[] { Permissions.CREATE_INSTANCE });
processEngine1.getAuthorizationService().saveAuthorization(newAuthorization);
newAuthorization = processEngine1.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GLOBAL);
newAuthorization.setResource(Resources.TASK);
newAuthorization.setResourceId("*");
newAuthorization.setPermissions(new Permission[] { Permissions.READ, Permissions.TASK_WORK });
processEngine1.getAuthorizationService().saveAuthorization(newAuthorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationScenario method startProcessInstance.
@DescribesScenario("startProcessInstance")
@Times(1)
public static ScenarioSetup startProcessInstance() {
return new ScenarioSetup() {
public void execute(ProcessEngine engine, String scenarioName) {
IdentityService identityService = engine.getIdentityService();
String userId = USER_ID + scenarioName;
String groupid = GROUP_ID + scenarioName;
// create an user
User user = identityService.newUser(userId);
identityService.saveUser(user);
// create group
Group group = identityService.newGroup(groupid);
identityService.saveGroup(group);
// create membership
identityService.createMembership(userId, groupid);
// create full authorization
AuthorizationService authorizationService = engine.getAuthorizationService();
// authorization for process definition
Authorization authProcDef = createAuthorization(authorizationService, Permissions.ALL, Resources.PROCESS_DEFINITION, userId);
engine.getAuthorizationService().saveAuthorization(authProcDef);
// authorization for deployment
Authorization authDeployment = createAuthorization(authorizationService, Permissions.ALL, Resources.DEPLOYMENT, userId);
engine.getAuthorizationService().saveAuthorization(authDeployment);
// authorization for process instance create
Authorization authProcessInstance = createAuthorization(authorizationService, Permissions.CREATE, Resources.PROCESS_INSTANCE, userId);
engine.getAuthorizationService().saveAuthorization(authProcessInstance);
// start a process instance
engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
}
};
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class FilterAuthorizationsTest method createTestUser.
protected User createTestUser(String userId) {
User user = identityService.newUser(userId);
identityService.saveUser(user);
// give user all permission to manipulate authorisations
Authorization authorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
authorization.setUserId(user.getId());
authorization.setResource(Resources.AUTHORIZATION);
authorization.setResourceId(Authorization.ANY);
authorization.addPermission(Permissions.ALL);
authorizationService.saveAuthorization(authorization);
// give user all permission to manipulate users
authorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
authorization.setUserId(user.getId());
authorization.setResource(Resources.USER);
authorization.setResourceId(Authorization.ANY);
authorization.addPermission(Permissions.ALL);
authorizationService.saveAuthorization(authorization);
authorization = authorizationService.createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
authorization.setUserId(user.getId());
authorization.setResource(Resources.TASK);
authorization.setResourceId(Authorization.ANY);
authorization.addPermission(Permissions.ALL);
authorizationService.saveAuthorization(authorization);
return user;
}
Aggregations