kapok

          垃圾桶,嘿嘿,我藏的這么深你們還能找到啊,真牛!

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            455 隨筆 :: 0 文章 :: 76 評(píng)論 :: 0 Trackbacks

          http://firebody.blogbus.com/logs/2004/08/320481.html
          一般對(duì)于權(quán)限管理的基本思路是ACL列表。關(guān)系邏輯如下:

          user(group)--AccessI(訪問級(jí)別)---resources(各種資源)

          一行就是一個(gè)ACL記錄。基于這種原理,opensymphony開發(fā)了兩個(gè)框架:OSUser ,OsAccess。都是很優(yōu)秀的框架,可以去參考一下。

          ACL缺點(diǎn):

          用數(shù)據(jù)的格式硬性限定權(quán)限管理,失去靈活定制的功能。

          ACL以resource,user為主。

          抽象不大合理。ACL本身是一個(gè)抽象嗎?值得探討。現(xiàn)實(shí)世界中,一個(gè)人具備一些權(quán)限,這些權(quán)限可以操作特定資源。那我們的抽象就應(yīng)該是user本身關(guān)聯(lián)著權(quán)限,關(guān)聯(lián)的箭頭由User指向權(quán)限,然而ACL中的User與權(quán)限的關(guān)聯(lián)卻是被動(dòng)的關(guān)聯(lián)。

          ACL本身不適合反映用戶組(機(jī)構(gòu))權(quán)限繼承關(guān)系。

          在OA場(chǎng)合中,也不適合使用ACL。

          接下來,我們探討一下基于role的權(quán)限的管理設(shè)計(jì)。

          引用一篇java道上的一片帖子:

          作者:dunel  出自:http://www.jdon.com

          最近對(duì)就有系統(tǒng)人員權(quán)限升級(jí)計(jì)劃——也談人員權(quán)限的設(shè)計(jì)。

          dunel http://www.jdon.com Apr 16, 2004 5:43 PM 回復(fù)此消息 回復(fù)

          前言:
          人員、機(jī)構(gòu)、角色、權(quán)限對(duì)象間組織關(guān)系的重新抽象;

          人員、機(jī)構(gòu)、角色、權(quán)限;
          這四個(gè)經(jīng)過抽象的對(duì)象原型經(jīng)過事實(shí)證明還是比較成功的;

          這幾個(gè)對(duì)象不會(huì)有大的變動(dòng);
          但是實(shí)際中也碰到了問題,就是這些對(duì)象之間關(guān)系的不確定性;
          下面描述以下四個(gè)對(duì)象新的關(guān)系結(jié)構(gòu);

          1 核心思想:

          1。人員在系統(tǒng)中總是扮演某種角色的;
          例如:小張?jiān)趯儆谵k公廳這個(gè)部門,以前我們都傾向于認(rèn)為辦公廳聚合了小張。
          其實(shí)考察一下實(shí)際情況,辦公廳下面有個(gè)辦公廳人員這個(gè)角色,而小張只是扮演了這個(gè)角色而已;
          考慮一下如果當(dāng)小長(zhǎng)被調(diào)動(dòng)另外一個(gè)部門時(shí)候那種抽象更容易處理。

          2。業(yè)務(wù)邏輯希望面對(duì)的是系統(tǒng)中的角色,而非扮演角色的具體的人。
          例如:以工作流示例,一個(gè)公文的下一步流轉(zhuǎn)的對(duì)象是組織部部長(zhǎng),他不關(guān)心誰扮演這個(gè)部長(zhǎng),人員權(quán)限模塊知道就行了。

          2 抽象關(guān)系描述:


          .人員和機(jī)構(gòu)之間的松耦合(通過角色耦合)

          目的:改變?cè)愀獾厝藛T和機(jī)構(gòu)之間的強(qiáng)聚合關(guān)系。




          人員和部門通過角色進(jìn)行耦合;

          人員和部門的關(guān)系可以容易的變化,不會(huì)產(chǎn)生大的影響。

          .人員和角色間變成強(qiáng)聚合關(guān)系;

          目的:強(qiáng)調(diào)人員在系統(tǒng)中必須扮演角色,起碼扮演某個(gè)機(jī)構(gòu)的人員這個(gè)角色;




          人員的角色又可以同時(shí)扮演的,也有互相排斥的。

          排斥的角色就是不能同時(shí)扮演的,登錄以后可以選擇的角色;

          由管理員規(guī)定人員的那些角色是相互排斥的;


          .機(jī)構(gòu)和權(quán)限點(diǎn)之間沒有直接關(guān)系;

          目的:讓機(jī)構(gòu)的抽象更清晰化,機(jī)構(gòu)和權(quán)限的關(guān)系通過角色體現(xiàn);


          .機(jī)構(gòu)和角色之間強(qiáng)聚合關(guān)系;

          目的:明確部門的作用是行使某種特定職能的。



          說明:

          部門和部門之間還有從屬關(guān)系;

          部門可以專門設(shè)置部門管理員用于管理下級(jí)的機(jī)構(gòu)和人員,使分級(jí)管理在模型上成為可能;

          部門擁有的角色有寫是系統(tǒng)規(guī)定的,如:部門人員,部門管理員;

          部門可以自定義自己的角色,并由部門管理員管理;

          .角色之間的繼承關(guān)系;
          目的:更好的處理角色和權(quán)限點(diǎn)之間的關(guān)系;



          說明:

          角色之間擁有繼承關(guān)系如上圖所示。

          可以被繼承的角色是由系統(tǒng)管理員制定的,部門管理員不能制定;

          3 總結(jié):

          經(jīng)過考慮,我認(rèn)為 人員、機(jī)構(gòu)、角色、權(quán)限 的關(guān)系應(yīng)該做成可以改變的插件,系統(tǒng)初始時(shí)候進(jìn)行選擇不同組織方式;

          也就是說,上文描述的 人員、機(jī)構(gòu)、角色、權(quán)限 的關(guān)系還有原有關(guān)系都做成的插件,并不拋棄原有的人員權(quán)限關(guān)系。


          Re: 最近對(duì)就有系統(tǒng)人員權(quán)限升級(jí)計(jì)劃——也談人員權(quán)限的設(shè)計(jì)。 發(fā)表時(shí)間: Apr 16, 2004 5:46 PM
          回復(fù)此消息 回復(fù)
          發(fā)表人: dunel    發(fā)表文章: 13 / 注冊(cè)時(shí)間: 2004-04





          Re: 最近對(duì)就有系統(tǒng)人員權(quán)限升級(jí)計(jì)劃——也談人員權(quán)限的設(shè)計(jì)。 發(fā)表時(shí)間: Apr 16, 2004 5:53 PM
          回復(fù)此消息 回復(fù)
          發(fā)表人: dunel    發(fā)表文章: 13 / 注冊(cè)時(shí)間: 2004-04
          與RBAC向做的設(shè)想就是人員和權(quán)限的直接耦合關(guān)系。
          在應(yīng)用中經(jīng)常會(huì)出現(xiàn)某個(gè)人就是要比其他人多出來一個(gè)權(quán)限,而且這樣的情況非常多,如果每次都為這種情況做一個(gè)角色的話,基本上會(huì)造成角色的泛濫。
          不知道大家有什么好的設(shè)想,或者解決方案。


          Re: 最近對(duì)就有系統(tǒng)人員權(quán)限升級(jí)計(jì)劃——也談人員權(quán)限的設(shè)計(jì)。 發(fā)表時(shí)間: Apr 19, 2004 4:32 PM
          回復(fù)此消息 回復(fù)
          發(fā)表人: dunel    發(fā)表文章: 13 / 注冊(cè)時(shí)間: 2004-04
          最近研究了RBAC的規(guī)范,RBAC沒有提到關(guān)于人員是如何組織的,更關(guān)注與資源的控制。但是我認(rèn)為人員機(jī)構(gòu)的管理是應(yīng)該一起關(guān)注的,所以做出了這樣的設(shè)計(jì)。

          大家給提提意見吧。

          Re: 最近對(duì)就有系統(tǒng)人員權(quán)限升級(jí)計(jì)劃——也談人員權(quán)限的設(shè)計(jì)。 發(fā)表時(shí)間: Apr 20, 2004 1:28 PM
          回復(fù)此消息 回復(fù)
          發(fā)表人: dunel    發(fā)表文章: 13 / 注冊(cè)時(shí)間: 2004-04
          ROLE BASE ACCESS CONTROL
          最近研究了RBAC的標(biāo)準(zhǔn),這個(gè)標(biāo)準(zhǔn)剛剛成為美國(guó)國(guó)家標(biāo)準(zhǔn)。http://csrc.nist.gov/rbac/

          下面是我的一些心得和筆記,希望能有用處。

          1. RBAC的中心思想就是通過角色來做到用戶和權(quán)限點(diǎn)的關(guān)聯(lián);
          2. 擴(kuò)展RBAC角色是可以繼承的。
          一般繼承,就是多繼承,一個(gè)角色可以繼承多個(gè)角色;
          限制繼承就是單繼承,一個(gè)角色只能繼承一個(gè)角色;
          3. 靜態(tài)職責(zé)分離Static Separation of Duty --SSD是說,一個(gè)人一次只能扮演一個(gè)角色;
          經(jīng)常在系統(tǒng)的行政角色上實(shí)施SSD;這個(gè)限制強(qiáng)加在人員分配的情況下的;
          4. 動(dòng)態(tài)職責(zé)分離 Dynamic Separation of Duty – DSD就是:timely revocation of truest,就是能給人員分配沖突的角色,但是一個(gè)人每次只能扮演其中的一個(gè);原來的設(shè)想中涉及到了DSD就是讓人選擇角色進(jìn)入;

           

          我們看看一個(gè)XML實(shí)現(xiàn):

          user.xml:---》對(duì)應(yīng)role權(quán)限系統(tǒng)中的參與者。

          <?xml version="1.0" encoding="UTF-8"?>
          <users>
            <user id="superuser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
              <attributes>
                <attribute name="firstname" value="superuser"/>
                <attribute name="password" value="secret"/>
              </attributes>
            </user>
            <user id="bob">
              <roles>
                <role id="portal.user"/>
                <role id="portal.it"/>
              </roles>
              <attributes>
                <attribute name="firstname" value="Bob"/>
                <attribute name="password" value="bob1"/>
              </attributes>
            </user>
            <user id="alice">
              <roles>
                <role id="portal.user"/>
              </roles>
              <attributes>
                <attribute name="firstname" value="Alice"/>
                <attribute name="password" value="alice1"/>
              </attributes>
            </user>
          </users>
          ----------------------------------------------------------------

          rolse.xml:---->對(duì)應(yīng)role權(quán)限設(shè)計(jì)系統(tǒng)中的角色定義

          <?xml version="1.0" encoding="UTF-8"?>
          <roles>
            <role description="This role is for IT users of the portal" id="portal.it">
              <resources>
                <resource id="gadget.slashdot"/>
              </resources>
            </role>
            <role description="This role is for normal users of the portal" id="portal.user">
              <resources>
                <resource id="gadget.info"/>
                <resource id="gadget.calc"/>
                <resource id="gadget.news"/>
                <resource id="gadget.joke"/>
                <resource id="gadget.cal"/>
              </resources>
            </role>
            <role description="This role can administer the profilestore" id="profilestore.administrator">
              <resources>
                <resource id="profilestore.AddResource"/>
                <resource id="profilestore.AddResourceToRole"/>
                <resource id="profilestore.AddRole"/>
                <resource id="profilestore.AddRoleToUser"/>
                <resource id="profilestore.AddUser"/>
                <resource id="profilestore.ChangePassword"/>
                <resource id="profilestore.DeleteResource"/>
                <resource id="profilestore.DeleteRole"/>
                <resource id="profilestore.DeleteUser"/>
                <resource id="profilestore.GetUser"/>
                <resource id="profilestore.GetUserProperty"/>
                <resource id="profilestore.GetUsers"/>
                <resource id="profilestore.HasResource"/>
                <resource id="profilestore.HasRole"/>
                <resource id="profilestore.ModifyUser"/>
                <resource id="profilestore.RemoveResourceFromRole"/>
                <resource id="profilestore.RemoveRoleFromUser"/>
                <resource id="profilestore.SetUserProperty"/>
              </resources>
            </role>
          </roles>
          -----------------------------------------------------------------------

          resources.xml:--->對(duì)應(yīng)role權(quán)限設(shè)計(jì)中的權(quán)限點(diǎn)

           </resource>
            <resource description="The ability to add a resource to a role" id="profilestore.AddResourceToRole">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to add a role" id="profilestore.AddRole">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to add a role to a user" id="profilestore.AddRoleToUser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to add a user" id="profilestore.AddUser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to change a password" id="profilestore.ChangePassword">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to delete a resource" id="profilestore.DeleteResource">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to delete a role" id="profilestore.DeleteRole">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to delete a user" id="profilestore.DeleteUser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to get a user's details" id="profilestore.GetUser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to get a user property" id="profilestore.GetUserProperty">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to get user details" id="profilestore.GetUsers">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to check if a user has  a resource" id="profilestore.HasResource">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to check if a user has a role" id="profilestore.HasRole">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to modify a user's details" id="profilestore.ModifyUser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to remove a resource from a role" id="profilestore.RemoveResourceFromRole">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to remove a role from a user" id="profilestore.RemoveRoleFromUser">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
            <resource description="The ability to set a user property" id="profilestore.SetUserProperty">
              <roles>
                <role id="profilestore.administrator"/>
              </roles>
            </resource>
          </resources>
          -------------------------------------------------

           

          posted on 2005-05-23 23:39 笨笨 閱讀(10495) 評(píng)論(1)  編輯  收藏 所屬分類: J2EEHibernateAndSpringALL

          評(píng)論

          # re: 一個(gè)很不錯(cuò)的基于角色的權(quán)限管理系統(tǒng)設(shè)計(jì)! 2011-12-13 17:15 Smt
          好深?yuàn)W  回復(fù)  更多評(píng)論
            

          主站蜘蛛池模板: 汾阳市| 蒲城县| 黄大仙区| 深圳市| 英吉沙县| 安龙县| 开原市| 城固县| 丰镇市| 茂名市| 汾西县| 广宁县| 宾阳县| 洱源县| 格尔木市| 高淳县| 芦山县| 清丰县| 聊城市| 建平县| 博客| 阜康市| 雷山县| 望江县| 运城市| 徐州市| 阿坝| 宁南县| 扶余县| 克山县| 定襄县| 百色市| 绥宁县| 新疆| 临夏县| 万宁市| 潼关县| 天祝| 阳原县| 茂名市| 新丰县|