[Pkg-javascript-commits] [ltx] 26/469: SASL ANONYMOUS support

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:00:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit 8697a226dd67ee86b238be1739a8f9e9fea1b593
Author: Astro <astro at spaceboyz.net>
Date:   Sun May 30 23:18:31 2010 +0200

    SASL ANONYMOUS support
---
 lib/xmpp/client.js | 17 +++++------------
 lib/xmpp/sasl.js   | 23 +++++++++++++++++------
 2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/lib/xmpp/client.js b/lib/xmpp/client.js
index 2cb2e70..1e3e95f 100644
--- a/lib/xmpp/client.js
+++ b/lib/xmpp/client.js
@@ -136,10 +136,11 @@ Client.prototype.useFeatures = function() {
     if (this.state == STATE_PREAUTH &&
 	this.streamFeatures.getChild('mechanisms', NS_XMPP_SASL)) {
 	this.state = STATE_AUTH;
-	var mech = selectAuthMechanism(this.streamFeatures.
-				       getChild('mechanisms', NS_XMPP_SASL).
-				       getChildren('mechanism', NS_XMPP_SASL).
-				       map(function(el) { return el.getText(); }));
+	var mech = sasl.selectMechanism(
+		       this.streamFeatures.
+		       getChild('mechanisms', NS_XMPP_SASL).
+		       getChildren('mechanism', NS_XMPP_SASL).
+		       map(function(el) { return el.getText(); }));
 	if (mech) {
 	    mech.authzid = this.jid.bare().toString();
 	    mech.authcid = this.jid.user;
@@ -184,11 +185,3 @@ Client.prototype.useFeatures = function() {
     }
 };
 
-function selectAuthMechanism(mechs) {
-    /*if (mechs.indexOf("DIGEST-MD5") >= 0)
-       return "DIGEST-MD5";
-    else*/ if (mechs.indexOf("PLAIN") >= 0)
-       return new sasl.Mechanism("PLAIN");
-    else
-       return null;
-}
diff --git a/lib/xmpp/sasl.js b/lib/xmpp/sasl.js
index d215cc4..17bb1b4 100644
--- a/lib/xmpp/sasl.js
+++ b/lib/xmpp/sasl.js
@@ -1,16 +1,27 @@
-function Mechanism(name) {
-    this.name = name;
-    if (name == "PLAIN")
-	Plain.call(this);
+function selectMechanism(mechs) {
+    if (mechs.indexOf("ANONYMOUS") >= 0)
+	return new Anonymous();
+    /*if (mechs.indexOf("DIGEST-MD5") >= 0)
+       return "DIGEST-MD5";*/
+    else if (mechs.indexOf("PLAIN") >= 0)
+       return new Plain();
     else
-	throw("Unsupported mechanism: " + name);
+       return null;
 }
-exports.Mechanism = Mechanism;
+exports.selectMechanism = selectMechanism;
 
 function Plain() {
+    this.name = "PLAIN";
     this.auth = function() {
 	return this.authzid + "\0" +
 	    this.authcid + "\0" +
 	    this.password;
     };
 }
+
+function Anonymous() {
+    this.name = "ANONYMOUS";
+    this.auth = function() {
+	return this.authzid;
+    };
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list