WebApplicationContext webApplicationContext = WebApplicationContextUtils
.getWebApplicationContext(sc);
AuthenticationManager authenticationManager = (AuthenticationManager) webApplicationContext
.getBean("authenticationManager");
RememberMeServices rememberMeServices = (RememberMeServices) webApplicationContext
.getBean("rememberMeServices");
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(
accountid, "");
HttpSession session = request.getSession();
session.setAttribute("ACEGI_SECURITY_LAST_USERNAME", accountid);
WebAuthenticationDetails webdetails = new WebAuthenticationDetails(
request);
auth.setDetails(webdetails);
Authentication tauth = authenticationManager.authenticate(auth);
SecurityContextHolder.getContext().setAuthentication(tauth);
rememberMeServices.loginSuccess(request, response, tauth);
动态创建Authentication对象
最新推荐文章于 2023-10-06 20:59:23 发布