• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            面對現實,超越自己
            逆水行舟,不進則退
            posts - 269,comments - 32,trackbacks - 0

            引文:

            調試GLOOX 1.0.10的注冊功能頗費了一些功夫。總體邏輯如GLOOX自帶的例子一樣是毫無疑問的,但是照搬例子又是不能完成注冊的,返回錯誤碼為4------RegistrationBadRequest筆者一開始在網上狂搜解決方案,資料少之又少,有建議重寫Client::handleNormalNode函數(目的是禁止SASL認證)的,有直接繼承Client重寫Client::handleNormalNode函數的,但都沒說到點子上。經過一段時間的研究,在GLOOX的maillist上得到啟發,順利完成注冊。現將解決方案記錄下來:


            環境

            客戶端:GLOOX1.0.1.0 VS2008

            服務器:OPENFIRE 默認安裝


            對于GLOOX自帶的注冊例子不能正常注冊的問題有人在郵件列表里提出來。一個哥們這樣回答:

            Ok, I've found what the problem was 
            In openFire server parameters, Anonymous Login => Disabled !!! 

            意思是要禁用openFire服務器里的選項”注冊和登錄“的”匿名登錄“項

            筆者按此說明禁用該選項,果然注冊成功。

            這說明開始的注冊失敗是和匿名登錄有關系的。我們來看一下引用registration_expmple例子登錄失敗時的XML流:

            S->C:服務器返回給客戶端支持的認證機制:

            <stream:features xmlns:stream='http://etherx.jabber.org/streams'><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns='http://jabber.org/features/compress'><method>zlib</method></compression><auth xmlns='http://jabber.org/features/iq-auth'/><register xmlns='http://jabber.org/features/iq-register'/></stream:features> 

             

            從上面XML流中我們可以看到,默認openFire支持四種認證機制,分別是:DIGEST-MD5、PLAIN、ANONYMOUS、CRAM-MD5。然后我們看GLOOX客戶端的響應流:

            C->S:客戶端返回選擇的認證方式:

            <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>

            可以看出,客戶端”無恥“的選擇了”匿名“--
            'ANONYMOUS'方式

            接下來的流程就是客戶端”無恥“的選擇了以匿名的方式登錄了服務器,然后再發送注冊請求,請求如下:

            <iq id='uid:4e69eccd:00006784' type='set' from='447e0585@zxl/447e0585' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>bbaxiao</username><password>123456</password><name>test2</name><email>163@gmail.com</email></query></iq> 

            我們看到,IQ節里包含“form”屬性,即客戶端匿名身份標識。

            注意,一個客戶端已經以一個身份(由服務器臨時分配的一個JID)登錄,建立了會話,在服務器上我們會看到這個會話,并且服務器發送心跳一直維護這個會話。這種情況下,這個客戶端再發送注冊請求(另一個身份)建立與服務器的連接是不被允許的。具體請參考XEP-0077(In-Band Registration):我們關注這兩段:

            If the entity cancels its registration with its "home" server (i.e., the server at which it has maintained its XMPP account), then the entity SHOULD NOT include a 'from' or 'to' address in the remove request the server SHOULD then return a <not-authorized/> stream error and terminate all active sessions for the entity. The server SHOULD perform the remove based on the bare JID <localpart@domain.tld> associated with the current session or connection over which it received the remove request. If the server is an instant messaging and presence server that conforms to XMPP IM [8], the server SHOULD also cancel all existing presence subscriptions related to that entity (as stored in the entity's roster). 
             
            If the entity cancels its registration with a service other than its home server, its home server MUST stamp a 'from' address on the remove request, which in accordance with XMPP Core will be the entity's full JID <localpart@domain.tld/resource>. The service MUST perform the remove based on the bare JID <localpart@domain.tld> portion of the 'from' address. 

            If the entity cancels its registration with its "home" server (i.e., the server at which it has maintained its XMPP account), then the entity SHOULD NOT include a 'from' or 'to' address in the remove request the server SHOULD then return a <not-authorized/> stream error and terminate all active sessions for the entity. The server SHOULD perform the remove based on the bare JID <localpart@domain.tld> associated with the current session or connection over which it received the remove request. If the server is an instant messaging and presence server that conforms to XMPP IM [8], the server SHOULD also cancel all existing presence subscriptions related to that entity (as stored in the entity's roster).  
              
            If the entity cancels its registration with a service other than its home server, its home server MUST stamp a 'from' address on the remove request, which in accordance with XMPP Core will be the entity's full JID <localpart@domain.tld/resource>. The service MUST perform the remove based on the bare JID <localpart@domain.tld> portion of the 'from' address.  

             

            意思是說注冊請求不能包含“from”屬性。

            正常的注冊流如下:

            <iq id='uid:4e69eccd:00003d6c' type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>bbaxiao</username><password>123456</password><name>test2</name><email>163@gmail.com</email></query></iq> 

            ---------------------------

            綜上所述,解決方案如下:

            一、關閉openFire的匿名登錄功能。^_^……

            二、禁止GLOOX匿名認證功能。

            file:client.cpp 
             
            fun: int Client::getSaslMechs( Tag* tag ) 
             
            line:423 
             
            //將423行注釋掉即可。 
            422:if( tag->hasChildWithCData( mech, "ANONYMOUS" ) ) 
            423      //mechs |= SaslMechAnonymous; 

            重新編譯生成DLL即可。

            三、手動設置GLOOX客戶端SASL認證機制

            在調用j->connect()之前設置SASL認證機制,比如設置為“DIGEST-MD5”


            j->setSASLMechanisms(SaslMechDigestMd5);

            這種方式的缺點是需要先確定服務器支持的認證機制。

            四、根據XEP-0077所述,即使其名登錄,注冊流只要不帶“from”屬性應該也可以。所以我們要處理發出的注冊流,去除“from”屬性重新發送注冊流即可。


            本文轉自:http://blog.csdn.net/abcpanpeng/article/details/7370974


            posted on 2014-08-28 17:59 王海光 閱讀(1549) 評論(0)  編輯 收藏 引用 所屬分類: Openfire&Gloox
            久久久精品国产亚洲成人满18免费网站| 精品久久香蕉国产线看观看亚洲| 久久久久亚洲AV成人网人人网站| 久久久精品久久久久久| 无码精品久久久天天影视| 欧美久久综合性欧美| 久久久久亚洲av成人网人人软件 | 久久精品国产亚洲7777| 亚洲色欲久久久久综合网| 色欲av伊人久久大香线蕉影院| 99精品久久久久久久婷婷| 无码超乳爆乳中文字幕久久| 久久国产精品国语对白| 久久国产高清字幕中文| 一本色道久久综合亚洲精品| 欧美久久一级内射wwwwww.| 久久99国产精一区二区三区| 亚洲欧美日韩久久精品第一区| 久久久久亚洲精品天堂久久久久久| 久久婷婷五月综合色奶水99啪| 久久久久亚洲av毛片大| 国产伊人久久| 久久91精品国产91久久小草| 精品少妇人妻av无码久久| 97久久国产露脸精品国产 | 亚洲AV日韩精品久久久久| 亚洲国产成人久久综合区| 久久久久久久国产免费看| 秋霞久久国产精品电影院| 国产一级做a爰片久久毛片| 久久天堂AV综合合色蜜桃网| 亚洲级αV无码毛片久久精品| 亚洲伊人久久综合中文成人网| 日本免费一区二区久久人人澡| 2021精品国产综合久久| 久久99国产精一区二区三区| 99久久精品国产综合一区| 久久免费香蕉视频| 国产精品中文久久久久久久| 一日本道伊人久久综合影| 精品伊人久久大线蕉色首页|