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 };
}
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;
}
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);
}
}
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);
}
}
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());
}
}
Aggregations