有没有办法在使用 acegi 安全模块的 servlet 应用程序中避免基于表单的登录?我想以某种方式将登录名和密码传递给 URL。我试着这样称呼:
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
也收到了事件并显示了身份验证表单。