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
事件還接收並顯示認證形式。