Spring Security User
Posted
by DD
on Stack Overflow
See other posts from Stack Overflow
or by DD
Published on 2010-05-15T12:25:15Z
Indexed on
2010/05/15
12:34 UTC
Read the original article
Hit count: 285
spring-security
What is best practise in Spring when creating a new user with custom attributes...to extend org.springframework.security.core.userdetails.User or to create the User in the UserDetailsService (this is the approach taken in the IceFaces tutorial).
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));
}
© Stack Overflow or respective owner