Jetspeed-2 心得隨筆(5)(完)-Security
Posted on 2006-07-17 17:22 開(kāi)源愛(ài)好者 閱讀(772) 評(píng)論(2) 編輯 收藏 所屬分類(lèi): Portal
Jetspeed2 Security介紹的官方連結(jié):
[url]http://portals.apache.org/jetspeed-2/multiproject/jetspeed-security/[url]
J2使用JAAS的來(lái)處理security有關(guān)的問(wèn)題。以之前裝在Tomcat上的J2為例,可以由c:\tomcat\conf\Catalina\localhost\jetspeed.xml及C:\tomcat\webapps\jetspeed\WEB-INF\web.xml看到有關(guān)JAAS Realm及l(fā)ogin的設(shè)定。
大致上來(lái)說(shuō),JAAS包含Principal、Permission、Policy三個(gè)概念。在J2中有user、role、group三種Principal。而Permission基本上有page、portlet,tab等等,當(dāng)然也可以增加自訂的Permission。至於Policy,J2並沒(méi)有使用JAAS的policy檔,而是使用自帶的RdbmsPolicy,也就是把Policy的資訊存在資料庫(kù)中;而透過(guò)"適當(dāng)"的實(shí)作和設(shè)定,J2也可以使用相關(guān)App Server的JAAS。
底下是官方的security元件架構(gòu)圖:

在J2中,核心的部份就是"J2 Security Coarsed Services"裡的4個(gè)Manager元件。J2的JAAS login module實(shí)際上是使用UserManager來(lái)進(jìn)行authentication;UserManager透過(guò)OJB自資料庫(kù)中取出user的資料例如UserPrincipal、Crendential等並進(jìn)行authorization.
當(dāng)透過(guò)UserManager認(rèn)證完成以後,J2會(huì)同時(shí)將此User相對(duì)應(yīng)的所有Principal取出並建立此User的Subject。此後,當(dāng)SecurityValve執(zhí)行時(shí),就會(huì)呼叫JAAS的Subject.doAsPrivileged(Subject,PrivilegedAction,AccessControlContext)進(jìn)行有關(guān)authorization的動(dòng)作。有興趣的可以參考o(jì)rg.apache.jetspeed.security.impl.AbstractSecurityValve的原始碼。
J2在security的部份也提供了SPI的設(shè)計(jì)供開(kāi)發(fā)人員加入自訂的認(rèn)證方式,例如使用LDAP,參考底下官方的連結(jié)http://portals.apache.org/jetspeed-2/multiproject/jetspeed-security/ldap.html可以知道如何使用LDAP來(lái)進(jìn)行J2上的認(rèn)證。
關(guān)於J2,其實(shí)還有很多部份值得介紹,例如Bridge、Profiler等等??上н@些部份小弟並不是十分的了解,期待日後有更多高手能夠?qū)2做更多的介紹,小弟在此先向大家跪謝啦!!Orz
[url]http://portals.apache.org/jetspeed-2/multiproject/jetspeed-security/[url]
J2使用JAAS的來(lái)處理security有關(guān)的問(wèn)題。以之前裝在Tomcat上的J2為例,可以由c:\tomcat\conf\Catalina\localhost\jetspeed.xml及C:\tomcat\webapps\jetspeed\WEB-INF\web.xml看到有關(guān)JAAS Realm及l(fā)ogin的設(shè)定。
大致上來(lái)說(shuō),JAAS包含Principal、Permission、Policy三個(gè)概念。在J2中有user、role、group三種Principal。而Permission基本上有page、portlet,tab等等,當(dāng)然也可以增加自訂的Permission。至於Policy,J2並沒(méi)有使用JAAS的policy檔,而是使用自帶的RdbmsPolicy,也就是把Policy的資訊存在資料庫(kù)中;而透過(guò)"適當(dāng)"的實(shí)作和設(shè)定,J2也可以使用相關(guān)App Server的JAAS。
底下是官方的security元件架構(gòu)圖:

在J2中,核心的部份就是"J2 Security Coarsed Services"裡的4個(gè)Manager元件。J2的JAAS login module實(shí)際上是使用UserManager來(lái)進(jìn)行authentication;UserManager透過(guò)OJB自資料庫(kù)中取出user的資料例如UserPrincipal、Crendential等並進(jìn)行authorization.
當(dāng)透過(guò)UserManager認(rèn)證完成以後,J2會(huì)同時(shí)將此User相對(duì)應(yīng)的所有Principal取出並建立此User的Subject。此後,當(dāng)SecurityValve執(zhí)行時(shí),就會(huì)呼叫JAAS的Subject.doAsPrivileged(Subject,PrivilegedAction,AccessControlContext)進(jìn)行有關(guān)authorization的動(dòng)作。有興趣的可以參考o(jì)rg.apache.jetspeed.security.impl.AbstractSecurityValve的原始碼。
J2在security的部份也提供了SPI的設(shè)計(jì)供開(kāi)發(fā)人員加入自訂的認(rèn)證方式,例如使用LDAP,參考底下官方的連結(jié)http://portals.apache.org/jetspeed-2/multiproject/jetspeed-security/ldap.html可以知道如何使用LDAP來(lái)進(jìn)行J2上的認(rèn)證。
關(guān)於J2,其實(shí)還有很多部份值得介紹,例如Bridge、Profiler等等??上н@些部份小弟並不是十分的了解,期待日後有更多高手能夠?qū)2做更多的介紹,小弟在此先向大家跪謝啦!!Orz