Created
August 13, 2012 12:16
-
-
Save mh-github/3340095 to your computer and use it in GitHub Desktop.
This file contains 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
@Service | |
public class UserServiceImpl implements UserDetailsService { | |
@Autowired | |
private UserDao userDao; | |
@Autowired | |
private RoleDao roleDao; | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.springframework.security.core.userdetails.UserDetailsService# | |
* loadUserByUsername(java.lang.String) | |
*/ | |
@Transactional | |
public UserDetails loadUserByUsername(String userName) | |
throws UsernameNotFoundException, DataAccessException { | |
User user = userDao.getUserByUserName(userName); | |
if (user == null) | |
throw new UsernameNotFoundException( | |
"getUserByUserName returned null."); | |
else { | |
List<Role> roles = roleDao.getRolesByUsername(userName); | |
user.setUserAuthorities(roles); | |
} | |
return user; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment