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

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

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

    Vikings

    2008年10月29日 #

    Dom4j的CDATA問題與UTF-8字符集

     

    本文轉自:http://www.b9527.net/?q=node/1124
     
    原文如下:
     

    1. 寫入文件的格式

    寫入 Xml 文件的時候默認是全部內容寫為一行,這個可以通過加入 Format 來解決:

    OutputFormat format = OutputFormat.createPrettyPrint();

    2. Xml 中文問題

    2.1 Xml 最好設為 UTF-8 格式,

    format.setEncoding("utf-8");

    2.2 不要用 FileWriter 輸出雙字節,改為 FileOutputStream 輸出單字節:

    XMLWriter output = new XMLWriter(new FileOutputStream(configFile), format);

    3. CDATA類型文本輸入

    Element conTblOpr = rowElement.addElement(XmlDBConstants.CON_TBL_OPR);// 加入節點

    DefaultCDATA conTblOprCdata = new DefaultCDATA(conTblOprField);// CDATA格式化

    conTblOpr.add(conTblOprCdata );// 加入CDATA文本

    Dom4j 里面已經內置了對 CDATA 類型文本的支持,不要硬編碼去在文本兩邊加<![CDATA[***]]>。

     

    posted @ 2011-07-05 00:12 Vikings 閱讀(2224) | 評論 (0)編輯 收藏

    實施WebService Security[WS-Security1.0]的Encrypt和Sign模式(XFire+WSS4J)

    轉自:
    http://www.tkk7.com/security/archive/2006/08/08/xfire_wss4j.html

    thanks for springside

    鑒于很多系統需要實施WS-Security的標準,我們在SpringSide中提供了XFire+WSS4J的Demo,本文介紹SpringSide中Spring+XFire+WSS4J的基本配置

    [WebService Server端配置]
    第一,創建一個基本的BookService
    public interface BookService {
        
    /** *//**
         * 按書名模糊查詢圖書
         
    */

        List findBooksByName(String name);

        
    /** *//**
         * 查找目錄下的所有圖書
         *
         * 
    @param categoryId 如果category為null或“all”, 列出所有圖書。
         
    */

        List findBooksByCategory(String categoryId);

        
    /** *//**
         * 列出所有分類.
         *
         * 
    @return List<Category>,或是null。
         
    */

        List getAllCategorys();
    }
    第二,接口擴展,即Extend基本的BookService,在XFire中,不同的WSS4J策略需要針對不同的ServiceClass,否則<inHandlers>里面的定義會Overlap。


       <!--BookService 基類-->
        
    <bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" abstract="true">
            
    <property name="serviceFactory" ref="xfire.serviceFactory"/>
            
    <property name="xfire" ref="xfire"/>
        
    </bean>

        
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            
    <property name="mappings">
                
    <value>
                    /BookService=bookService
                    /BookServiceWSS4J=bookServiceWSS4J
                    /BookServiceWSS4JEnc=bookServiceWSS4JEnc
                    /BookServiceWSS4JSign=bookServiceWSS4JSign
                
    </value>
            
    </property>
        
    </bean>

       
    <!--(1)BookWebService 不需要認證-->
        
    <bean id="bookService" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceFactory" ref="xfire.serviceFactory"/>
            
    <property name="xfire" ref="xfire"/>
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookService"/>
        
    </bean>

        
    <!--  (3)BookWebService 使用 WSS4J驗證-->
        
    <bean id="bookServiceWSS4J" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookServiceWSS4J"/>
            
    <property name="inHandlers">
                
    <list>
                    
    <ref bean="domInHandler"/>
                    
    <ref bean="wss4jInHandler"/>
                    
    <ref bean="validateUserTokenHandler"/>
                
    </list>
            
    </property>
        
    </bean>

        
    <bean id="domInHandler" class="org.codehaus.xfire.util.dom.DOMInHandler"/>

        
    <bean id="wss4jInHandler" class="org.codehaus.xfire.security.wss4j.WSS4JInHandler">
            
    <property name="properties">
                
    <props>
                    
    <prop key="action">UsernameToken</prop>
                    
    <prop key="passwordCallbackClass">org.springside.bookstore.plugins.xfire.wss4j.PasswordHandler</prop>
                
    </props>
            
    </property>
        
    </bean>

        
    <bean id="validateUserTokenHandler" class="org.springside.bookstore.plugins.xfire.wss4j.WSS4JTokenHandler"/>
        
        
    <!--  (4)BookWebService 使用 WSS4J驗證 Encrypt模式-->
        
    <bean id="bookServiceWSS4JEnc" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookServiceWSS4JEnc"/>
            
    <property name="inHandlers">
                
    <list>
                    
    <ref bean="domInHandler"/>
                    
    <ref bean="wss4jInHandlerEnc"/>
                    
    <ref bean="validateUserTokenHandler"/>
                
    </list>
            
    </property>
        
    </bean>
            
        
    <bean id="wss4jInHandlerEnc" class="org.codehaus.xfire.security.wss4j.WSS4JInHandler">
            
    <property name="properties">
              
    <props>
                
    <prop key="action">Encrypt</prop>
                
    <prop key="decryptionPropFile">org/springside/bookstore/plugins/xfire/wss4j/insecurity_enc.properties</prop>
                
    <prop key="passwordCallbackClass">org.springside.bookstore.plugins.xfire.wss4j.PasswordHandler</prop>
              
    </props>
            
    </property>
        
    </bean>
        
        
    <!--  (5)BookWebService 使用 WSS4J驗證 Signature模式-->
        
    <bean id="bookServiceWSS4JSign" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookServiceWSS4JSign"/>
            
    <property name="inHandlers">
                
    <list>
                    
    <ref bean="domInHandler"/>
                    
    <ref bean="wss4jInHandlerSign"/>
                    
    <ref bean="validateUserTokenHandler"/>
                
    </list>
            
    </property>
        
    </bean>
        
        
    <bean id="wss4jInHandlerSign" class="org.codehaus.xfire.security.wss4j.WSS4JInHandler">
            
    <property name="properties">
              
    <props>
                
    <prop key="action">Signature</prop>
                
    <prop key="signaturePropFile">org/springside/bookstore/plugins/xfire/wss4j/insecurity_sign.properties</prop>
                
    <prop key="passwordCallbackClass">org.springside.bookstore.plugins.xfire.wss4j.PasswordHandler</prop>
              
    </props>
            
    </property>
        
    </bean>
        
    </beans>

    posted @ 2008-10-29 01:55 Vikings 閱讀(379) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 国产精品久免费的黄网站| 好紧我太爽了视频免费国产| 亚洲激情在线观看| a在线观看免费视频| 免费精品国偷自产在线在线 | 国产成人精品日本亚洲专区| 亚洲人成电影亚洲人成9999网| 中文成人久久久久影院免费观看| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 久久精品国产亚洲77777| 99在线视频免费| 亚洲同性男gay网站在线观看| 免费中文字幕视频| 亚洲精品视频免费观看| 国产一级a毛一级a看免费人娇| 成年女人午夜毛片免费看| 久久精品国产亚洲AV麻豆王友容| 人人玩人人添人人澡免费| 亚洲色图综合在线| 日韩精品无码免费专区午夜| 亚洲avav天堂av在线不卡| 青娱乐免费在线视频| 亚洲欧洲无卡二区视頻| A在线观看免费网站大全| 亚洲精品久久久久无码AV片软件| 免费国产综合视频在线看| 国产在线观看免费av站| 久久亚洲日韩看片无码| 国产一精品一AV一免费| 久久久久亚洲av无码专区喷水| 成年男女男精品免费视频网站| 免费夜色污私人影院网站| 国产亚洲欧洲精品| 成人片黄网站色大片免费观看cn| 久久久久亚洲AV成人片| 在线观看国产情趣免费视频| 91成人免费观看在线观看| 久久精品国产亚洲AV久| 动漫黄网站免费永久在线观看| 无码毛片一区二区三区视频免费播放 | 成全视频在线观看免费高清动漫视频下载 |