Software /
code /
prosody
Comparison
util/sasl_cyrus.lua @ 3549:395d5bb5266e
util.sasl, util.sasl_cyrus: Load mechanisms list early rather than lazily, as they are always loaded anyway.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 02 Nov 2010 18:04:56 +0500 |
parent | 3468:d50e2c937717 |
child | 3550:5e5d136d9de0 |
comparison
equal
deleted
inserted
replaced
3548:cd8d1cacc65b | 3549:395d5bb5266e |
---|---|
98 end | 98 end |
99 cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); | 99 cyrussasl.set_canon_cb(sasl_i.cyrus, c14n_cb); |
100 end | 100 end |
101 | 101 |
102 cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) | 102 cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff) |
103 local mechanisms = {}; | |
104 local cyrus_mechs = cyrussasl.listmech(sasl_i.cyrus, nil, "", " ", ""); | |
105 for w in s_gmatch(cyrus_mechs, "[^ ]+") do | |
106 mechanisms[w] = true; | |
107 end | |
108 sasl_i.mechs = mechanisms; | |
103 return setmetatable(sasl_i, method); | 109 return setmetatable(sasl_i, method); |
104 end | 110 end |
105 | 111 |
106 -- get a fresh clone with the same realm and service name | 112 -- get a fresh clone with the same realm and service name |
107 function method:clean_clone() | 113 function method:clean_clone() |
108 return new(self.realm, self.service_name) | 114 return new(self.realm, self.service_name) |
109 end | 115 end |
110 | 116 |
111 -- get a list of possible SASL mechanims to use | 117 -- get a list of possible SASL mechanims to use |
112 function method:mechanisms() | 118 function method:mechanisms() |
113 local mechanisms = self.mechs; | 119 return self.mechs; |
114 if not mechanisms then | |
115 mechanisms = {} | |
116 local cyrus_mechs = cyrussasl.listmech(self.cyrus, nil, "", " ", "") | |
117 for w in s_gmatch(cyrus_mechs, "[^ ]+") do | |
118 mechanisms[w] = true; | |
119 end | |
120 self.mechs = mechanisms | |
121 end | |
122 return mechanisms; | |
123 end | 120 end |
124 | 121 |
125 -- select a mechanism to use | 122 -- select a mechanism to use |
126 function method:select(mechanism) | 123 function method:select(mechanism) |
127 self.mechanism = mechanism; | 124 self.mechanism = mechanism; |