26 |
26 |
27 module "digest-md5" |
27 module "digest-md5" |
28 |
28 |
29 --========================= |
29 --========================= |
30 --SASL DIGEST-MD5 according to RFC 2831 |
30 --SASL DIGEST-MD5 according to RFC 2831 |
31 local function digest_response() |
|
32 |
|
33 return response, A1, A2 |
|
34 end |
|
35 |
31 |
36 local function digest(self, message) |
32 local function digest(self, message) |
37 --TODO complete support for authzid |
33 --TODO complete support for authzid |
38 |
34 |
39 local function serialize(message) |
35 local function serialize(message) |
172 self.username = response["username"]; |
168 self.username = response["username"]; |
173 if self.profile.plain then |
169 if self.profile.plain then |
174 local password, state = self.profile.plain(response["username"], self.realm) |
170 local password, state = self.profile.plain(response["username"], self.realm) |
175 if state == nil then return "failure", "not-authorized" |
171 if state == nil then return "failure", "not-authorized" |
176 elseif state == false then return "failure", "account-disabled" end |
172 elseif state == false then return "failure", "account-disabled" end |
177 Y = md5(response["username"]..":"..response["realm"]..":"..password); |
173 local Y = md5(response["username"]..":"..response["realm"]..":"..password); |
178 elseif self.profile["digest-md5"] then |
174 elseif self.profile["digest-md5"] then |
179 local Y, state = self.profile["digest-md5"](response["username"], self.realm, response["realm"], response["charset"]) |
175 local Y, state = self.profile["digest-md5"](response["username"], self.realm, response["realm"], response["charset"]) |
180 if state == nil then return "failure", "not-authorized" |
176 if state == nil then return "failure", "not-authorized" |
181 elseif state == false then return "failure", "account-disabled" end |
177 elseif state == false then return "failure", "account-disabled" end |
182 elseif self.profile["digest-md5-test"] then |
178 elseif self.profile["digest-md5-test"] then |