2011-10-25 91 views
0

我的應用程序使用Spring Security來處理身份驗證。到目前爲止,我是使用基於JDBC的用戶服務簡單authenticaton提供商這既是執行認證和裝載當局和所有工作得很好:Spring Security:一個身份驗證提供程序,用於加載授權和其他身份驗證

<authentication-manager alias="authenticationManager"> 
    <authentication-provider> 
     <password-encoder hash="sha" /> 
     <jdbc-user-service data-source-ref="dataSource" 
      authorities-by-username-query="select t1.login, t2.USERROLES from USER as t1, USERROLES as t2 where t1.ID=t2.User_ID and t1.login= ?" 
      users-by-username-query="select login,password,enabled from USER where login = ?" /> 
    </authentication-provider> 
</authentication-manager> 

現在,我得到了一個新的規範:

  1. 機構要從數據庫加載像以前一樣
  2. 驗證應使用LDAP

做我正確配置LDAP身份驗證我在測試應用程序中,它工作得很好。現在我必須把它放在一起。我怎麼能讓我的jdbc認證提供程序不執行認證,但只加載權限,並啓用下一個認證管理器(在我的情況下,LDAP認證管理器)做真正authenticaton?

回答

2

您需要實現自己的身份驗證提供程序,但當然您可以重複使用DaoAuthenticationProvider和LDAP身份驗證提供程序。

BTW:Ldap身份驗證提供程序的授權部分在LdapAuthoritiesPopulator中完成。