Java Code Examples for org.flowable.idm.api.User#setFirstName()
The following examples show how to use
org.flowable.idm.api.User#setFirstName() .
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 |
@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: Application.java From flowable-engine with Apache License 2.0 | 6 votes |
@Bean InitializingBean usersAndGroupsInitializer(final IdentityService identityService) { return new InitializingBean() { @Override public void afterPropertiesSet() throws Exception { // install groups & users Group group = identityService.newGroup("user"); group.setName("users"); group.setType("security-role"); identityService.saveGroup(group); User josh = identityService.newUser("jlong"); josh.setFirstName("Josh"); josh.setLastName("Long"); josh.setPassword("password"); identityService.saveUser(josh); identityService.createMembership("jlong", "user"); } }; }
Example 3
Source File: IdentityServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testUserOptimisticLockingException() { User user = idmIdentityService.newUser("kermit"); idmIdentityService.saveUser(user); User user1 = idmIdentityService.createUserQuery().singleResult(); User user2 = idmIdentityService.createUserQuery().singleResult(); user1.setFirstName("name one"); idmIdentityService.saveUser(user1); assertThatThrownBy(() -> { user2.setFirstName("name two"); idmIdentityService.saveUser(user2); }) .isExactlyInstanceOf(FlowableOptimisticLockingException.class); idmIdentityService.deleteUser(user.getId()); }
Example 4
Source File: IdentityTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testUser() { User user = identityService.newUser("johndoe"); user.setFirstName("John"); user.setLastName("Doe"); user.setEmail("[email protected]"); identityService.saveUser(user); user = identityService.createUserQuery().userId("johndoe").singleResult(); assertThat(user.getId()).isEqualTo("johndoe"); assertThat(user.getFirstName()).isEqualTo("John"); assertThat(user.getLastName()).isEqualTo("Doe"); assertThat(user.getEmail()).isEqualTo("[email protected]"); identityService.deleteUser("johndoe"); }
Example 5
Source File: BaseSpringRestTestCase.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void createUsers() { User user = identityService.newUser("kermit"); user.setFirstName("Kermit"); user.setLastName("the Frog"); user.setPassword("kermit"); identityService.saveUser(user); Group group = identityService.newGroup("admin"); group.setName("Administrators"); identityService.saveGroup(group); identityService.createMembership(user.getId(), group.getId()); user = identityService.newUser("aSalesUser"); user.setFirstName("Sales"); user.setLastName("User"); user.setPassword("sales"); identityService.saveUser(user); Group salesGroup = identityService.newGroup("sales"); salesGroup.setName("Administrators"); identityService.saveGroup(salesGroup); identityService.createMembership(user.getId(), salesGroup.getId()); }
Example 6
Source File: IdentityServiceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testUpdateUser() { // First, create a new user User user = identityService.newUser("johndoe"); user.setFirstName("John"); user.setLastName("Doe"); user.setEmail("[email protected]"); identityService.saveUser(user); // Fetch and update the user user = identityService.createUserQuery().userId("johndoe").singleResult(); user.setEmail("[email protected]"); user.setFirstName("Jane"); user.setLastName("Donnel"); identityService.saveUser(user); user = identityService.createUserQuery().userId("johndoe").singleResult(); assertEquals("Jane", user.getFirstName()); assertEquals("Donnel", user.getLastName()); assertEquals("[email protected]", user.getEmail()); identityService.deleteUser(user.getId()); }
Example 7
Source File: CreateUserAndMembershipTestDelegate.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void execute(DelegateExecution execution) { ManagementService managementService = Context.getProcessEngineConfiguration().getManagementService(); managementService.executeCommand(new Command<Void>() { @Override public Void execute(CommandContext commandContext) { return null; } }); IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService(); String username = "Kermit"; User user = identityService.newUser(username); user.setPassword("123"); user.setFirstName("Manually"); user.setLastName("created"); identityService.saveUser(user); // Add admin group Group group = identityService.newGroup("admin"); identityService.saveGroup(group); identityService.createMembership(username, "admin"); }
Example 8
Source File: UserCollectionResource.java From flowable-engine with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Create a user", tags = { "Users" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the user was created."), @ApiResponse(code = 400, message = "Indicates the id of the user was missing.") }) @PostMapping(value = "/users", produces = "application/json") public UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response) { if (userRequest.getId() == null) { throw new FlowableIllegalArgumentException("Id cannot be null."); } // Check if a user with the given ID already exists so we return a CONFLICT if (identityService.createUserQuery().userId(userRequest.getId()).count() > 0) { throw new FlowableConflictException("A user with id '" + userRequest.getId() + "' already exists."); } User created = identityService.newUser(userRequest.getId()); created.setEmail(userRequest.getEmail()); created.setFirstName(userRequest.getFirstName()); created.setLastName(userRequest.getLastName()); created.setDisplayName(userRequest.getDisplayName()); created.setPassword(userRequest.getPassword()); if (restApiInterceptor != null) { restApiInterceptor.createNewUser(created); } identityService.saveUser(created); response.setStatus(HttpStatus.CREATED.value()); return idmRestResponseFactory.createUserResponse(created, false); }
Example 9
Source File: BaseSpringRestTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void createUsers() { User user = idmIdentityService.newUser("kermit"); user.setFirstName("Kermit"); user.setLastName("the Frog"); user.setPassword("kermit"); idmIdentityService.saveUser(user); Group group = idmIdentityService.newGroup("admin"); group.setName("Administrators"); idmIdentityService.saveGroup(group); idmIdentityService.createMembership(user.getId(), group.getId()); }
Example 10
Source File: BaseSpringRestTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void createUsers() { User user = identityService.newUser("kermit"); user.setFirstName("Kermit"); user.setLastName("the Frog"); user.setPassword("kermit"); identityService.saveUser(user); Group group = identityService.newGroup("admin"); group.setName("Administrators"); identityService.saveGroup(group); identityService.createMembership(user.getId(), group.getId()); }
Example 11
Source File: UserResource.java From flowable-engine with Apache License 2.0 | 5 votes |
@ApiOperation(value = "Update a user", tags = { "Users" }, notes = "All request values are optional. " + "For example, you can only include the firstName attribute in the request body JSON-object, only updating the firstName of the user, leaving all other fields unaffected. " + "When an attribute is explicitly included and is set to null, the user-value will be updated to null. " + "Example: {\"firstName\" : null} will clear the firstName of the user).") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the user was updated."), @ApiResponse(code = 404, message = "Indicates the requested user was not found."), @ApiResponse(code = 409, message = "Indicates the requested user was updated simultaneously.") }) @PutMapping(value = "/users/{userId}", produces = "application/json") public UserResponse updateUser(@ApiParam(name = "userId") @PathVariable String userId, @RequestBody UserRequest userRequest, HttpServletRequest request) { User user = getUserFromRequest(userId); if (userRequest.isEmailChanged()) { user.setEmail(userRequest.getEmail()); } if (userRequest.isFirstNameChanged()) { user.setFirstName(userRequest.getFirstName()); } if (userRequest.isLastNameChanged()) { user.setLastName(userRequest.getLastName()); } if (userRequest.isDisplayNameChanged()) { user.setDisplayName(userRequest.getDisplayName()); } if (userRequest.isPasswordChanged()) { user.setPassword(userRequest.getPassword()); identityService.updateUserPassword(user); } else { identityService.saveUser(user); } return restResponseFactory.createUserResponse(user, false); }
Example 12
Source File: UserPictureResourceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Test getting the picture for a user. */ @Test public void testGetUserPicture() throws Exception { User savedUser = null; try { User newUser = identityService.newUser("testuser"); newUser.setFirstName("Fred"); newUser.setLastName("McDonald"); newUser.setEmail("[email protected]"); identityService.saveUser(newUser); savedUser = newUser; // Create picture for user Picture thePicture = new Picture("this is the picture raw byte stream".getBytes(), "image/png"); identityService.setUserPicture(newUser.getId(), thePicture); CloseableHttpResponse response = executeRequest( new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER_PICTURE, newUser.getId())), HttpStatus.SC_OK); try (InputStream contentStream = response.getEntity().getContent()) { assertThat(contentStream).hasContent("this is the picture raw byte stream"); } // Check if media-type is correct assertThat(response.getEntity().getContentType().getValue()).isEqualTo("image/png"); closeResponse(response); } finally { // Delete user after test passes or fails if (savedUser != null) { identityService.deleteUser(savedUser.getId()); } } }
Example 13
Source File: UserServiceImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
public void updateUserDetails(String userId, String firstName, String lastName, String email, String tenantId) { User user = identityService.createUserQuery().userId(userId).singleResult(); if (user != null) { user.setFirstName(firstName); user.setLastName(lastName); user.setEmail(email); user.setTenantId(tenantId); identityService.saveUser(user); } }
Example 14
Source File: UserQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private User createUser(String id, String firstName, String lastName, String displayName, String email) { User user = idmIdentityService.newUser(id); user.setFirstName(firstName); user.setLastName(lastName); user.setDisplayName(displayName); user.setEmail(email); idmIdentityService.saveUser(user); return user; }
Example 15
Source File: IdentityServiceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testChangePassword() { idmEngineConfiguration.setPasswordEncoder(new ApacheDigester(ApacheDigester.Digester.MD5)); User user = idmIdentityService.newUser("johndoe"); user.setPassword("xxx"); idmIdentityService.saveUser(user); user = idmIdentityService.createUserQuery().userId("johndoe").list().get(0); user.setFirstName("John Doe"); idmIdentityService.saveUser(user); User johndoe = idmIdentityService.createUserQuery().userId("johndoe").list().get(0); assertThat(johndoe.getPassword()).isNotEqualTo("xxx"); assertThat(johndoe.getFirstName()).isEqualTo("John Doe"); assertThat(idmIdentityService.checkPassword("johndoe", "xxx")).isTrue(); user = idmIdentityService.createUserQuery().userId("johndoe").list().get(0); user.setPassword("yyy"); idmIdentityService.saveUser(user); assertThat(idmIdentityService.checkPassword("johndoe", "xxx")).isTrue(); user = idmIdentityService.createUserQuery().userId("johndoe").list().get(0); user.setPassword("yyy"); idmIdentityService.updateUserPassword(user); assertThat(idmIdentityService.checkPassword("johndoe", "yyy")).isTrue(); idmIdentityService.deleteUser("johndoe"); }
Example 16
Source File: UserQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private User createUser(String id, String firstName, String lastName, String email, String tenantId) { User user = identityService.newUser(id); user.setFirstName(firstName); user.setLastName(lastName); user.setEmail(email); user.setTenantId(tenantId); identityService.saveUser(user); return user; }
Example 17
Source File: ChangePasswordIdentityServiceTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testChangePassword() { try { User user = identityService.newUser("johndoe"); user.setPassword("xxx"); identityService.saveUser(user); user = identityService.createUserQuery().userId("johndoe").list().get(0); user.setFirstName("John Doe"); identityService.saveUser(user); User johndoe = identityService.createUserQuery().userId("johndoe").list().get(0); assertThat(johndoe.getPassword()).isNotEqualTo("xxx"); assertThat(johndoe.getFirstName()).isEqualTo("John Doe"); assertThat(identityService.checkPassword("johndoe", "xxx")).isTrue(); user = identityService.createUserQuery().userId("johndoe").list().get(0); user.setPassword("yyy"); identityService.saveUser(user); assertThat(identityService.checkPassword("johndoe", "xxx")).isTrue(); user = identityService.createUserQuery().userId("johndoe").list().get(0); user.setPassword("yyy"); identityService.updateUserPassword(user); assertThat(identityService.checkPassword("johndoe", "yyy")).isTrue(); } finally { identityService.deleteUser("johndoe"); } }
Example 18
Source File: UserResourceTest.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * Test updating a single user passing in no fields in the json, user should remain unchanged. */ @Test public void testUpdateUserNullFields() throws Exception { User savedUser = null; try { User newUser = identityService.newUser("testuser"); newUser.setFirstName("Fred"); newUser.setLastName("McDonald"); newUser.setDisplayName("Fred McDonald"); newUser.setEmail("[email protected]"); identityService.saveUser(newUser); savedUser = newUser; ObjectNode taskUpdateRequest = objectMapper.createObjectNode(); taskUpdateRequest.putNull("firstName"); taskUpdateRequest.putNull("lastName"); taskUpdateRequest.putNull("displayName"); taskUpdateRequest.putNull("email"); taskUpdateRequest.putNull("password"); HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())); httpPut.setEntity(new StringEntity(taskUpdateRequest.toString())); CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertThat(responseNode).isNotNull(); assertThatJson(responseNode) .when(Option.IGNORING_EXTRA_FIELDS) .isEqualTo("{" + "id: 'testuser'," + "firstName: null," + "lastName: null," + "displayName: null," + "email: null," + "url: '" + SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId()) + "'" + "}"); // Check user is updated in Flowable newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult(); assertThat(newUser.getLastName()).isNull(); assertThat(newUser.getFirstName()).isNull(); assertThat(newUser.getDisplayName()).isNull(); assertThat(newUser.getEmail()).isNull(); } finally { // Delete user after test fails if (savedUser != null) { identityService.deleteUser(savedUser.getId()); } } }
Example 19
Source File: UserResourceTest.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * Test updating a single user. */ @Test public void testUpdateUser() throws Exception { User savedUser = null; try { User newUser = identityService.newUser("testuser"); newUser.setFirstName("Fred"); newUser.setLastName("McDonald"); newUser.setEmail("[email protected]"); identityService.saveUser(newUser); savedUser = newUser; ObjectNode taskUpdateRequest = objectMapper.createObjectNode(); taskUpdateRequest.put("firstName", "Tijs"); taskUpdateRequest.put("lastName", "Barrez"); taskUpdateRequest.put("displayName", "Tijs Barrez"); taskUpdateRequest.put("email", "[email protected]"); taskUpdateRequest.put("password", "updatedpassword"); HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId())); httpPut.setEntity(new StringEntity(taskUpdateRequest.toString())); CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertThat(responseNode).isNotNull(); assertThatJson(responseNode) .when(Option.IGNORING_EXTRA_FIELDS) .isEqualTo("{" + "id: 'testuser'," + "firstName: 'Tijs'," + "lastName: 'Barrez'," + "displayName: 'Tijs Barrez'," + "email: '[email protected]'," + "url: '" + SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_USER, newUser.getId()) + "'" + "}"); // Check user is updated in Flowable newUser = identityService.createUserQuery().userId(newUser.getId()).singleResult(); assertThat(newUser.getLastName()).isEqualTo("Barrez"); assertThat(newUser.getFirstName()).isEqualTo("Tijs"); assertThat(newUser.getDisplayName()).isEqualTo("Tijs Barrez"); assertThat(newUser.getEmail()).isEqualTo("[email protected]"); assertThat(newUser.getPassword()).isEqualTo("updatedpassword"); } finally { // Delete user after test fails if (savedUser != null) { identityService.deleteUser(savedUser.getId()); } } }
Example 20
Source File: FlowableUserDetailsServiceTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@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(); }