3
我有以下UserDetailsService实现。
到目前为止,身份验证过程运行良好。
如何将我的“MYUSER豆”(即成功登录)存储在“会话”,所以我可以在我的应用弹簧安全访问来自更深层的UserDetailsService
感谢访问它在其他领域。
@Transactional(readOnly = true)
public class CustomUserDetailsService implements UserDetailsService {
private EmployeesApi employeesApi = new EmployeesApi();
/**
* Retrieves a user record containing the user's credentials and access.
*/
public UserDetails loadUserByUsername(String userName)
throws UsernameNotFoundException, DataAccessException {
// Declare a null Spring User
UserDetails user = null;
try {
MyUser employee = employeesApi.getByUserName(userName);
user = new User(
employee.getUserName(),
employee.getPassword().toLowerCase(),
true,
true,
true,
true,
getAuthorities(1));
} catch (Exception e) {
logger.error("Error in retrieving user");
throw new UsernameNotFoundException("Error in retrieving user");
}
}
....
对不起,我不明白,你可以发布简单的例子? TX! – fatnjazzy 2011-02-06 12:34:18