2014-06-30 17 views
0

以下是我用於編程登錄我的應用程序的代碼。以編程方式登錄到Spring Security的問題。 Jsession ID附帶.undefined suffex

  UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userName, passWord); 
      token.setDetails(new WebAuthenticationDetails(request)); 
      authentication = authenticationManager.authenticate(token); 
      LOGGER.debug("Logging in with [{}]"+ authentication.getPrincipal()); 
      SecurityContextHolder.getContext().setAuthentication(authentication); 

之後返回模型(不更改URL,我可以看到usename n角色在這裏)。在這個觀點上,有一種形式。它提交給另一個具有與當前用戶相同的角色權限的鏈接。

但是當用戶提交表單時,Spring會將其重定向到登錄頁面並使會話無效。

我檢查並發現jsession附加了.undefined(mS5YoJL3YfznQNuItNUeiLd6.undefined),我懷疑這肯定是問題所在。

+0

Spring Security對會話ID沒有任何作用。它[完全由容器處理](http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/faq.html#session-management)。我建議在會話ID中搜索「未定義」。你會發現各種與Jboss相關的討論。 –

+0

感謝盧克, 我檢查了它,並且由於Jboss AS 7.1而未定義,因爲我沒有在自動登錄時創建會話,所以這個問題就要到了。我改變了代碼並完美運行。感謝您的答覆。 –

回答

0

我檢查了它,並且由於Jboss AS 7.1而未定義,因爲我沒有在自動登錄時創建會話,所以這個問題就要到了。我改變了代碼並完美運行。感謝您的答覆。 -