我想知道如何將這兩個認證步驟相結合:在LDAPJAAS額外的LoginModules
- 檢查用戶名/密碼
- 添加校長在DB的對象體內發現(角色)。
LDAP用戶存儲庫不知道應用程序特定的角色,我不想管理應用程序數據庫中的密碼。所以我需要兩個。
JAAS配置文件允許有額外的LoginModule:
<name used by application to refer to this entry> {
<LoginModule> <flag> <LoginModule options>;
<optional additional LoginModules, flags and options>;
};
,但我無法找到的例子,說明如何我的作品。
這是不錯的方法嗎?
感謝
=========================================
這裏是我的回答:
事實上,我們可以有更多的LoginModule。 JAAS配置文件是:
Sample {
com.sun.security.auth.module.LdapLoginModule Requisite
userProvider="ldap://acme.org:389/OU=Users,OU=_ACME,DC=acmegis,DC=acme,DC=org"
authIdentity="{USERNAME}"
userFilter="(userPrincipalName={USERNAME})"
storePass=true
sample.module.SampleLoginModule required debug=true;
};
在這裏,我們有兩個的LoginModule:
太陽的LdapLoginModule,檢查用戶名/密碼, 和查詢我的數據庫,填補了校長雷sample.module.SampleLoginModule。 重要的參數是storePass = true,它要求LdapLoginModule將用戶名和密碼存儲在模塊的共享狀態中。 (見http://docs.oracle.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/module/LdapLoginModule.html)。
因此,下一個LoginModules可以獲取傳遞給sharedState Map參數中的initialize方法的用戶名。他們在login()中應該沒有任何關係,並且在DB中填充Principales的查詢是在commit()中完成的(就像Shimi Bandiel所說的那樣)。
我還沒有使用它,但是JBoss開發的DatabaseServerLoginModule(請參閱http://community.jboss.org/wiki/DatabaseServerLoginModule)支持身份驗證和角色映射。與password-stacking = useFirstPass一起使用,我們應該在不寫任何行代碼(但是是一個漂亮的JAAS配置文件)的情況下得到我需要的答案。
B.R.
謝謝你的回答。但是「com.sun.security.auth.module.LdapLoginModule」已經通過LDAP檢查用戶/密碼,我不想重寫它。看看我的答案,並發表評論(如果你想)。 B.R。 – kiki