Package org.sonatype.security.usermanagement

Examples of org.sonatype.security.usermanagement.User


    return this.filterListInMemeory(this.listUsers(), criteria);
  }

  private User toUser(SimpleUser simpleUser) {
    // simple conversion of object
    User user = new DefaultUser();
    user.setEmailAddress(simpleUser.getEmail());
    user.setName(simpleUser.getName());
    user.setUserId(simpleUser.getUserId());
    user.setStatus(UserStatus.active);
    for (String role : simpleUser.getRoles()) {
      RoleIdentifier plexusRole = new RoleIdentifier(this.getSource(), role);
      user.addRole(plexusRole);
    }
    // set the source of this user to this
    user.setSource(this.getSource());

    return user;
  }
View Full Code Here


    assertThat(auinfo, nullValue());
  }

  @Test
  public void multipleRealms() throws Exception {
    final User redUser = mock(User.class);
    when(redUser.getUserId()).thenReturn("joe");
    final User blueUser = mock(User.class);
    when(blueUser.getUserId()).thenReturn("joe");
    when(redUserManager.getUser("joe")).thenReturn(redUser);
    when(blueUserManager.getUser("joe")).thenReturn(blueUser);

    final AuthenticationInfo auinfo = testSubject.getAuthenticationInfo(new RutAuthAuthenticationToken("Some-Header",
        "joe", "localhost"));
View Full Code Here

    assertThat(auinfo.getPrincipals().getRealmNames(), hasItems("RED", "BLUE"));
  }

  @Test
  public void onlyInOne() throws Exception {
    final User redUser = mock(User.class);
    when(redUser.getUserId()).thenReturn("joe");
    when(redUserManager.getUser("joe")).thenReturn(redUser);
    when(blueUserManager.getUser("joe")).thenThrow(UserNotFoundException.class);

    final AuthenticationInfo auinfo = testSubject.getAuthenticationInfo(new RutAuthAuthenticationToken("Some-Header",
        "joe", "localhost"));
View Full Code Here

    return dto;
  }

  protected User restToNexusModel(UserAccount dto) {
    User user = new DefaultUser();

    user.setUserId(dto.getUserId());

    user.setFirstName(dto.getFirstName());
    user.setLastName(dto.getLastName());

    user.setEmailAddress(dto.getEmail());

    user.setSource(DEFAULT_SOURCE);

    user.setStatus(UserStatus.active);

    return user;
  }
View Full Code Here

        Role role = authzManager.getRole(userId);

        handleRole(role, authzManager, responseResource, null);
      }
      else {
        User user = getSecuritySystem().getUser(userId);

        handleUser(user, authzManager, responseResource);
      }

      return responseResource;
View Full Code Here

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

    User user;
    try {
      // TODO: remove the "all" we either need to move it down into the SecuritySystem, or remove it, i vote
      // remove it.
      String source = getUserSource(request);
View Full Code Here

        }
      }

      if (!StringUtils.isEmpty(filterRequest.getData().getUserId())) {
        try {
          User user = getSecuritySystem().getUser(filterRequest.getData().getUserId());

          List<PlexusRoleResource> plexusRoles = securityToRestModel(user).getRoles();

          for (PlexusRoleResource plexusRole : plexusRoles) {
            if (!DEFAULT_SOURCE.equals(plexusRole.getSource())) {
View Full Code Here

            this.getErrorResponse("*",
                "Updating a users password using this URI is not allowed."));
      }

      try {
        User user = restToSecurityModel(getSecuritySystem().getUser(resource.getUserId()), resource);

        validateUserContainment(user);

        getSecuritySystem().updateUser(user);

View Full Code Here

    // i.e. like the 'Change Password' link.
    String username = perms.getLoggedInUsername();
    if (StringUtils.isNotEmpty(username)) {
      // look up the realm of the user
      try {
        User user = this.getSecuritySystem().getUser(username);
        String source = (user != null) ? user.getSource() : null;
        perms.setLoggedInUserSource(source);
      }
      catch (UserNotFoundException e) {
        if (getLogger().isDebugEnabled()) {
          getLogger().info("Failed to lookup user: {}", username, e);
View Full Code Here

    String userId = getUserId(request);

    try {
      AssignedPrivilegeListResourceResponse responseResource = new AssignedPrivilegeListResourceResponse();

      User user = this.getSecuritySystem().getUser(userId);

      AuthorizationManager authzManager = getSecuritySystem().getAuthorizationManager("default");

      for (RoleIdentifier roleIdentifier : user.getRoles()) {
        try {
          handleRole(authzManager.getRole(roleIdentifier.getRoleId()), null, authzManager,
              responseResource);
        }
        catch (NoSuchRoleException e) {
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.