Software /
code /
prosody
Comparison
util/sasl_cyrus.lua @ 2393:1572be348f88
util.sasl_cyrus: Initializing Cyrus SASL library and a bit cleanup.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Tue, 22 Dec 2009 20:55:35 +0100 |
parent | 2392:8777831706d9 |
child | 2394:a2972f9fda6d |
comparison
equal
deleted
inserted
replaced
2392:8777831706d9 | 2393:1572be348f88 |
---|---|
29 local method = {}; | 29 local method = {}; |
30 method.__index = method; | 30 method.__index = method; |
31 local mechanisms = {}; | 31 local mechanisms = {}; |
32 local backend_mechanism = {}; | 32 local backend_mechanism = {}; |
33 | 33 |
34 -- register a new SASL mechanims | 34 pcall(cyrussasl.server_init, "prosody") |
35 local function registerMechanism(name, backends, f) | |
36 assert(type(name) == "string", "Parameter name MUST be a string."); | |
37 assert(type(backends) == "string" or type(backends) == "table", "Parameter backends MUST be either a string or a table."); | |
38 assert(type(f) == "function", "Parameter f MUST be a function."); | |
39 mechanisms[name] = f | |
40 for _, backend_name in ipairs(backends) do | |
41 if backend_mechanism[backend_name] == nil then backend_mechanism[backend_name] = {}; end | |
42 t_insert(backend_mechanism[backend_name], name); | |
43 end | |
44 end | |
45 | 35 |
46 -- create a new SASL object which can be used to authenticate clients | 36 -- create a new SASL object which can be used to authenticate clients |
47 function new(realm, service_name) | 37 function new(realm, service_name) |
48 local sasl_i = {}; | 38 local sasl_i = {}; |
49 sasl_i.realm = realm; | 39 sasl_i.realm = realm; |