use of org.camunda.bpm.engine.impl.persistence.entity.UserEntity in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method createMembership.
// membership //////////////////////////////////////////////////////
public void createMembership(String userId, String groupId) {
checkAuthorization(Permissions.CREATE, Resources.GROUP_MEMBERSHIP, groupId);
UserEntity user = findUserById(userId);
GroupEntity group = findGroupById(groupId);
MembershipEntity membership = new MembershipEntity();
membership.setUser(user);
membership.setGroup(group);
getDbEntityManager().insert(membership);
createDefaultMembershipAuthorizations(userId, groupId);
}
use of org.camunda.bpm.engine.impl.persistence.entity.UserEntity 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.UserEntity in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method saveUser.
public User saveUser(User user) {
UserEntity userEntity = (UserEntity) user;
// encrypt password
userEntity.encryptPassword();
if (userEntity.getRevision() == 0) {
checkAuthorization(Permissions.CREATE, Resources.USER, null);
getDbEntityManager().insert(userEntity);
createDefaultAuthorizations(userEntity);
} else {
checkAuthorization(Permissions.UPDATE, Resources.USER, user.getId());
getDbEntityManager().merge(userEntity);
}
return userEntity;
}
use of org.camunda.bpm.engine.impl.persistence.entity.UserEntity in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testUserUnlock.
public void testUserUnlock() throws ParseException {
// crate user while still in god-mode:
String userId = "jonny";
User jonny = identityService.newUser(userId);
jonny.setPassword("xxx");
identityService.saveUser(jonny);
lockUser(userId, "invalid pwd");
// assume
int maxNumOfAttempts = 10;
UserEntity lockedUser = (UserEntity) identityService.createUserQuery().userId(jonny.getId()).singleResult();
assertNotNull(lockedUser);
assertNotNull(lockedUser.getLockExpirationTime());
assertEquals(maxNumOfAttempts, lockedUser.getAttempts());
// create global auth
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(USER);
basePerms.setResourceId(ANY);
basePerms.addPermission(ALL);
authorizationService.saveAuthorization(basePerms);
// set auth
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthentication("admin", Collections.singletonList(Groups.CAMUNDA_ADMIN), null);
// when
identityService.unlockUser(lockedUser.getId());
// then
lockedUser = (UserEntity) identityService.createUserQuery().userId(jonny.getId()).singleResult();
assertNotNull(lockedUser);
assertNull(lockedUser.getLockExpirationTime());
assertEquals(0, lockedUser.getAttempts());
}
Aggregations