2010-03-30 72 views
0

我有一個設置爲使用默認ldap服務器/認證管理器/認證提供者/用戶服務的Web應用程序。我有另一個DAO,它已經完成了大部分使用Spring-LDAP(除了驗證用戶身份)所做的工作。我的問題是,我希望主體是我自己的自定義bean類。什麼是最簡單的方法來做到這一點?春季安全定製主要版本

最初我想創建一個自定義身份驗證提供程序,但由於默認的提供程序完全符合我的要求,似乎並不需要。我想我只需要重寫實際返回Principal bean的任何對象。這是可能的,並且能夠被注入安全ldap驗證器上下文中?

這是怎樣我現在有它設置:

<ldap-server 
    url="ldap://HOST:3268/BASEDN" 
    manager-dn="FULLDN" 
    manager-password="PASS"/> 

    <authentication-manager> 
<ldap-authentication-provider user-search-filter="(samaccountname={0})"/> 
<authentication-provider> 
     <ldap-user-service user-search-filter="(samaccountname={0})"/> 
</authentication-provider> 

</authentication-manager> 

是「LDAP用戶服務」的主要豆什麼鏈接到SecurityContext中的Authentication對象?

現在的問題是我有第二個LDAP配置(幾乎與auth配置相同),用於DAO,當用戶轉到頁面時,我只需重新查找他們的用戶帳戶,然後找回用戶對象(這將是很好,如果它是SecurityContext的校長)...

回答

1

使用ldap-authentification-provider/@user-context-mapper-ref和實現自己的 org.springframework.security.ldap.userdetails.UserDetailsContextMapper