我記得,我bean定義是這樣的,並且工作正常程序化記得,我與春天secruity
<security:remember-me data-source-ref="dataSource" user-service-ref="userService"/>
然而,用戶第一次註冊,我想以編程方式記錄他們並執行一記-我。我不知道如何訪問Remember-me服務。我能做到這一點
UsernamePasswordAuthenticationToken auth =
new UsernamePasswordAuthenticationToken(user, "", authorities);
SecurityContextHolder.getContext().setAuthentication(auth);
HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request) {
@Override public String getParameter(String name) { return "true"; }
};
但是如何訪問記住我服務象下面這樣,因爲我使用的是默認的彈簧實現,而不是我自己的豆?
getRememberMeServices().loginSuccess(wrapper, response, auth);
從here
編輯 我已經改變了我的bean定義看起來像這樣
<security:remember-me services-alias="rememberMeService" data-source-ref="dataSource" user-service-ref="userService"/>
不過的IntelliJ仍然回來同一個錯誤,當我嘗試這樣的注入:
@Resource(name = "rememberMeService")
private RememberMeServices rememberMeService;
試着替換_ @ Resource_ by _ @ Inject_或_ @ Autowired_ – 2013-02-11 09:48:05