Java Code Examples for org.flowable.idm.api.User#setId()

The following examples show how to use org.flowable.idm.api.User#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AiaUserEntityManager.java    From plumdo-work with Apache License 2.0 6 votes vote down vote up
@Override
public List<User> findUserByQueryCriteria(UserQueryImpl query) {
    List<User> users = new ArrayList<>();
    ObjectMap response = restClient.getForIdentityService("/users", queryToParams(query), ObjectMap.class);
    if (response == null) {
        return users;
    }
    List<ObjectMap> dataMap = response.getAsList("data");
    for (ObjectMap userMap : dataMap) {
        User user = new UserEntityImpl();
        user.setId(userMap.getAsString("id"));
        user.setFirstName(userMap.getAsString("name"));
        user.setLastName(userMap.getAsString("name"));
        user.setEmail(userMap.getAsString("email"));
        users.add(user);
    }
    return users;
}
 
Example 2
Source File: LDAPIdentityServiceImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public List<User> getUsersWithPrivilege(String name) {
    List<User> users = new ArrayList<>();
    List<PrivilegeMapping> privilegeMappings = getPrivilegeMappingsByPrivilegeId(name);
    for (PrivilegeMapping privilegeMapping : privilegeMappings) {
        if (privilegeMapping.getUserId() != null) {
            User user = new UserEntityImpl();
            user.setId(privilegeMapping.getUserId());
            user.setLastName(privilegeMapping.getUserId());
            users.add(user);
        }
    }
    
    return users;
}
 
Example 3
Source File: FlowableUserDetailsServiceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void testLoadingKnownUserWithAllPrivileges() {
    UserDetails kermit = userDetailsService.loadUserByUsername("kermit");

    assertThat(kermit).isNotNull();
    assertThat(kermit.isCredentialsNonExpired()).as("credentialsNonExpired").isTrue();
    assertThat(kermit.isAccountNonLocked()).as("accountNonLocked").isTrue();
    assertThat(kermit.isAccountNonExpired()).as("accountNonExpired").isTrue();
    assertThat(kermit.isEnabled()).as("enabled").isTrue();
    assertThat(kermit.getUsername()).as("username").isEqualTo("kermit");
    assertThat(kermit.getPassword()).as("password").isEqualTo("kermit");
    assertThat(kermit.getAuthorities())
        .extracting(GrantedAuthority::getAuthority)
        .as("granted authorities")
        .containsExactly(
            "access admin application",
            "access modeler application",
            "start processes"
        );

    assertThat(kermit).isInstanceOf(FlowableUserDetails.class);

    FlowableUserDetails kermitFlowable = (FlowableUserDetails) kermit;

    User user = kermitFlowable.getUser();
    assertThat(user.getId()).isEqualTo("kermit");
    assertThat(user.getFirstName()).isEqualTo("Kermit");
    assertThat(user.getLastName()).isEqualTo("the Frog");
    assertThat(user.getDisplayName()).isEqualTo("Kermit the Frog");
    assertThat(user.getEmail()).isEqualTo("[email protected]");
    assertThat(user.getPassword()).isEqualTo("kermit");

    user.setId("test");
    user.setFirstName("test");
    user.setLastName("test");
    user.setDisplayName("test");
    user.setEmail("test");

    assertThat(user.getId()).isEqualTo("kermit");
    assertThat(user.getFirstName()).isEqualTo("Kermit");
    assertThat(user.getLastName()).isEqualTo("the Frog");
    assertThat(user.getDisplayName()).isEqualTo("Kermit the Frog");
    assertThat(user.getEmail()).isEqualTo("[email protected]");

    assertThat(kermitFlowable.getGroups())
        .extracting(Group::getId, Group::getName, Group::getType)
        .as("Groups")
        .containsExactlyInAnyOrder(
            tuple("admins", "Admins", "user"),
            tuple("sales", "Sales", "user"),
            tuple("engineering", "Engineering", "tech")
        );

    kermitFlowable.getGroups().forEach(group -> {
        group.setId("test");
        group.setType("test");
        group.setName("test");
    });

    assertThat(kermitFlowable.getGroups())
        .extracting(Group::getId, Group::getName, Group::getType)
        .as("Groups")
        .containsExactlyInAnyOrder(
            tuple("admins", "Admins", "user"),
            tuple("sales", "Sales", "user"),
            tuple("engineering", "Engineering", "tech")
        );

    assertThat(kermit).isInstanceOf(CredentialsContainer.class);
    CredentialsContainer container = (CredentialsContainer) kermit;
    container.eraseCredentials();
    assertThat(kermit.getPassword()).as("Password after erase").isNull();
    assertThat(kermitFlowable.getUser().getPassword()).as("User password after erase").isNull();
}
 
Example 4
Source File: FlowableUserDetailsServiceTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void testLoadingKnownUserWithSomePrivileges() {
    UserDetails fozzie = userDetailsService.loadUserByUsername("fozzie");

    assertThat(fozzie).isNotNull();
    assertThat(fozzie.isCredentialsNonExpired()).as("credentialsNonExpired").isTrue();
    assertThat(fozzie.isAccountNonLocked()).as("accountNonLocked").isTrue();
    assertThat(fozzie.isAccountNonExpired()).as("accountNonExpired").isTrue();
    assertThat(fozzie.isEnabled()).as("enabled").isTrue();
    assertThat(fozzie.getUsername()).as("username").isEqualTo("fozzie");
    assertThat(fozzie.getPassword()).as("password").isEqualTo("fozzie");
    assertThat(fozzie.getAuthorities())
        .extracting(GrantedAuthority::getAuthority)
        .as("granted authorities")
        .containsExactly(
            "start processes"
        );

    assertThat(fozzie).isInstanceOf(FlowableUserDetails.class);

    FlowableUserDetails fozzieFlowable = (FlowableUserDetails) fozzie;

    User user = fozzieFlowable.getUser();
    assertThat(user.getId()).isEqualTo("fozzie");
    assertThat(user.getFirstName()).isEqualTo("Fozzie");
    assertThat(user.getLastName()).isEqualTo("Bear");
    assertThat(user.getDisplayName()).isEqualTo("Fozzie Bear");
    assertThat(user.getEmail()).isEqualTo("[email protected]");
    assertThat(user.getPassword()).isEqualTo("fozzie");

    user.setId("test");
    user.setFirstName("test");
    user.setLastName("test");
    user.setDisplayName("test");
    user.setEmail("test");

    assertThat(user.getId()).isEqualTo("fozzie");
    assertThat(user.getFirstName()).isEqualTo("Fozzie");
    assertThat(user.getLastName()).isEqualTo("Bear");
    assertThat(user.getDisplayName()).isEqualTo("Fozzie Bear");
    assertThat(user.getEmail()).isEqualTo("[email protected]");

    assertThat(fozzieFlowable.getGroups())
        .extracting(Group::getId, Group::getName, Group::getType)
        .as("Groups")
        .containsExactlyInAnyOrder(
            tuple("sales", "Sales", "user")
        );
}