Package org.sonatype.security.usermanagement

Examples of org.sonatype.security.usermanagement.User


  @Test
  public void testGetUserFromLocator()
      throws Exception
  {
    UserManager userLocator = this.getUserManager();
    User user = userLocator.getUser("cstamas");
    assertNotNull(user);
    Assert.assertEquals("cstamas", user.getUserId());
    Assert.assertEquals("cstamas@sonatype.com", user.getEmailAddress());
    Assert.assertEquals("Tamas Cservenak", user.getName());
  }
View Full Code Here


      throws Exception
  {
    UserManager userLocator = this.getUserManager();
    Set<User> users = userLocator.listUsers();

    User cstamas = this.getById(users, "cstamas");
    Assert.assertEquals("cstamas", cstamas.getUserId());
    Assert.assertEquals("cstamas@sonatype.com", cstamas.getEmailAddress());
    Assert.assertEquals("Tamas Cservenak", cstamas.getName());

    User brianf = this.getById(users, "brianf");
    Assert.assertEquals("brianf", brianf.getUserId());
    Assert.assertEquals("brianf@sonatype.com", brianf.getEmailAddress());
    Assert.assertEquals("Brian Fox", brianf.getName());

    User jvanzyl = this.getById(users, "jvanzyl");
    Assert.assertEquals("jvanzyl", jvanzyl.getUserId());
    Assert.assertEquals("jvanzyl@sonatype.com", jvanzyl.getEmailAddress());
    Assert.assertEquals("Jason Van Zyl", jvanzyl.getName());

    User jdcasey = this.getById(users, "jdcasey");
    Assert.assertEquals("jdcasey", jdcasey.getUserId());
    Assert.assertEquals("jdcasey@sonatype.com", jdcasey.getEmailAddress());
    Assert.assertEquals("John Casey", jdcasey.getName());

    Assert.assertEquals("Ids: " + users, 4, users.size());
  }
View Full Code Here

    realms.add(LdapPlugin.REALM_NAME);

    securitySystem.setRealms(realms);

    // the user developer is in both realms, we need to make sure the order is honored
    User user = securitySystem.getUser("brianf");
    Assert.assertEquals("default", user.getSource());

    realms.clear();
    realms.add(LdapPlugin.REALM_NAME);
    realms.add("XmlAuthenticatingRealm");
    securitySystem.setRealms(realms);

    // now the user should belong to the LDAP realm

    user = securitySystem.getUser("brianf");
    Assert.assertEquals("LDAP", user.getSource());

  }
View Full Code Here

    final SimplePrincipalCollection principals = new SimplePrincipalCollection();
    final List<String> configuredRealms = securitySystem.getRealms();
    for (UserManager userManager : userManagers) {
      if (configuredRealms.contains(userManager.getAuthenticationRealmName())) {
        try {
          final User user = userManager.getUser(rutUserId);
          principals.add(user.getUserId(), userManager.getAuthenticationRealmName());
        }
        catch (UserNotFoundException e) {
          // ignore and continue searching
        }
      }
View Full Code Here

  {
    String userId = null;
    if (principals != null) {
      userId = principals.getPrimaryPrincipal().toString();
      try {
        final User user = findUserManager(principals).getUser(userId);
        if (user != null) {
          return user.getStatus();
        }
      }
      catch (final NoSuchUserManagerException e) {
        throw new UserNotFoundException(userId, e.getMessage(), e);
      }
View Full Code Here

  public void testGetUser()
      throws Exception
  {
    UserManager userLocator = this.getUserManager();
    User testUser = userLocator.getUser("test-user");

    Assert.assertEquals("Test User", testUser.getName());
    Assert.assertEquals("test-user", testUser.getUserId());
    Assert.assertEquals("changeme1@yourcompany.com", testUser.getEmailAddress());

    // test roles
    Map<String, RoleIdentifier> roleMap = this.toRoleMap(testUser.getRoles());

    Assert.assertTrue(roleMap.containsKey("role1"));
    Assert.assertTrue(roleMap.containsKey("role2"));
    Assert.assertEquals(2, roleMap.size());
  }
View Full Code Here

  public void testGetUserWithEmptyRole()
      throws Exception
  {
    UserManager userLocator = this.getUserManager();
    User testUser = userLocator.getUser("test-user-with-empty-role");

    Assert.assertEquals("Test User With Empty Role", testUser.getName());
    Assert.assertEquals("test-user-with-empty-role", testUser.getUserId());
    Assert.assertEquals("empty-role@yourcompany.com", testUser.getEmailAddress());

    // test roles
    Map<String, RoleIdentifier> roleMap = this.toRoleMap(testUser.getRoles());

    Assert.assertTrue(roleMap.containsKey("empty-role"));
    Assert.assertTrue(roleMap.containsKey("role1"));
    Assert.assertTrue(roleMap.containsKey("role2"));
    Assert.assertEquals(3, roleMap.size());
View Full Code Here

  public void testInvalidRoleMapping()
      throws Exception
  {
    SecuritySystem userManager = this.getSecuritySystem();

    User user = userManager.getUser("jcoder");
    Assert.assertNotNull(user);

    Set<String> roleIds = new HashSet<String>();
    for (RoleIdentifier role : user.getRoles()) {
      Assert.assertNotNull("User has null role.", role);
      roleIds.add(role.getRoleId());
    }
    Assert.assertFalse(roleIds.contains("INVALID-ROLE-BLA-BLA"));
  }
View Full Code Here

  }

  public User updateUser(User user)
      throws UserNotFoundException
  {
    User existingUser = this.getUser(user.getUserId());

    if (existingUser == null) {
      throw new UserNotFoundException(user.getUserId());
    }
View Full Code Here

  }

  public void deleteUser(String userId)
      throws UserNotFoundException
  {
    User existingUser = this.getUser(userId);

    if (existingUser == null) {
      throw new UserNotFoundException(userId);
    }
View Full Code Here

TOP

Related Classes of org.sonatype.security.usermanagement.User

Copyright © 2018 www.massapicom. 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.