use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.
the class AdministratorAuthorizationPlugin method postProcessEngineBuild.
public void postProcessEngineBuild(ProcessEngine processEngine) {
if (!authorizationEnabled) {
return;
}
final AuthorizationService authorizationService = processEngine.getAuthorizationService();
if (administratorGroupName != null && administratorGroupName.length() > 0) {
// create ADMIN authorizations on all built-in resources for configured group
for (Resource resource : Resources.values()) {
if (authorizationService.createAuthorizationQuery().groupIdIn(administratorGroupName).resourceType(resource).resourceId(ANY).count() == 0) {
AuthorizationEntity adminGroupAuth = new AuthorizationEntity(AUTH_TYPE_GRANT);
adminGroupAuth.setGroupId(administratorGroupName);
adminGroupAuth.setResource(resource);
adminGroupAuth.setResourceId(ANY);
adminGroupAuth.addPermission(ALL);
authorizationService.saveAuthorization(adminGroupAuth);
LOG.grantGroupPermissions(administratorGroupName, resource.resourceName());
}
}
}
if (administratorUserName != null && administratorUserName.length() > 0) {
// create ADMIN authorizations on all built-in resources for configured user
for (Resource resource : Resources.values()) {
if (authorizationService.createAuthorizationQuery().userIdIn(administratorUserName).resourceType(resource).resourceId(ANY).count() == 0) {
AuthorizationEntity adminUserAuth = new AuthorizationEntity(AUTH_TYPE_GRANT);
adminUserAuth.setUserId(administratorUserName);
adminUserAuth.setResource(resource);
adminUserAuth.setResourceId(ANY);
adminUserAuth.addPermission(ALL);
authorizationService.saveAuthorization(adminUserAuth);
LOG.grantUserPermissions(administratorUserName, resource.resourceName());
}
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.
the class DefaultAuthorizationProvider method newUser.
public AuthorizationEntity[] newUser(User user) {
// create an authorization which gives the user all permissions on himself:
String userId = user.getId();
ensureValidIndividualResourceId("Cannot create default authorization for user " + userId, userId);
AuthorizationEntity resourceOwnerAuthorization = createGrantAuthorization(userId, null, USER, userId, ALL);
return new AuthorizationEntity[] { resourceOwnerAuthorization };
}
use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.
the class DefaultAuthorizationProvider method newTaskAssignee.
public AuthorizationEntity[] newTaskAssignee(Task task, String oldAssignee, String newAssignee) {
if (newAssignee != null) {
ensureValidIndividualResourceId("Cannot create default authorization for assignee " + newAssignee, newAssignee);
// create (or update) an authorization for the new assignee.
String taskId = task.getId();
// fetch existing authorization
AuthorizationEntity authorization = getGrantAuthorizationByUserId(newAssignee, 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/TASK_WORK) permission
// Update or TASK_WORK permission is configurable in camunda.cfg.xml and by default, UPDATE permission is provided
authorization = updateAuthorization(authorization, newAssignee, null, TASK, taskId, READ, getDefaultUserPermissionForTask());
// return always created or updated authorization
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 DefaultAuthorizationProvider method newGroup.
public AuthorizationEntity[] newGroup(Group group) {
List<AuthorizationEntity> authorizations = new ArrayList<AuthorizationEntity>();
// whenever a new group is created, all users part of the
// group are granted READ permissions on the group
String groupId = group.getId();
ensureValidIndividualResourceId("Cannot create default authorization for group " + groupId, groupId);
AuthorizationEntity groupMemberAuthorization = createGrantAuthorization(null, groupId, GROUP, groupId, READ);
authorizations.add(groupMemberAuthorization);
return authorizations.toArray(new AuthorizationEntity[0]);
}
use of org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity in project camunda-bpm-platform by camunda.
the class DefaultAuthorizationProvider method newTaskOwner.
public AuthorizationEntity[] newTaskOwner(Task task, String oldOwner, String newOwner) {
if (newOwner != null) {
ensureValidIndividualResourceId("Cannot create default authorization for owner " + newOwner, newOwner);
// create (or update) an authorization for the new owner.
String taskId = task.getId();
// fetch existing authorization
AuthorizationEntity authorization = getGrantAuthorizationByUserId(newOwner, 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/TASK_WORK) permission
// Update or TASK_WORK permission is configurable in camunda.cfg.xml and by default, UPDATE permission is provided
authorization = updateAuthorization(authorization, newOwner, null, TASK, taskId, READ, getDefaultUserPermissionForTask());
// return always created or updated authorization
return new AuthorizationEntity[] { authorization };
}
return null;
}
Aggregations