Search in sources :

Example 31 with IdentityService

use of org.camunda.bpm.engine.IdentityService 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 32 with IdentityService

use of org.camunda.bpm.engine.IdentityService 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

IdentityService (org.camunda.bpm.engine.IdentityService)32 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)9 User (org.camunda.bpm.engine.identity.User)8 Group (org.camunda.bpm.engine.identity.Group)7 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 RuntimeService (org.camunda.bpm.engine.RuntimeService)6 ArrayList (java.util.ArrayList)4 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)4 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 Authorization (org.camunda.bpm.engine.authorization.Authorization)3 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)3 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)3 URI (java.net.URI)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 FilterService (org.camunda.bpm.engine.FilterService)2 FormService (org.camunda.bpm.engine.FormService)2 TaskService (org.camunda.bpm.engine.TaskService)2 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)2