Search in sources :

Example 81 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class TaskQueryExpressionTest method setUp.

@Before
public void setUp() {
    group1 = createGroup("group1");
    Group group2 = createGroup("group2");
    Group group3 = createGroup("group3");
    user = createUser("user", group1.getId(), group2.getId());
    anotherUser = createUser("anotherUser", group3.getId());
    userWithoutGroups = createUser("userWithoutGroups");
    setTime(1427547759000l);
    task = createTestTask("task");
    // shift time to force distinguishable create times
    adjustTime(2 * 60);
    Task anotherTask = createTestTask("anotherTask");
    Task assignedCandidateTask = createTestTask("assignedCandidateTask");
    taskService.setOwner(task.getId(), user.getId());
    taskService.setAssignee(task.getId(), user.getId());
    taskService.addCandidateUser(anotherTask.getId(), user.getId());
    taskService.addCandidateGroup(anotherTask.getId(), group1.getId());
    taskService.setAssignee(assignedCandidateTask.getId(), user.getId());
    taskService.addCandidateUser(assignedCandidateTask.getId(), user.getId());
    taskService.addCandidateGroup(assignedCandidateTask.getId(), group1.getId());
}
Also used : Group(org.camunda.bpm.engine.identity.Group) Task(org.camunda.bpm.engine.task.Task) Before(org.junit.Before)

Example 82 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class TaskCandidateTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    Group accountants = identityService.newGroup("accountancy");
    identityService.saveGroup(accountants);
    Group managers = identityService.newGroup("management");
    identityService.saveGroup(managers);
    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);
    User kermit = identityService.newUser(KERMIT);
    identityService.saveUser(kermit);
    identityService.createMembership(KERMIT, "accountancy");
    User gonzo = identityService.newUser(GONZO);
    identityService.saveUser(gonzo);
    identityService.createMembership(GONZO, "management");
    identityService.createMembership(GONZO, "accountancy");
    identityService.createMembership(GONZO, "sales");
}
Also used : Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User)

Example 83 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class PurgeDatabaseTest method createAuthenticationData.

private void createAuthenticationData() {
    IdentityService identityService = engineRule.getIdentityService();
    Group group = identityService.newGroup("group");
    identityService.saveGroup(group);
    User user = identityService.newUser("user");
    User user2 = identityService.newUser("user2");
    identityService.saveUser(user);
    identityService.saveUser(user2);
    Tenant tenant = identityService.newTenant("tenant");
    identityService.saveTenant(tenant);
    Tenant tenant2 = identityService.newTenant("tenant2");
    identityService.saveTenant(tenant2);
    identityService.createMembership("user", "group");
    identityService.createTenantUserMembership("tenant", "user");
    identityService.createTenantUserMembership("tenant2", "user2");
    TestResource resource1 = new TestResource("resource1", 100);
    // create global authorization which grants all permissions to all users (on resource1):
    AuthorizationService authorizationService = engineRule.getAuthorizationService();
    Authorization globalAuth = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
    globalAuth.setResource(resource1);
    globalAuth.setResourceId(ANY);
    globalAuth.addPermission(ALL);
    authorizationService.saveAuthorization(globalAuth);
    // grant user read auth on resource2
    TestResource resource2 = new TestResource("resource2", 200);
    Authorization userGrant = authorizationService.createNewAuthorization(AUTH_TYPE_GRANT);
    userGrant.setUserId("user");
    userGrant.setResource(resource2);
    userGrant.setResourceId(ANY);
    userGrant.addPermission(READ);
    authorizationService.saveAuthorization(userGrant);
    identityService.setAuthenticatedUserId("user");
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authorization(org.camunda.bpm.engine.authorization.Authorization) Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User) Tenant(org.camunda.bpm.engine.identity.Tenant) AuthorizationService(org.camunda.bpm.engine.AuthorizationService) TestResource(org.camunda.bpm.engine.test.api.identity.TestResource)

Example 84 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class DefaultPermissionForTenantMemberTest method init.

@Before
public void init() {
    identityService = engineRule.getIdentityService();
    authorizationService = engineRule.getAuthorizationService();
    createTenant(TENANT_ONE);
    User user = identityService.newUser(USER_ID);
    identityService.saveUser(user);
    Group group = identityService.newGroup(GROUP_ID);
    identityService.saveGroup(group);
    engineRule.getProcessEngineConfiguration().setAuthorizationEnabled(true);
}
Also used : Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User) Before(org.junit.Before)

Example 85 with Group

use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.

the class HalGroupResolver method resolveNotCachedLinks.

protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
    IdentityService identityService = processEngine.getIdentityService();
    List<Group> groups = identityService.createGroupQuery().groupIdIn(linkedIds).listPage(0, linkedIds.length);
    List<HalResource<?>> resolvedGroups = new ArrayList<HalResource<?>>();
    for (Group group : groups) {
        resolvedGroups.add(HalGroup.fromGroup(group));
    }
    return resolvedGroups;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Group(org.camunda.bpm.engine.identity.Group) ArrayList(java.util.ArrayList) HalResource(org.camunda.bpm.engine.rest.hal.HalResource)

Aggregations

Group (org.camunda.bpm.engine.identity.Group)92 Test (org.junit.Test)34 User (org.camunda.bpm.engine.identity.User)29 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)22 Authorization (org.camunda.bpm.engine.authorization.Authorization)13 ArrayList (java.util.ArrayList)12 Matchers.anyString (org.mockito.Matchers.anyString)12 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)10 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)9 Tenant (org.camunda.bpm.engine.identity.Tenant)9 IdentityService (org.camunda.bpm.engine.IdentityService)7 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)7 UserQuery (org.camunda.bpm.engine.identity.UserQuery)4 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)4 Before (org.junit.Before)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2