Search in sources :

Example 11 with AuthorizationEntity

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.

the class DefaultAuthorizationProvider method newTaskGroupIdentityLink.

public AuthorizationEntity[] newTaskGroupIdentityLink(Task task, String groupId, String type) {
    ensureValidIndividualResourceId("Cannot grant default authorization for identity link to group " + groupId, groupId);
    // create (or update) an authorization for the given group
    // whenever a new user identity link will be added
    String taskId = task.getId();
    // fetch existing authorization
    AuthorizationEntity authorization = getGrantAuthorizationByGroupId(groupId, TASK, taskId);
    // update authorization:
    // (1) fetched authorization == null -> create a new authorization (with READ and (UPDATE/TASK_WORK) permission)
    // (2) fetched authorization != null -> add READ and UPDATE permission
    // Update or TASK_WORK permission is configurable in camunda.cfg.xml and by default, UPDATE permission is provided
    authorization = updateAuthorization(authorization, null, groupId, TASK, taskId, READ, getDefaultUserPermissionForTask());
    // return always created or updated authorization
    return new AuthorizationEntity[] { authorization };
}
Also used : AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity)

Example 12 with AuthorizationEntity

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.

the class DefaultAuthorizationProvider method newDeployment.

// Deployment ///////////////////////////////////////////////
public AuthorizationEntity[] newDeployment(Deployment deployment) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    IdentityService identityService = processEngineConfiguration.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    if (currentAuthentication != null && currentAuthentication.getUserId() != null) {
        String userId = currentAuthentication.getUserId();
        String deploymentId = deployment.getId();
        AuthorizationEntity authorization = createGrantAuthorization(userId, null, DEPLOYMENT, deploymentId, READ, DELETE);
        return new AuthorizationEntity[] { authorization };
    }
    return null;
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 13 with AuthorizationEntity

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.

the class DecisionDefinitionManager method createDefaultAuthorizations.

protected void createDefaultAuthorizations(DecisionDefinition decisionDefinition) {
    if (isAuthorizationEnabled()) {
        ResourceAuthorizationProvider provider = getResourceAuthorizationProvider();
        AuthorizationEntity[] authorizations = provider.newDecisionDefinition(decisionDefinition);
        saveDefaultAuthorizations(authorizations);
    }
}
Also used : ResourceAuthorizationProvider(org.camunda.bpm.engine.impl.cfg.auth.ResourceAuthorizationProvider) AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity)

Example 14 with AuthorizationEntity

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.

the class DecisionRequirementsDefinitionManager method createDefaultAuthorizations.

protected void createDefaultAuthorizations(DecisionRequirementsDefinition decisionRequirementsDefinition) {
    if (isAuthorizationEnabled()) {
        ResourceAuthorizationProvider provider = getResourceAuthorizationProvider();
        AuthorizationEntity[] authorizations = provider.newDecisionRequirementsDefinition(decisionRequirementsDefinition);
        saveDefaultAuthorizations(authorizations);
    }
}
Also used : ResourceAuthorizationProvider(org.camunda.bpm.engine.impl.cfg.auth.ResourceAuthorizationProvider) AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity)

Example 15 with AuthorizationEntity

use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.

the class AuthorizationServiceTest method testGlobalAuthPermissions.

public void testGlobalAuthPermissions() {
    AuthorizationEntity authorization = new AuthorizationEntity(AUTH_TYPE_GRANT);
    assertFalse(authorization.isPermissionGranted(ALL));
    assertTrue(authorization.isPermissionGranted(NONE));
    List<Permission> perms = Arrays.asList(authorization.getPermissions(Permissions.values()));
    assertTrue(perms.contains(NONE));
    assertEquals(1, perms.size());
    authorization.addPermission(READ);
    perms = Arrays.asList(authorization.getPermissions(Permissions.values()));
    assertTrue(perms.contains(NONE));
    assertTrue(perms.contains(READ));
    assertEquals(2, perms.size());
    assertTrue(authorization.isPermissionGranted(READ));
    // (none is always granted => you are always authorized to do nothing)
    assertTrue(authorization.isPermissionGranted(NONE));
    try {
        authorization.isPermissionRevoked(READ);
        fail("Exception expected");
    } catch (IllegalStateException e) {
        assertTextPresent("ENGINE-03026 Method 'isPermissionRevoked' cannot be used for authorization with type 'GRANT'.", e.getMessage());
    }
}
Also used : AuthorizationEntity(org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity) Permission(org.camunda.bpm.engine.authorization.Permission)

Aggregations

AuthorizationEntity (org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity)19 Permission (org.camunda.bpm.engine.authorization.Permission)4 AuthorizationService (org.camunda.bpm.engine.AuthorizationService)2 IdentityService (org.camunda.bpm.engine.IdentityService)2 Authorization (org.camunda.bpm.engine.authorization.Authorization)2 Resource (org.camunda.bpm.engine.authorization.Resource)2 ResourceAuthorizationProvider (org.camunda.bpm.engine.impl.cfg.auth.ResourceAuthorizationProvider)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 FilterService (org.camunda.bpm.engine.FilterService)1 TaskService (org.camunda.bpm.engine.TaskService)1 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)1 Filter (org.camunda.bpm.engine.filter.Filter)1 Group (org.camunda.bpm.engine.identity.Group)1 User (org.camunda.bpm.engine.identity.User)1 AuthorizationQueryImpl (org.camunda.bpm.engine.impl.AuthorizationQueryImpl)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)1