Software /
code /
prosody
Comparison
util/sasl_cyrus.lua @ 3428:8a12ae696687
util.sasl_cyrus: Cleanup.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 02 Aug 2010 18:54:16 +0500 |
parent | 3426:37b9b8e171b9 |
child | 3441:d4f89802cf1e |
comparison
equal
deleted
inserted
replaced
3427:046a8cf304dd | 3428:8a12ae696687 |
---|---|
85 end | 85 end |
86 end | 86 end |
87 | 87 |
88 -- create a new SASL object which can be used to authenticate clients | 88 -- create a new SASL object which can be used to authenticate clients |
89 function new(realm, service_name, app_name) | 89 function new(realm, service_name, app_name) |
90 local sasl_i = {}; | |
91 | 90 |
92 init(app_name or service_name); | 91 init(app_name or service_name); |
93 | 92 |
94 sasl_i.realm = realm; | |
95 sasl_i.service_name = service_name; | |
96 | |
97 local st, ret = pcall(cyrussasl.server_new, service_name, nil, realm, nil, nil) | 93 local st, ret = pcall(cyrussasl.server_new, service_name, nil, realm, nil, nil) |
98 if st then | 94 if not st then |
99 sasl_i.cyrus = ret; | |
100 else | |
101 log("error", "Creating SASL server connection failed: %s", ret); | 95 log("error", "Creating SASL server connection failed: %s", ret); |
102 return nil; | 96 return nil; |
103 end | 97 end |
98 | |
99 local sasl_i = { realm = realm, service_name = service_name, cyrus = ret }; | |
104 | 100 |
105 if cyrussasl.set_canon_cb then | 101 if cyrussasl.set_canon_cb then |
106 local c14n_cb = function (user) | 102 local c14n_cb = function (user) |
107 local node = s_match(user, "^([^@]+)"); | 103 local node = s_match(user, "^([^@]+)"); |
108 log("debug", "Canonicalizing username %s to %s", user, node) | 104 log("debug", "Canonicalizing username %s to %s", user, node) |
110 end | 106 end |
111 cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); | 107 cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); |
112 end | 108 end |
113 | 109 |
114 cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) | 110 cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) |
115 local s = setmetatable(sasl_i, method); | 111 return setmetatable(sasl_i, method); |
116 return s; | |
117 end | 112 end |
118 | 113 |
119 -- get a fresh clone with the same realm and service name | 114 -- get a fresh clone with the same realm and service name |
120 function method:clean_clone() | 115 function method:clean_clone() |
121 return new(self.realm, self.service_name) | 116 return new(self.realm, self.service_name) |