@Test public void testLoadUserByUsername() throws Exception { UserDetails userDetails = userDetailsService.loadUserByUsername(ADMIN); assertNotNull(userDetails); assertEquals(ADMIN, userDetails.getUsername()); assertFalse(userDetails.getAuthorities().isEmpty()); assertEquals(ADMIN, userDetails.getAuthorities().iterator().next().getAuthority()); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user != null) { return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), mapRoles(user)); } throw new UsernameNotFoundException(String.format("Username '%s' not found", username)); }
UserDetailsServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user != null) { return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), mapRoles(user)); } throw new UsernameNotFoundException(String.format("Username '%s' not found", username)); } }
UserDetailsServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user != null) { return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), mapRoles(user)); } throw new UsernameNotFoundException(String.format("Username '%s' not found", username)); } @Autowired  UserDetailsServiceImpl(UserRepository userRepository); }
UserDetailsServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user != null) { return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), mapRoles(user)); } throw new UsernameNotFoundException(String.format("Username '%s' not found", username)); } @Autowired  UserDetailsServiceImpl(UserRepository userRepository); @Override UserDetails loadUserByUsername(String username); }
UserDetailsServiceImpl implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user != null) { return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), mapRoles(user)); } throw new UsernameNotFoundException(String.format("Username '%s' not found", username)); } @Autowired  UserDetailsServiceImpl(UserRepository userRepository); @Override UserDetails loadUserByUsername(String username);  }