Package org.sonatype.security.usermanagement

Examples of org.sonatype.security.usermanagement.User


    String roleId = "empty-role";

    RoleIdentifier emptyRole = new RoleIdentifier("default", roleId);

    UserManager userManager = this.getUserManager();
    User user = userManager.getUser(userId);

    assertEquals(3, user.getRoles().size());
    assertTrue(user.getRoles().contains(emptyRole));

    user.removeRole(emptyRole);

    assertEquals(2, user.getRoles().size());
    assertFalse(user.getRoles().contains(emptyRole));

    userManager.updateUser(user);

    Configuration securityModel = this.getSecurityConfiguration();
    for (CUserRoleMapping userRoleMapping : securityModel.getUserRoleMappings()) {
View Full Code Here


      throws Exception
  {
    String userId = "test-user-with-empty-role";

    UserManager userManager = this.getUserManager();
    User user = userManager.getUser(userId);

    String value = "value";
    user.setEmailAddress(String.format("%s@%s", value, value));
    user.setFirstName(value);
    user.setLastName(value);

    userManager.updateUser(user);

    Configuration securityModel = this.getSecurityConfiguration();

    boolean found = false;
    for (CUser tmpUser : securityModel.getUsers()) {
      if (userId.equals(tmpUser.getId())) {
        assertEquals(String.format("%s@%s", value, value), user.getEmailAddress());
        assertEquals(value, user.getFirstName());
        assertEquals(value, user.getLastName());
        found = true;
      }
    }
    assertTrue("user not found", found);
View Full Code Here

    String roleId = "role1";

    RoleIdentifier emptyRole = new RoleIdentifier("default", roleId);

    UserManager userManager = this.getUserManager();
    User user = userManager.getUser(userId);

    assertEquals(3, user.getRoles().size());
    assertTrue(user.getRoles().contains(emptyRole));

    user.removeRole(emptyRole);

    assertEquals(2, user.getRoles().size());
    assertFalse(user.getRoles().contains(emptyRole));

    userManager.updateUser(user);

    Configuration securityModel = this.getSecurityConfiguration();
    for (CUserRoleMapping userRoleMapping : securityModel.getUserRoleMappings()) {
View Full Code Here

  public void testGetUser()
      throws Exception
  {
    SecuritySystem securitySystem = this.getSecuritySystem();
    User jcoder = securitySystem.getUser("jcoder", "MockUserManagerA");

    Assert.assertNotNull(jcoder);

  }
View Full Code Here

  public void testAddUser()
      throws Exception
  {
    SecuritySystem securitySystem = this.getSecuritySystem();

    User user = new DefaultUser();
    user.setEmailAddress("email@foo.com");
    user.setName("testAddUser");
    user.setSource("MockUserManagerA");
    user.setStatus(UserStatus.active);
    user.setUserId("testAddUser");

    user.addRole(new RoleIdentifier("default", "test-role1"));

    Assert.assertNotNull(securitySystem.addUser(user));
  }
View Full Code Here

  }

  public User getUser(String userId)
      throws UserNotFoundException
  {
    User user = toUser(configuration.readUser(userId));
    return user;
  }
View Full Code Here

          for (CUserRoleMapping roleMapping : roleMappings) {
            if (!SOURCE.equals(roleMapping.getSource())) {
              if (matchesCriteria(roleMapping.getUserId(), roleMapping.getSource(), roleMapping.getRoles(),
                  criteria)) {
                try {
                  User user = getSecuritySystem().getUser(roleMapping.getUserId(), roleMapping.getSource());
                  users.add(user);
                }
                catch (UserNotFoundException e) {
                  log.debug("User: '" + roleMapping.getUserId() + "' of source: '"
                      + roleMapping.getSource() + "' could not be found.", e);
View Full Code Here

    Set<User> users = new HashSet<User>();

    List<CUserRoleMapping> userRoleMappings = this.configuration.listUserRoleMappings();
    for (CUserRoleMapping userRoleMapping : userRoleMappings) {
      try {
        User user = this.getSecuritySystem().getUser(userRoleMapping.getUserId(), userRoleMapping.getSource());
        if (user != null) {
          users.add(user);
        }
      }
      catch (UserNotFoundException e) {
View Full Code Here

    List<String> realmHints = new ArrayList<String>();
    realmHints.add("MockRealmA");
    realmHints.add("MockRealmB");
    securitySystem.setRealms(realmHints);

    User jcoder = securitySystem.getUser("jcoder");
    Assert.assertNotNull(jcoder);

    // make sure jcoder is from MockUserManagerA
    Assert.assertEquals("MockUserManagerA", jcoder.getSource());

    // now change the order
    realmHints.clear();
    realmHints.add("MockRealmB");
    realmHints.add("MockRealmA");
    securitySystem.setRealms(realmHints);

    jcoder = securitySystem.getUser("jcoder");
    Assert.assertNotNull(jcoder);

    // make sure jcoder is from MockUserManagerA
    Assert.assertEquals("MockUserManagerB", jcoder.getSource());

  }
View Full Code Here

    // now something will be in the cache, just make sure
    Assert.assertFalse(mockRealmB.getAuthorizationCache().keys().isEmpty());

    // now if we update a user the cache should be cleared
    User user = securitySystem.getUser("bburton", "MockUserManagerB"); // different user, doesn't matter, in the
    // future we should get a little more fine
    // grained
    securitySystem.updateUser(user);

    // empty again
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.