SASL: Minor cleanup.

Thu, 03 Jun 2010 17:48:50 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Thu, 03 Jun 2010 17:48:50 +0500
changeset 3176
c713fa2ba80c
parent 3175
104f05235cef
child 3177
89b64966f511

SASL: Minor cleanup.

util/sasl.lua file | annotate | diff | comparison | revisions
util/sasl/anonymous.lua file | annotate | diff | comparison | revisions
util/sasl/plain.lua file | annotate | diff | comparison | revisions
util/sasl/scram.lua file | annotate | diff | comparison | revisions
--- a/util/sasl.lua	Thu Jun 03 17:47:51 2010 +0500
+++ b/util/sasl.lua	Thu Jun 03 17:48:50 2010 +0500
@@ -108,11 +108,8 @@
 		return false;
 	end
 	
-	self.mech_i = mechanisms[mechanism]
-	if self.mech_i == nil then 
-		return false;
-	end
-	return true;
+	self.mech_i = mechanisms[mechanism];
+	return (self.mech_i ~= nil);
 end
 
 -- feed new messages to process into the library
--- a/util/sasl/anonymous.lua	Thu Jun 03 17:47:51 2010 +0500
+++ b/util/sasl/anonymous.lua	Thu Jun 03 17:48:50 2010 +0500
@@ -35,7 +35,7 @@
 	repeat
 		username = generate_uuid();
 	until self.profile.anonymous(username, self.realm);
-	self["username"] = username;
+	self.username = username;
 	return "success"
 end
 
--- a/util/sasl/plain.lua	Thu Jun 03 17:47:51 2010 +0500
+++ b/util/sasl/plain.lua	Thu Jun 03 17:48:50 2010 +0500
@@ -58,7 +58,7 @@
 	if self.profile.plain then
 		local correct_password;
 		correct_password, state = self.profile.plain(authentication, self.realm);
-		if correct_password == password then correct = true; else correct = false; end
+		correct = (correct_password == password);
 	elseif self.profile.plain_test then
 		correct, state = self.profile.plain_test(authentication, self.realm, password);
 	end
--- a/util/sasl/scram.lua	Thu Jun 03 17:47:51 2010 +0500
+++ b/util/sasl/scram.lua	Thu Jun 03 17:48:50 2010 +0500
@@ -93,10 +93,8 @@
 	return username;
 end
 
-local function hashprep( hashname ) 
-	local hash = hashname:lower()
-	hash = hash:gsub("-", "_")
-	return hash
+local function hashprep(hashname)
+	return hashname:lower():gsub("-", "_");
 end
 
 function saltedPasswordSHA1(password, salt, iteration_count)

mercurial