Java Code Examples for org.camunda.bpm.engine.identity.User#setLastName()

The following examples show how to use org.camunda.bpm.engine.identity.User#setLastName() . 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: IdentityServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateUser() {
  // First, create a new user
  User user = identityService.newUser("johndoe");
  user.setFirstName("John");
  user.setLastName("Doe");
  user.setEmail("[email protected]");
  user.setPassword("s3cret");
  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());
  assertTrue(identityService.checkPassword("johndoe", "s3cret"));

  identityService.deleteUser(user.getId());
}
 
Example 2
Source File: IdentityServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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();
  assertEquals("johndoe", user.getId());
  assertEquals("John", user.getFirstName());
  assertEquals("Doe", user.getLastName());
  assertEquals("[email protected]", user.getEmail());

  identityService.deleteUser("johndoe");
}
 
Example 3
Source File: DefaultUserLifecycleBean.java    From Showcase with Apache License 2.0 5 votes vote down vote up
private User createDefaultUser(String username, String password) {
    User user = identityService.newUser(username);
    user.setPassword(password);
    user.setFirstName("Educama");
    user.setLastName("User");
    identityService.saveUser(user);

    return user;
}
 
Example 4
Source File: UserQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private User createUser(String id, String firstName, String lastName, String email) {
  User user = identityService.newUser(id);
  user.setFirstName(firstName);
  user.setLastName(lastName);
  user.setEmail(email);
  identityService.saveUser(user);
  return user;
}
 
Example 5
Source File: DefaultPasswordPolicyTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldUpdateUserDetailsWithoutPolicyCheck() {
  // given
  // first, create a new user
  User user = identityService.newUser("johndoe");
  user.setFirstName("John");
  user.setLastName("Doe");
  user.setEmail("[email protected]");
  user.setPassword("Passw0rds!");
  identityService.saveUser(user);

  // when
  // fetch and update the user
  user = identityService.createUserQuery().userId("johndoe").singleResult();
  user.setEmail("[email protected]");
  user.setFirstName("Jane");
  user.setLastName("Donnel");
  identityService.saveUser(user);

  // then
  user = identityService.createUserQuery().userId("johndoe").singleResult();
  assertThat(user.getFirstName(), is("Jane"));
  assertThat(user.getLastName(), is("Donnel"));
  assertThat(user.getEmail(), is("[email protected]"));
  assertThat(identityService.checkPassword("johndoe", "Passw0rds!"), is(true));

  identityService.deleteUser(user.getId());
}
 
Example 6
Source File: Application.java    From camunda-spring-boot-amqp-microservice-cloud-example with Apache License 2.0 4 votes vote down vote up
public static void createDefaultUser(ProcessEngine engine) {
  // and add default user to Camunda to be ready-to-go
  if (engine.getIdentityService().createUserQuery().userId("demo").count() == 0) {
    User user = engine.getIdentityService().newUser("demo");
    user.setFirstName("Demo");
    user.setLastName("Demo");
    user.setPassword("demo");
    user.setEmail("[email protected]");
    engine.getIdentityService().saveUser(user);

    Group group = engine.getIdentityService().newGroup(Groups.CAMUNDA_ADMIN);
    group.setName("Administrators");
    group.setType(Groups.GROUP_TYPE_SYSTEM);
    engine.getIdentityService().saveGroup(group);

    for (Resource resource : Resources.values()) {
      Authorization auth = engine.getAuthorizationService().createNewAuthorization(AUTH_TYPE_GRANT);
      auth.setGroupId(Groups.CAMUNDA_ADMIN);
      auth.addPermission(ALL);
      auth.setResourceId(ANY);
      auth.setResource(resource);
      engine.getAuthorizationService().saveAuthorization(auth);
    }

    engine.getIdentityService().createMembership("demo", Groups.CAMUNDA_ADMIN);
  }

  // create default "all tasks" filter
  if (engine.getFilterService().createFilterQuery().filterName("Alle").count() == 0) {

    Map<String, Object> filterProperties = new HashMap<String, Object>();
    filterProperties.put("description", "Alle Aufgaben");
    filterProperties.put("priority", 10);

    Filter filter = engine.getFilterService().newTaskFilter() //
        .setName("Alle") //
        .setProperties(filterProperties)//
        .setOwner("demo")//
        .setQuery(engine.getTaskService().createTaskQuery());
    engine.getFilterService().saveFilter(filter);

    // and authorize demo user for it
    if (engine.getAuthorizationService().createAuthorizationQuery().resourceType(FILTER).resourceId(filter.getId()) //
        .userIdIn("demo").count() == 0) {
      Authorization managementGroupFilterRead = engine.getAuthorizationService().createNewAuthorization(Authorization.AUTH_TYPE_GRANT);
      managementGroupFilterRead.setResource(FILTER);
      managementGroupFilterRead.setResourceId(filter.getId());
      managementGroupFilterRead.addPermission(ALL);
      managementGroupFilterRead.setUserId("demo");
      engine.getAuthorizationService().saveAuthorization(managementGroupFilterRead);
    }

  }
}
 
Example 7
Source File: UserProfileDto.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void update(User dbUser) {  
  dbUser.setId(getId());
  dbUser.setFirstName(getFirstName());
  dbUser.setLastName(getLastName());
  dbUser.setEmail(getEmail());
}