Package org.sonatype.security.usermanagement

Examples of org.sonatype.security.usermanagement.UserSearchCriteria


    Set<User> users = null;
    if ("all".equalsIgnoreCase(source)) {
      users = this.getSecuritySystem().listUsers();
    }
    else {
      users = this.getSecuritySystem().searchUsers(new UserSearchCriteria(null, null, source));
    }

    result.setData(this.securityToRestModel(users));

    return result;
View Full Code Here


  @GET
  public PlexusUserListResourceResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {

    UserSearchCriteria criteria = new UserSearchCriteria();
    criteria.setUserId(this.getSearchArg(request));
    criteria.setSource(this.getUserSource(request));

    return this.search(criteria);
  }
View Full Code Here

  public UserListResourceResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    UserListResourceResponse result = new UserListResourceResponse();

    for (User user : getSecuritySystem().searchUsers(new UserSearchCriteria(null, null, DEFAULT_SOURCE))) {
      UserResource res = securityToRestModel(user, request, true);

      if (res != null) {
        result.addData(res);
      }
View Full Code Here

      throws ResourceException
  {
    PlexusUserSearchCriteriaResource criteriaResource =
        ((PlexusUserSearchCriteriaResourceRequest) payload).getData();

    UserSearchCriteria criteria = this.toPlexusSearchCriteria(criteriaResource);
    criteria.setSource(this.getUserSource(request));

    return this.search(criteria);
  }
View Full Code Here

    return this.search(criteria);
  }

  private UserSearchCriteria toPlexusSearchCriteria(PlexusUserSearchCriteriaResource criteriaResource) {
    UserSearchCriteria criteria = new UserSearchCriteria();
    criteria.setUserId(criteriaResource.getUserId());

    // NOTE: in the future we could expand the REST resource to send back a list of roles, (or a single role)
    // to get a list of all users of Role 'XYZ'
    if (criteriaResource.isEffectiveUsers()) {
      Set<String> roleIds = new HashSet<String>();

      Set<Role> roles = null;
      try {
        roles = this.getSecuritySystem().listRoles("default");
      }
      catch (NoSuchAuthorizationManagerException e) {
        this.getLogger().error("Cannot find default UserManager,  effective user search may not work properly.",
            e);
        roles = this.getSecuritySystem().listRoles();
      }

      for (Role role : roles) {
        roleIds.add(role.getRoleId());
      }

      criteria.setOneOfRoleIds(roleIds);
    }

    return criteria;
  }
View Full Code Here

  @Override
  @GET
  public PlexusUserListResourceResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    UserSearchCriteria criteria = new UserSearchCriteria();

    // match all userIds
    criteria.setUserId("");
    criteria.setSource(this.getUserSource(request));

    return this.search(criteria);
  }
View Full Code Here

  @Test
  public void testSearch()
      throws Exception
  {
    UserManager userLocator = this.getUserManager();
    Set<User> users = userLocator.searchUsers(new UserSearchCriteria("j"));

    assertNotNull(this.getById(users, "jvanzyl"));
    assertNotNull(this.getById(users, "jdcasey"));
    Assert.assertEquals("Users: " + users, 2, users.size());
  }
View Full Code Here

    Set<String> allRoleIds = new HashSet<String>();
    for (Role role : this.getSecuritySystem().listRoles()) {
      allRoleIds.add(role.getRoleId());
    }

    UserSearchCriteria criteria = new UserSearchCriteria("j", allRoleIds, null);

    Set<User> users = userLocator.searchUsers(criteria);

    assertNotNull(this.getById(users, "jvanzyl"));
    Assert.assertEquals("Users: " + users, 1, users.size());
View Full Code Here

  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

  }

  public void forgotPassword(String userId, String email)
      throws UserNotFoundException, InvalidConfigurationException
  {
    UserSearchCriteria criteria = new UserSearchCriteria();
    criteria.setEmail(email);
    criteria.setUserId(userId);

    Set<User> users = this.searchUsers(criteria);

    boolean found = false;
View Full Code Here

TOP

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

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.