Created
February 23, 2015 17:20
-
-
Save chbatey/e288d7431dc1a2f84ebb to your computer and use it in GitHub Desktop.
Example UserDetailsService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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