2013-07-24 25 views
0

在spring security中是否有任何配置方式,所以我可以在調用此代碼時獲得自定義的「USER」DAO類對象。在Spring Security中配置一個自定義對象

SecurityContextHolder.getContext().getAuthentication().getPrincipal(); 
+0

您的DAO對象?你確定?基本上,你的意思是你的「用戶」對象(或任何你所說的)? – mael

+0

是「用戶」dao對象 –

回答

2

做用DaoAuthenticationProvider

  1. 確保您User DAO對象最簡單的方法擴展org.springframework.security.core.userdetails.UserDetails
  2. 實現你org.springframework.security.core.userdetails.UserDetailsService和你UserDetailsService
  3. 回報您 User DAO對象
  4. 配置DaoAuthenticationProvider
+0

我應該在spring xml文件中將它配置爲一個bean –

+0

您現在使用什麼配置?你應該配置DaoAuthenticationProvider – Michael

相關問題