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