@Test public void adoptUser_with_role_owner() { AuthUser entity = createAuthUser(); entity.setRoleOwner(true); entity.setRoleUser(false); entity.setRoleSuperAdmin(false); UserDetails result = AuthUserRestAPIConfiguration.adoptUser(entity); assertHasAuthority(result, RoleConstants.ROLE_OWNER); }
static UserDetails adoptUser(AuthUser entity) { UserBuilder builder = User.builder(); builder.username(entity.getUserId()); String hashedApiToken = entity.getHashedApiToken(); builder.password(hashedApiToken); List<String> authorities = accumulateAuthorities(entity); builder.authorities(authorities.toArray(new String[authorities.size()])); boolean disabled = hashedApiToken==null || hashedApiToken.isEmpty(); builder.disabled(disabled); UserDetails details = builder.build(); LOG.trace("User:{} has authorities: {}, entity:{}",entity.getUserId(), details.getAuthorities(),entity); return details; }
AuthUserRestAPIConfiguration { static UserDetails adoptUser(AuthUser entity) { UserBuilder builder = User.builder(); builder.username(entity.getUserId()); String hashedApiToken = entity.getHashedApiToken(); builder.password(hashedApiToken); List<String> authorities = accumulateAuthorities(entity); builder.authorities(authorities.toArray(new String[authorities.size()])); boolean disabled = hashedApiToken==null || hashedApiToken.isEmpty(); builder.disabled(disabled); UserDetails details = builder.build(); LOG.trace("User:{} has authorities: {}, entity:{}",entity.getUserId(), details.getAuthorities(),entity); return details; } }
AuthUserRestAPIConfiguration { static UserDetails adoptUser(AuthUser entity) { UserBuilder builder = User.builder(); builder.username(entity.getUserId()); String hashedApiToken = entity.getHashedApiToken(); builder.password(hashedApiToken); List<String> authorities = accumulateAuthorities(entity); builder.authorities(authorities.toArray(new String[authorities.size()])); boolean disabled = hashedApiToken==null || hashedApiToken.isEmpty(); builder.disabled(disabled); UserDetails details = builder.build(); LOG.trace("User:{} has authorities: {}, entity:{}",entity.getUserId(), details.getAuthorities(),entity); return details; }  }
AuthUserRestAPIConfiguration { static UserDetails adoptUser(AuthUser entity) { UserBuilder builder = User.builder(); builder.username(entity.getUserId()); String hashedApiToken = entity.getHashedApiToken(); builder.password(hashedApiToken); List<String> authorities = accumulateAuthorities(entity); builder.authorities(authorities.toArray(new String[authorities.size()])); boolean disabled = hashedApiToken==null || hashedApiToken.isEmpty(); builder.disabled(disabled); UserDetails details = builder.build(); LOG.trace("User:{} has authorities: {}, entity:{}",entity.getUserId(), details.getAuthorities(),entity); return details; }  @Bean UserDetailsService userDetailsService(final AuthUserRepository repository); }
AuthUserRestAPIConfiguration { static UserDetails adoptUser(AuthUser entity) { UserBuilder builder = User.builder(); builder.username(entity.getUserId()); String hashedApiToken = entity.getHashedApiToken(); builder.password(hashedApiToken); List<String> authorities = accumulateAuthorities(entity); builder.authorities(authorities.toArray(new String[authorities.size()])); boolean disabled = hashedApiToken==null || hashedApiToken.isEmpty(); builder.disabled(disabled); UserDetails details = builder.build(); LOG.trace("User:{} has authorities: {}, entity:{}",entity.getUserId(), details.getAuthorities(),entity); return details; }  @Bean UserDetailsService userDetailsService(final AuthUserRepository repository);  }