Examples of DefaultUser


Examples of org.sonatype.security.usermanagement.DefaultUser

  protected User toUser(CUser cUser) {
    if (cUser == null) {
      return null;
    }

    DefaultUser user = new DefaultUser();

    user.setUserId(cUser.getId());
    user.setFirstName(cUser.getFirstName());
    user.setLastName(cUser.getLastName());
    user.setEmailAddress(cUser.getEmail());
    user.setSource(SOURCE);
    user.setStatus(UserStatus.valueOf(cUser.getStatus()));

    try {
      user.setRoles(this.getUsersRoles(cUser.getId(), SOURCE));
    }
    catch (UserNotFoundException e) {
      // We should NEVER get here
      this.log.warn("Could not find user: '" + cUser.getId() + "' of source: '" + SOURCE
          + "' while looking up the users roles.", e);
View Full Code Here

Examples of org.sonatype.security.usermanagement.DefaultUser

  public void testAddUser()
      throws Exception
  {
    UserManager userManager = this.getUserManager();

    User user = new DefaultUser();
    user.setUserId("testCreateUser");
    user.setName(user.getUserId() + "-name");
    user.setSource(user.getUserId() + "default");
    user.setEmailAddress("email@email");
    user.setStatus(UserStatus.active);
    user.addRole(new RoleIdentifier("default", "role1"));
    user.addRole(new RoleIdentifier("default", "role3"));

    userManager.addUser(user, "my-password");

    ConfigurationManager config = this.getConfigurationManager();

    CUser secUser = config.readUser(user.getUserId());
    Assert.assertEquals(secUser.getId(), user.getUserId());
    Assert.assertEquals(secUser.getEmail(), user.getEmailAddress());
    Assert.assertEquals(secUser.getFirstName(), user.getFirstName());
    Assert.assertEquals(secUser.getLastName(), user.getLastName());
    assertThat(this.passwordService.passwordsMatch("my-password", secUser.getPassword()), is(true));

    Assert.assertEquals(secUser.getStatus(), user.getStatus().name());

    CUserRoleMapping roleMapping = config.readUserRoleMapping("testCreateUser", "default");

    Assert.assertTrue(roleMapping.getRoles().contains("role1"));
    Assert.assertTrue(roleMapping.getRoles().contains("role3"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.