<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

    環(huán)境:
    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認證方式,也可以自己實現(xiàn)認證方式,可調定為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,資源與權限的映射關系在開發(fā)時已經(jīng)綁定死,無法動態(tài)修改。


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

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

    posted on 2010-04-27 09:56 Robin's Programming World 閱讀(2363) 評論(0)  編輯  收藏 所屬分類: JavaFlex & Flash
    主站蜘蛛池模板: 亚洲成av人片在线看片| 亚洲国产精品无码久久SM| 亚洲一区二区三区免费在线观看| 色多多www视频在线观看免费| 免费人成在线观看播放国产| 久久久久久亚洲av无码蜜芽| 日本久久久免费高清| 亚洲AV噜噜一区二区三区| 免费毛片在线播放| 国产成人亚洲精品蜜芽影院| 日韩a级毛片免费视频| 色天使亚洲综合一区二区| va亚洲va日韩不卡在线观看| 国产精品视频全国免费观看| 亚洲色无码一区二区三区| 久9久9精品免费观看| 亚洲伊人久久大香线蕉啊| 毛片免费在线观看网站| 男性gay黄免费网站| 久久亚洲高清观看| 100000免费啪啪18免进| 在线看亚洲十八禁网站| 国产亚洲一区二区三区在线不卡| 99re6在线精品免费观看| 亚洲综合图片小说区热久久| 一二三四在线观看免费高清中文在线观看 | 18禁男女爽爽爽午夜网站免费| 亚洲偷自拍拍综合网| 免费观看男人吊女人视频| 亚洲综合久久久久久中文字幕| 成人激情免费视频| 免费国产污网站在线观看不要卡| 亚洲精品无码AV人在线播放| 91精品国产免费久久久久久青草| 亚洲av日韩aⅴ无码色老头| 久久亚洲av无码精品浪潮| 日本阿v免费费视频完整版| 欧亚一级毛片免费看| 久久久亚洲欧洲日产国码aⅴ | 亚洲综合小说久久另类区| 免费看国产精品麻豆|