dojox/xmpp/sasl.js

  • Provides:

    • dojox.xmpp.sasl
  • Requires:

    • dojox.xmpp.util in common
    • dojo.AdapterRegistry in common in project dojo
    • dojox.encoding.digests.MD5 in common
  • dojox.xmpp.sasl._Base

    • type
      Function
    • parameters:
      • session: (typeof )
    • source: [view]
        this.session = session;


        this.startAuth();
    • summary
  • dojox.xmpp.sasl._Base.mechanism

    • summary
  • dojox.xmpp.sasl._Base.closeAuthTag

    • summary
  • dojox.xmpp.sasl._Base.startAuth

    • type
      Function
    • source: [view]
        var auth = new dojox.string.Builder(dojox.xmpp.util.createElement("auth", {
         xmlns: dojox.xmpp.sasl.saslNS,
         mechanism: this.mechanism
        }, this.closeAuthTag));
        this.appendToAuth(auth);
        this.session.dispatchPacket(auth.toString());
    • summary
  • dojox.xmpp.sasl._Base.appendToAuth

    • type
      Function
    • parameters:
      • auth: (typeof )
    • source: [view]
      }
    • summary
  • dojox.xmpp.sasl._Base.onChallenge

    • type
      Function
    • parameters:
      • msg: (typeof )
    • source: [view]
        if(!this.first_challenge){
         this.first_challenge = true;
         this.onFirstChallenge(msg);
        }else{
         this.onSecondChallenge(msg);
        }
    • summary
  • dojox.xmpp.sasl._Base.onFirstChallenge

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.xmpp.sasl._Base.onSecondChallenge

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.xmpp.sasl._Base.onSuccess

    • type
      Function
    • source: [view]
        this.session.sendRestart();
    • summary
  • dojox.xmpp.sasl._Base.first_challenge

    • summary
  • dojox.xmpp.sasl._Base.session

    • summary
  • dojox.xmpp.sasl.SunWebClientAuth

    • type
      Function
    • chains:
      • dojox.xmpp.sasl._Base: (prototype)
      • dojox.xmpp.sasl._Base: (call)
    • summary
  • dojox.xmpp.sasl.SunWebClientAuth.mechanism

    • summary
  • dojox.xmpp.sasl.Plain

    • type
      Function
    • chains:
      • dojox.xmpp.sasl._Base: (prototype)
      • dojox.xmpp.sasl._Base: (call)
    • summary
  • dojox.xmpp.sasl.Plain.mechanism

    • summary
  • dojox.xmpp.sasl.Plain.closeAuthTag

    • summary
  • dojox.xmpp.sasl.Plain.appendToAuth

    • type
      Function
    • parameters:
      • auth: (typeof )
    • source: [view]
        var id = this.session.jid;
        var index = this.session.jid.indexOf('@');
        if (index != -1){
         id = this.session.jid.substring(0, index);
        }
        var token = this.session.jid + '\u0000' + id + '\u0000' + this.session.password;
        token = dojox.xmpp.util.Base64.encode(token);


        auth.append(token);
        auth.append("");


        delete this.session.password;
    • summary
  • dojox.xmpp.sasl.DigestMD5

    • type
      Function
    • chains:
      • dojox.xmpp.sasl._Base: (prototype)
      • dojox.xmpp.sasl._Base: (call)
    • summary
  • dojox.xmpp.sasl.DigestMD5.mechanism

    • summary
  • dojox.xmpp.sasl.DigestMD5.onFirstChallenge

    • type
      Function
    • parameters:
      • msg: (typeof )
    • source: [view]
        var dxed = dojox.encoding.digests;
        var dxedo = dojox.encoding.digests.outputTypes;
        var HEX = function(n){
         return dxed.MD5(n, dxedo.Hex);
        };
        var H = function(s){
         return dxed.MD5(s, dxedo.String);
        };


        var ch_str = dojox.xmpp.util.Base64.decode(msg.firstChild.nodeValue);
        var ch = {
         realm: "",
         nonce: "",
         qop: "auth",
         maxbuf: 65536
        };
        ch_str.replace(/([a-z]+)=([^,]+)/g, function(t,k,v){
         v = v.replace(/^"(.+)"$/, "$1");
         ch[k] = v;
        });


        var A2_append = '';
        switch(ch.qop){
         case 'auth-int':
         case 'auth-conf':
          A2_append = ':00000000000000000000000000000000';
         case 'auth':
          break;
         default:
          return false;
        }
        var cnonce = dxed.MD5(Math.random() * 1234567890, dxedo.Hex);
        var digest_uri = 'xmpp/' + this.session.domain;


        var username = this.session.jid;
        var index = this.session.jid.indexOf('@');
        if (index != -1){
         username = this.session.jid.substring(0, index);
        }
        username = dojox.xmpp.util.encodeJid(username);


        var A1 = new dojox.string.Builder();
        A1.append(H(username + ':' + ch.realm + ':' + this.session.password),
         ':', ch.nonce + ':' + cnonce);
        delete this.session.password;
        var A2_rspauth = ':' + digest_uri + A2_append;
        var A2 = 'AUTHENTICATE' + A2_rspauth;


        var response_value = new dojox.string.Builder();
        response_value.append(HEX(A1.toString()), ':', ch.nonce, ':00000001:', cnonce, ':',
         ch.qop, ':')


        var ret = new dojox.string.Builder();
        ret.append('username="', username, '",',
         'realm="', ch.realm, '",',
         'nonce=', ch.nonce, ',',
         'cnonce="', cnonce, '",',
         'nc="00000001",qop="', ch.qop, '",digest-uri="', digest_uri, '",',
         'response="', HEX(response_value.toString() + HEX(A2)), '",charset="utf-8"');


        var response = new dojox.string.Builder(dojox.xmpp.util.createElement("response", {
         xmlns: dojox.xmpp.xmpp.SASL_NS
        }, false));
        response.append(dojox.xmpp.util.Base64.encode(ret.toString()));
        response.append('');


        this.rspauth = HEX(response_value.toString() + HEX(A2_rspauth));


        this.session.dispatchPacket(response.toString());
    • summary
  • dojox.xmpp.sasl.DigestMD5.onSecondChallenge

    • type
      Function
    • parameters:
      • msg: (typeof )
    • source: [view]
        var ch_str = dojox.xmpp.util.Base64.decode(msg.firstChild.nodeValue);


        if(this.rspauth == ch_str.substring(8)){
         var response = new dojox.string.Builder(dojox.xmpp.util.createElement("response", {
          xmlns: dojox.xmpp.xmpp.SASL_NS
         }, true));
         this.session.dispatchPacket(response.toString());
        }else{
         //FIXME
        }
    • summary
  • dojox.xmpp.sasl.DigestMD5.rspauth

    • summary
  • dojox.xmpp.sasl.saslNS

    • summary
  • dojox.xmpp.sasl.registry

    • summary
  • dojox.xmpp.sasl

    • type
      Object
    • summary
  • dojox.xmpp

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary