Search in sources :

Example 6 with UserEntity

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);
}
Also used : MembershipEntity(org.camunda.bpm.engine.impl.persistence.entity.MembershipEntity) TenantMembershipEntity(org.camunda.bpm.engine.impl.persistence.entity.TenantMembershipEntity) GroupEntity(org.camunda.bpm.engine.impl.persistence.entity.GroupEntity) UserEntity(org.camunda.bpm.engine.impl.persistence.entity.UserEntity)

Example 7 with UserEntity

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);
}
Also used : TenantMembershipEntity(org.camunda.bpm.engine.impl.persistence.entity.TenantMembershipEntity) TenantEntity(org.camunda.bpm.engine.impl.persistence.entity.TenantEntity) UserEntity(org.camunda.bpm.engine.impl.persistence.entity.UserEntity)

Example 8 with UserEntity

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;
}
Also used : UserEntity(org.camunda.bpm.engine.impl.persistence.entity.UserEntity)

Example 9 with 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());
}
Also used : MissingAuthorization(org.camunda.bpm.engine.authorization.MissingAuthorization) Authorization(org.camunda.bpm.engine.authorization.Authorization) User(org.camunda.bpm.engine.identity.User) UserEntity(org.camunda.bpm.engine.impl.persistence.entity.UserEntity)

Aggregations

UserEntity (org.camunda.bpm.engine.impl.persistence.entity.UserEntity)9 User (org.camunda.bpm.engine.identity.User)4 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)2 Authorization (org.camunda.bpm.engine.authorization.Authorization)2 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)2 TenantMembershipEntity (org.camunda.bpm.engine.impl.persistence.entity.TenantMembershipEntity)2 ArrayList (java.util.ArrayList)1 AuthenticationException (javax.naming.AuthenticationException)1 NamingException (javax.naming.NamingException)1 SearchResult (javax.naming.directory.SearchResult)1 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 IdentityProviderException (org.camunda.bpm.engine.impl.identity.IdentityProviderException)1 GroupEntity (org.camunda.bpm.engine.impl.persistence.entity.GroupEntity)1 MembershipEntity (org.camunda.bpm.engine.impl.persistence.entity.MembershipEntity)1 TenantEntity (org.camunda.bpm.engine.impl.persistence.entity.TenantEntity)1