<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-193  評論-715  文章-1  trackbacks-0

    環境:
    BlazeDS 3.2.0.3978
    Tomcat 6.0.29 (本例在Tomcat 5.5中不能正常運行,因為Tomcat 5.5的context部分的設計與6.0不一樣)
    Java5

    1,在service-config.xml中加入認證和角色(組)的定義:
    <security>
            
    <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat" />
            
    <security-constraint id="trusted">
            
    <auth-method>Basic</auth-method>
                
    <roles>
                    
    <role>tomcat</role>
                
    </roles>
            
    </security-constraint>
            
    <security-constraint id="users">
                
    <auth-method>Basic</auth-method>
                
    <roles>
                    
    <role>role1</role>
                    
    <role>tomcat</role>
                
    </roles>
            
    </security-constraint>
        
    </security>
    需要說明的是,這里的security-constraint tag相當于一個角色組,其id屬性就是角色組的ID,如users角色組包含role1和tomcat兩個角色。
    auth-method tag表示認證的方式,Basic即采用HTTP Basic認證方式,也可以自己實現認證方式,可調定為Custom,關于此種認證方式,我將在稍后分享給大家。

    這些角色和用戶,均被定義在Tomcat的conf/tomcat-users.xml配置中:
    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
    <!--
      NOTE:  By default, no user is included in the "manager" role required
      to operate the "/manager" web application.  If you wish to use this app,
      you must define such a user - the username and password are arbitrary.
    -->
    <!--
      NOTE:  The sample user and role entries below are wrapped in a comment
      and thus are ignored when reading this file. Do not forget to remove
      <!.. ..> that surrounds them.
    -->

      
    <role rolename="tomcat"/>
      
    <role rolename="role1"/>
      
    <role rolename="manager"/>
      
    <user username="admin" password="admin" roles="manager"/>
      
    <user username="tomcat" password="tomcat" roles="tomcat"/>
      
    <user username="both" password="tomcat" roles="tomcat,role1"/>
      
    <user username="role1" password="tomcat" roles="role1"/>

    </tomcat-users>


    2,在remote-config.xml中配置具體的destination的權限約束:
    <destination id="Domain">
            
    <properties>
                
    <source>com.robin.service.domain.DomainService</source>
                
    <include-methods>
                
    <method name="getAllDomains"/>
                
    <method name="addOrUpdateDomain" security-constraint="trusted"/>
                
    </include-methods>
            
    </properties>
            
    <security>
                
    <security-constraint ref="users"/>
            
    </security>
        
    </destination>
    在此配置中,定義所有的方法只要是users角色組中的用戶即可訪問,但是addOrUpdateDomain方法需要trusted角色組中的用戶才能訪問。

    3,將BlazeDS與Tomcat結合所依賴的lib復制到lib目錄中,包含flex-tomcat-common.jar和flex-tomcat-server.jar兩個JAR。

    4,修改Tomcat目錄下的conf/context.xml文件,加入如下Context(在Tomcat5.5中無法成功):
    <Valve className="flex.messaging.security.TomcatValve"/>

    好了,就這么簡單,重啟Tomcat,即可驗證了。

    總結一下:
    1,引入了角色組的概念,這個比較好。
    2,角色和用戶定義依賴于Tomcat,無法定義在如DBMS中,不方便修改。
    3,跨平臺性不好。
    4,資源與權限的映射關系在開發時已經綁定死,無法動態修改。


    PS:2010.4.28. 分享給大家不依賴Tomcat容器實現認證與授權的例子,如有需要,請參考:《BlazeDS自定義認證與權限控制

    本Blog所有內容不得隨意轉載,版權屬于作者所有。如需轉載請與作者聯系( fastzch@163.com    QQ:9184314)。
    未經許可的轉載,本人保留一切法律權益。
    一直以來,發現有某些人完全不尊重我的勞動成果,隨意轉載,提醒一下那些人小心哪天惹上官司。

    posted on 2010-04-27 09:56 Robin's Programming World 閱讀(2349) 評論(0)  編輯  收藏 所屬分類: JavaFlex & Flash
    主站蜘蛛池模板: 国产小视频免费观看| 精品国产污污免费网站aⅴ| 国产免费131美女视频| 亚洲爆乳少妇无码激情| 免费鲁丝片一级观看| 亚洲国产精品美女久久久久| 四虎影院免费在线播放| 最刺激黄a大片免费网站| 亚洲嫩模在线观看| 最近的中文字幕大全免费8| 亚洲欧洲日韩国产| 最新欧洲大片免费在线| 亚洲男同gay片| 亚洲国产成人精品无码久久久久久综合| 日本系列1页亚洲系列| 国产男女猛烈无遮挡免费视频网站 | 三上悠亚亚洲一区高清| 中文字幕成人免费高清在线| 久久精品7亚洲午夜a| 最近中文字幕免费完整| 亚洲综合色丁香婷婷六月图片 | 亚洲欧美日韩中文二区| 啊v在线免费观看| 久久久精品视频免费观看| 久久久久亚洲av无码专区导航 | 国产精品爱啪在线线免费观看| jjzz亚洲亚洲女人| 国产日韩久久免费影院| 亚洲AV无码第一区二区三区 | 在线永久免费观看黄网站| 免费无码婬片aaa直播表情| 亚洲国产另类久久久精品| 国产亚洲美女精品久久| 国产亚洲综合成人91精品 | 中字幕视频在线永久在线观看免费 | 人人揉揉香蕉大免费不卡| 亚洲中文字幕无码中文字| 国产精品亚洲mnbav网站 | 国产亚洲综合色就色| 国产成人免费爽爽爽视频| 久久99久久成人免费播放|