-- get a list of possible SASL mechanims to use
function method:mechanisms()
- local mechanisms = {}
- local cyrus_mechs = cyrussasl.listmech(self.cyrus, nil, "", " ", "")
- for w in s_gmatch(cyrus_mechs, "[^ ]+") do
- mechanisms[w] = true;
+ local mechanisms = self.mechs;
+ if not mechanisms then
+ mechanisms = {}
+ local cyrus_mechs = cyrussasl.listmech(self.cyrus, nil, "", " ", "")
+ for w in s_gmatch(cyrus_mechs, "[^ ]+") do
+ mechanisms[w] = true;
+ end
+ self.mechs = mechanisms
end
- self.mechs = mechanisms
- return array.collect(keys(mechanisms));
+ return mechanisms;
end
-- select a mechanism to use
function method:select(mechanism)
self.mechanism = mechanism;
- if not self.mechs then self:mechanisms(); end
- return self.mechs[mechanism];
+ return self:mechanisms()[mechanism];
end
-- feed new messages to process into the library
log("debug", "SASL mechanism not available from remote end")
return "failure", "invalid-mechanism", "SASL mechanism not available"
elseif (err == -13) then -- SASL_BADAUTH
- return "failure", "not-authorized", cyrussasl.get_message( self.cyrus )
+ return "failure", "not-authorized", sasl_errstring[err];
else
- log("debug", "Got SASL error condition %d: %s", err, cyrussasl.get_message( self.cyrus ))
- return "failure", "undefined-condition", cyrussasl.get_message( self.cyrus )
+ log("debug", "Got SASL error condition %d: %s", err, sasl_errstring[err]);
+ return "failure", "undefined-condition", sasl_errstring[err];
end
end