2014-01-09 109 views
0

我試圖使用Spring Security 3.1,但是我在驗證後失去了我的HttpSession。我得到:「沒有HttpSession當前存在」在創建了正確的HttpSession之後。春季安全:認證後HttpSession丟失

,我發現了以下日誌:

08 janv. 2014 19:53:59 DEBUG HttpSessionSecurityContextRepository - SecurityContext stored to HttpSession: '[email protected]e8a84f: Authentication: org.springframew[email protected]bce8a84f: Principal: [email protected]: Username: ADMIN; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]ffff6a82: RemoteIpAddress: 127.0.0.1; SessionId: qx1qn1vbjxx71xedid64oi977; Granted Authorities: ROLE_ADMIN' 
08 janv. 2014 19:53:59 DEBUG DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'spring': assuming HandlerAdapter completed request handling 
08 janv. 2014 19:53:59 DEBUG DispatcherServlet - Successfully completed request 
08 janv. 2014 19:53:59 DEBUG ExceptionTranslationFilter - Chain processed normally 
08 janv. 2014 19:53:59 DEBUG SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 1 of 10 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter' 
08 janv. 2014 19:54:00 DEBUG HttpSessionSecurityContextRepository - No HttpSession currently exists 
08 janv. 2014 19:54:00 DEBUG HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: null. A new one will be created. 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 2 of 10 in additional filter chain; firing Filter: 'LogoutFilter' 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 3 of 10 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter' 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 4 of 10 in additional filter chain; firing Filter: 'BasicAuthenticationFilter' 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 5 of 10 in additional filter chain; firing Filter: 'RequestCacheAwareFilter' 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 6 of 10 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter' 
08 janv. 2014 19:54:00 DEBUG FilterChainProxy - /index at position 7 of 10 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter' 
08 janv. 2014 19:54:00 DEBUG AnonymousAuthenticationFilter - Populated SecurityContextHolder with anonymous token: 'org.sprin[email protected]9055e4a6: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS' 

可能是什麼問題呢?

UPDATE:
我發現我的問題...我有,我應該對關心前一個文件:

碼頭-web.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
    "http://jetty.mortbay.org/configure.dtd"> 
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 
    <Get name="sessionHandler"> 
     <Get name="sessionManager"> 
      <Set name="usingCookies" type="boolean">false</Set> 
     </Get> 
    </Get> 
</Configure> 

我禁用我的cookie ...

+0

你可以請更新它的XML(S),即spring_context.xml,spring_security.xml ... –

+0

@MayurGupta我解決了我的問題。通過查看我的xml文件,我發現我禁用了我的cookie。謝謝 – user3175671

+0

哦,是的....你說得對,但你應該把這個作爲答案,你應該接受它。對於面臨同樣問題的其他程序員可能會有所幫助...... –

回答

0

,我發現我的問題......我有,我應該關心前一個文件:

碼頭-web.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
    "http://jetty.mortbay.org/configure.dtd"> 
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 
    <Get name="sessionHandler"> 
     <Get name="sessionManager"> 
      <Set name="usingCookies" type="boolean">false</Set> 
     </Get> 
    </Get> 
</Configure> 

我自己禁用了Cookie ...我刪除了這個文件,現在它正在工作。