use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method createTenantUserMembership.
public void createTenantUserMembership(String tenantId, String userId) {
checkAuthorization(Permissions.CREATE, Resources.TENANT_MEMBERSHIP, tenantId);
TenantEntity tenant = findTenantById(tenantId);
UserEntity user = findUserById(userId);
ensureNotNull("No tenant found with id '" + tenantId + "'.", "tenant", tenant);
ensureNotNull("No user found with id '" + userId + "'.", "user", user);
TenantMembershipEntity membership = new TenantMembershipEntity();
membership.setTenant(tenant);
membership.setUser(user);
getDbEntityManager().insert(membership);
createDefaultTenantMembershipAuthorizations(tenant, user);
}
use of org.camunda.bpm.engine.impl.persistence.entity.TenantEntity in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testTenantUpdateAuthorizations.
public void testTenantUpdateAuthorizations() {
// 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 update
basePerms.removePermission(UPDATE);
authorizationService.saveAuthorization(basePerms);
// turn on authorization
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId(jonny2);
// fetch user:
tenant = identityService.createTenantQuery().singleResult();
tenant.setName("newName");
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(UPDATE.getName(), TENANT.resourceName(), "tenant", info);
}
// but I can create a new tenant:
Tenant newTenant = identityService.newTenant("newTenant");
identityService.saveTenant(newTenant);
}
Aggregations