1
什麼是Spring中創建具有自定義屬性的新用戶的最佳實踐...以擴展org.springframework.security.core.userdetails.User或在UserDetailsService中創建User(這是採取的方法在IceFaces教程中)。Spring Security用戶
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException, DataAccessException {
AppUser user = userDAO.findUser(username);
if (user == null)
throw new UsernameNotFoundException("User not found: " + username);
else {
return makeUser(user);
}
}
private User makeUser(AppUser user) {
return new User(user.getLogin(), user
.getPassword(), true, true, true, true,
makeGrantedAuthorities(user));
}