0
有没有一种方法可以避免使用acegi安全模块的servlet应用程序中基于表单的登录?我想通过某种方式将登录名和密码传递给URL。我试着打电话给这样的事情:自动登录acegi安全
GrantedAuthority[] grantedAuthorities = new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ADMIN")};
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("admin", "passwordofadmin", grantedAuthorities);
WebAuthenticationDetails authdetails = (WebAuthenticationDetails) authentication.getDetails();
HttpSession session = event.getSession();
ProviderManager pm = (ProviderManager)WebApplicationContextUtils.getWebApplicationContext(session.getServletContext()).getBean("authenticationManager");
pm.doAuthentication(authentication);
SecurityContextHolder.getContext().setAuthentication(authentication);
在
HttpSessionCreatedEvent
事件的处理程序
,我收到AuthenticationSuccessEvent
事件,但随后Failure
事件还接收并显示认证形式。