use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method deleteTenant.
public void deleteTenant(String tenantId) {
checkAuthorization(Permissions.DELETE, Resources.TENANT, tenantId);
TenantEntity tenant = findTenantById(tenantId);
if (tenant != null) {
deleteTenantMembershipsOfTenant(tenantId);
deleteAuthorizations(Resources.TENANT, tenantId);
getDbEntityManager().delete(tenant);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method saveTenant.
public Tenant saveTenant(Tenant tenant) {
TenantEntity tenantEntity = (TenantEntity) tenant;
if (tenantEntity.getRevision() == 0) {
checkAuthorization(Permissions.CREATE, Resources.TENANT, null);
getDbEntityManager().insert(tenantEntity);
createDefaultAuthorizations(tenant);
} else {
checkAuthorization(Permissions.UPDATE, Resources.TENANT, tenant.getId());
getDbEntityManager().merge(tenantEntity);
}
return tenantEntity;
}
use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method createTenantGroupMembership.
public void createTenantGroupMembership(String tenantId, String groupId) {
checkAuthorization(Permissions.CREATE, Resources.TENANT_MEMBERSHIP, tenantId);
TenantEntity tenant = findTenantById(tenantId);
GroupEntity group = findGroupById(groupId);
ensureNotNull("No tenant found with id '" + tenantId + "'.", "tenant", tenant);
ensureNotNull("No group found with id '" + groupId + "'.", "group", group);
TenantMembershipEntity membership = new TenantMembershipEntity();
membership.setTenant(tenant);
membership.setGroup(group);
getDbEntityManager().insert(membership);
createDefaultTenantMembershipAuthorizations(tenant, group);
}
use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testTenantCreateAuthorizations.
public void testTenantCreateAuthorizations() {
// add base permission which allows nobody to create tenants:
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(TENANT);
basePerms.setResourceId(ANY);
// add all then remove 'create'
basePerms.addPermission(ALL);
basePerms.removePermission(CREATE);
authorizationService.saveAuthorization(basePerms);
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId(jonny2);
try {
identityService.newTenant("tenant");
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(CREATE.getName(), TENANT.resourceName(), null, info);
}
// circumvent auth check to get new transient userobject
Tenant tenant = new TenantEntity("tenant");
try {
identityService.saveTenant(tenant);
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(CREATE.getName(), TENANT.resourceName(), null, info);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testTenantDeleteAuthorizations.
public void testTenantDeleteAuthorizations() {
// create tenant
Tenant tenant = new TenantEntity("tenant");
identityService.saveTenant(tenant);
// create global auth
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(TENANT);
basePerms.setResourceId(ANY);
basePerms.addPermission(ALL);
// revoke delete
basePerms.removePermission(DELETE);
authorizationService.saveAuthorization(basePerms);
// turn on authorization
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId(jonny2);
try {
identityService.deleteTenant("tenant");
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(DELETE.getName(), TENANT.resourceName(), "tenant", info);
}
}
Aggregations