Package org.sonatype.security.usermanagement

Examples of org.sonatype.security.usermanagement.UserManager


  }

  public void testSearchUser()
      throws Exception
  {
    UserManager userLocator = this.getUserManager();

    Set<User> users = userLocator.searchUsers(new UserSearchCriteria("test"));
    Map<String, User> userMap = this.toUserMap(users);

    Assert.assertTrue(userMap.containsKey("test-user"));
    Assert.assertTrue(userMap.containsKey("test-user-with-empty-role"));
View Full Code Here


      password = this.generatePassword();
    }

    // first save the user
    // this is the UserManager that owns the user
    UserManager userManager = userManagerFacade.getUserManager(user.getSource());

    if (!userManager.supportsWrite()) {
      throw new InvalidConfigurationException("UserManager: " + userManager.getSource()
          + " does not support writing.");
    }

    userManager.addUser(user, password);

    // then save the users Roles
    for (UserManager tmpUserManager : userManagerFacade.getUserManagers().values()) {
      // skip the user manager that owns the user, we already did that
      // these user managers will only save roles
View Full Code Here

  public User updateUser(User user)
      throws UserNotFoundException, NoSuchUserManagerException, InvalidConfigurationException
  {
    // first update the user
    // this is the UserManager that owns the user
    UserManager userManager = userManagerFacade.getUserManager(user.getSource());

    if (!userManager.supportsWrite()) {
      throw new InvalidConfigurationException("UserManager: " + userManager.getSource()
          + " does not support writing.");
    }

    final User oldUser = userManager.getUser(user.getUserId());
    userManager.updateUser(user);
    if (oldUser.getStatus() == UserStatus.active && user.getStatus() != oldUser.getStatus()) {
      // clear the realm authc caches as user got disabled
      eventBus.post(new UserPrincipalsExpired(user.getUserId(), user.getSource()));
    }
View Full Code Here

              + "To delete this user, disable anonymous access or, "
              + "change the anonymous username and password to another valid values!"
      );
    }

    UserManager userManager = userManagerFacade.getUserManager(source);
    userManager.deleteUser(userId);

    // flush authc
    eventBus.post(new UserPrincipalsExpired(userId, source));
  }
View Full Code Here

  public User getUser(String userId, String source)
      throws UserNotFoundException, NoSuchUserManagerException
  {
    // first get the user
    // this is the UserManager that owns the user
    UserManager userManager = userManagerFacade.getUserManager(source);
    User user = userManager.getUser(userId);

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

    Collection<Realm> realms = this.getSecurityManager().getRealms();

    for (Realm realm : realms) {
      // now user the realm.name to find the UserManager
      if (realmToUserManagerMap.containsKey(realm.getName())) {
        UserManager userManager = realmToUserManagerMap.get(realm.getName());
        // remove from unorderd and add to orderd
        unOrderdLocators.remove(userManager);
        orderedLocators.add(userManager);
      }
    }
View Full Code Here

      throws UserNotFoundException, InvalidConfigurationException
  {
    User user = this.getUser(userId);

    try {
      UserManager userManager = userManagerFacade.getUserManager(user.getSource());
      userManager.changePassword(userId, newPassword);
    }
    catch (NoSuchUserManagerException e) {
      // this should NEVER happen
      this.logger.warn("User '" + userId + "' with source: '" + user.getSource()
          + "' but could not find the UserManager for that source.");
View Full Code Here

      throws NoSuchUserManagerException, AuthenticationException
  {
    final Subject subject = login("test-user", "deployment123");
    try {
      final PrincipalCollection principals = subject.getPrincipals();
      final UserManager userManager = helper().findUserManager(principals);

      assertThat(principals.getPrimaryPrincipal().toString(), isIn(userManager.listUserIds()));
      assertThat(userManager.getAuthenticationRealmName(), isIn(principals.getRealmNames()));
    }
    finally {
      subject.logout();
    }
  }
View Full Code Here

    securitySystem.setRealms(realms);

    final Subject subject = login("tempUser", "tempPass");
    try {
      final PrincipalCollection principals = subject.getPrincipals();
      final UserManager userManager = helper().findUserManager(principals);

      assertThat(principals.getPrimaryPrincipal().toString(), isIn(userManager.listUserIds()));
      assertThat(userManager.getAuthenticationRealmName(), isIn(principals.getRealmNames()));
    }
    finally {
      subject.logout();
    }
  }
View Full Code Here

  }

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

    User user = userManager.getUser("test-user");

    Assert.assertEquals(user.getUserId(), "test-user");
    Assert.assertEquals(user.getEmailAddress(), "changeme1@yourcompany.com");
    Assert.assertEquals(user.getName(), "Test User");
    // not exposed anymore
View Full Code Here

TOP

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

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.