Skip to content

Instantly share code, notes, and snippets.

@chbatey
Created February 23, 2015 17:20
Show Gist options
  • Save chbatey/e288d7431dc1a2f84ebb to your computer and use it in GitHub Desktop.
Save chbatey/e288d7431dc1a2f84ebb to your computer and use it in GitHub Desktop.
Example UserDetailsService
@Component
public class CassandraUserDetailsService implements UserDetailsService {
private AuctionUserDao auctionUserDao;
@Inject
public CassandraUserDetailsService(AuctionUserDao auctionUserDao) {
this.auctionUserDao = auctionUserDao;
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
AuctionUser user = auctionUserDao.retrieveUser(username).orElseThrow(() -> new UsernameNotFoundException(username));
return new UserWithSalt(user.getUserName(), user.getSalt(), user.getMd5Password(), Sets.newHashSet(new SimpleGrantedAuthority("ROLE_USER")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment