public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending ) { triggerInit(); List<User> userList = new ArrayList<User>(); Iterator<User> it = users.values().iterator(); while ( it.hasNext() ) { User u = it.next(); if ( u.getFullName().indexOf( fullNameKey ) > -1 ) { userList.add( u ); } } Collections.sort( userList, new UserSorter( orderAscending ) ); return userList; }
private int compareUsers( User user, User user1 ) { if ( ORDER_BY_EMAIL.equals( getOrderBy() ) ) { return user.getEmail() == null ? -1 : user1.getEmail() == null ? 1 : user.getEmail().compareTo( user1.getEmail() ); } else if ( ORDER_BY_FULLNAME.equals( getOrderBy() ) ) { return user.getFullName() == null ? -1 : user1.getFullName() == null ? 1 : user.getFullName().compareTo( user1.getFullName() ); } else { return user.getUsername().compareTo( user1.getUsername() ); } } }
/** * Returns true if this user should be considered a match of the current query * * @param user * @return */ public boolean matches( User user ) { if ( getUsername() != null && user.getUsername() != null && user.getUsername().toLowerCase().indexOf( getUsername().toLowerCase() ) == -1 ) { return false; } else if ( getFullName() != null && user.getFullName() != null && user.getFullName().toLowerCase().indexOf( getFullName().toLowerCase() ) == -1 ) { return false; } else if ( getEmail() != null && user.getEmail() != null && user.getEmail().toLowerCase().indexOf( getEmail().toLowerCase() ) == -1 ) { return false; } else { return true; } }
public Attributes getCreationAttributes( User user, boolean encodePasswordIfChanged ) throws MappingException { Attributes userAttrs = new BasicAttributes(); boolean passwordSet = false; if ( !passwordSet && ( user.getEncodedPassword() != null ) ) { userAttrs.put( getPasswordAttribute(), user.getEncodedPassword() ); } if ( !StringUtils.isEmpty( user.getFullName() ) ) { userAttrs.put( getUserFullNameAttribute(), user.getFullName() ); } if ( !StringUtils.isEmpty( user.getEmail() ) ) { userAttrs.put( getEmailAddressAttribute(), user.getEmail() ); } return userAttrs; }
assertNotNull( admin ); assertEquals( user.getEmail(), admin.getEmail() ); assertEquals( user.getFullName(), admin.getFullName() );
private User buildRestUser( org.apache.archiva.redback.users.User user ) { User restUser = new User(); restUser.setEmail( user.getEmail() ); restUser.setUsername( user.getUsername() ); restUser.setPasswordChangeRequired( user.isPasswordChangeRequired() ); restUser.setLocked( user.isLocked() ); restUser.setValidated( user.isValidated() ); restUser.setFullName( user.getFullName() ); return restUser; } }
private SecuritySession createSession( String principal ) throws ArchivaSecurityException, AccessDeniedException { User user; try { user = securitySystem.getUserManager().findUser( principal ); if ( user == null ) { throw new ArchivaSecurityException( "The security system had an internal error - please check your system logs" ); } } catch ( UserNotFoundException e ) { throw new PrincipalNotFoundException( "Unable to find principal " + principal + "", e ); } catch ( UserManagerException e ) { throw new ArchivaSecurityException( e.getMessage(), e ); } if ( user.isLocked() ) { throw new AccessDeniedException( "User " + principal + "(" + user.getFullName() + ") is locked." ); } AuthenticationResult authn = new AuthenticationResult( true, principal, null ); authn.setUser( user ); return new DefaultSecuritySession( authn, user ); }
private SecuritySession createSession( String principal ) throws ArchivaSecurityException, AccessDeniedException { User user; try { user = securitySystem.getUserManager().findUser( principal ); if ( user == null ) { throw new ArchivaSecurityException( "The security system had an internal error - please check your system logs" ); } } catch ( UserNotFoundException e ) { throw new PrincipalNotFoundException( "Unable to find principal " + principal + "", e ); } catch ( UserManagerException e ) { throw new ArchivaSecurityException( e.getMessage(), e ); } if ( user.isLocked() ) { throw new AccessDeniedException( "User " + principal + "(" + user.getFullName() + ") is locked." ); } AuthenticationResult authn = new AuthenticationResult( true, principal, null ); authn.setUser( user ); return new DefaultSecuritySession( authn, user ); }
assertNotNull( user ); assertEquals( "superuser@somedomain.com", user.getEmail() ); assertEquals( "Super User", user.getFullName() ); assertTrue( securityPolicy.getPasswordEncoder().isPasswordValid( user.getEncodedPassword(), "superpass" ) );
assertEquals( "root@somedomain.com", user.getEmail() ); assertEquals( "root", user.getUsername() ); assertEquals( "Root User", user.getFullName() );
public User( org.apache.archiva.redback.users.User user ) { setUsername( user.getUsername() ); this.setEmail( user.getEmail() ); this.setFullName( user.getFullName() ); this.setLocked( user.isLocked() ); this.setPassword( user.getPassword() ); this.setValidated( user.isValidated() ); this.setPasswordChangeRequired( user.isPasswordChangeRequired() ); this.setPermanent( user.isPermanent() ); this.setUserManagerId( user.getUserManagerId() ); setTimestampAccountCreation( DateUtils.formatWithAge( user.getAccountCreationDate(), "ago" ) ); setTimestampLastLogin( DateUtils.formatWithAge( user.getLastLoginDate(), "ago" ) ); setTimestampLastPasswordChange( DateUtils.formatWithAge( user.getLastPasswordChange(), "ago" ) ); }