Comparison

util/sasl.lua @ 3442:8cfacc41099e

util.sasl: Simplified some code a bit.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 03 Aug 2010 18:19:45 +0500
parent 3441:d4f89802cf1e
child 3549:395d5bb5266e
comparison
equal deleted inserted replaced
3441:d4f89802cf1e 3442:8cfacc41099e
46 end 46 end
47 end 47 end
48 48
49 -- create a new SASL object which can be used to authenticate clients 49 -- create a new SASL object which can be used to authenticate clients
50 function new(realm, profile) 50 function new(realm, profile)
51 local sasl_i = {profile = profile}; 51 return setmetatable({ profile = profile, realm = realm }, method);
52 sasl_i.realm = realm;
53 return setmetatable(sasl_i, method);
54 end 52 end
55 53
56 -- get a fresh clone with the same realm and profile 54 -- get a fresh clone with the same realm and profile
57 function method:clean_clone() 55 function method:clean_clone()
58 return new(self.realm, self.profile) 56 return new(self.realm, self.profile)
90 --if message == "" or message == nil then return "failure", "malformed-request" end 88 --if message == "" or message == nil then return "failure", "malformed-request" end
91 return self.mech_i(self, message); 89 return self.mech_i(self, message);
92 end 90 end
93 91
94 -- load the mechanisms 92 -- load the mechanisms
95 local load_mechs = {"plain", "digest-md5", "anonymous", "scram"} 93 require "util.sasl.plain" .init(registerMechanism);
96 for _, mech in ipairs(load_mechs) do 94 require "util.sasl.digest-md5".init(registerMechanism);
97 local name = "util.sasl."..mech; 95 require "util.sasl.anonymous" .init(registerMechanism);
98 local m = require(name); 96 require "util.sasl.scram" .init(registerMechanism);
99 m.init(registerMechanism)
100 end
101 97
102 return _M; 98 return _M;