private List<String> admins = new ArrayList<String>();
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserInfo userInfo = repository.getByUsername(username);
if (userInfo != null) {
// TODO: make passwords configurable? part of object?
String password = "password";
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
authorities.add(ROLE_USER);
if (admins != null && admins.contains(username)) {
authorities.add(ROLE_ADMIN);
}
// TODO: this should really be our own UserDetails wrapper class, shouldn't it?
User user = new User(userInfo.getSub(), password, authorities);
return user;
} else {
throw new UsernameNotFoundException("Could not find username: " + username);
}
}