Search in sources :

Example 31 with Authorization

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;
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization) User(org.camunda.bpm.engine.identity.User)

Example 32 with Authorization

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);
    }
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization) MissingAuthorization(org.camunda.bpm.engine.authorization.MissingAuthorization)

Example 33 with 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;
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization)

Example 34 with 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());
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

Example 35 with Authorization

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);
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization)

Aggregations

Authorization (org.camunda.bpm.engine.authorization.Authorization)117 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)26 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)22 User (org.camunda.bpm.engine.identity.User)20 Test (org.junit.Test)17 AuthorizationQuery (org.camunda.bpm.engine.authorization.AuthorizationQuery)16 Group (org.camunda.bpm.engine.identity.Group)13 Permission (org.camunda.bpm.engine.authorization.Permission)12 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)9 Tenant (org.camunda.bpm.engine.identity.Tenant)9 AuthorizationDto (org.camunda.bpm.engine.rest.dto.authorization.AuthorizationDto)8 Matchers.anyString (org.mockito.Matchers.anyString)7 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 IdentityService (org.camunda.bpm.engine.IdentityService)3 Resource (org.camunda.bpm.engine.authorization.Resource)3 TenantEntity (org.camunda.bpm.engine.impl.persistence.entity.TenantEntity)3 Before (org.junit.Before)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Filter (org.camunda.bpm.engine.filter.Filter)2