diff options
author | jorj <jorj@jorj.org> | 2009-12-23 16:46:49 -0500 |
---|---|---|
committer | jorj <jorj@jorj.org> | 2009-12-23 16:46:49 -0500 |
commit | 6a6004339d3085dd8da68de98852c9c08ae0d94d (patch) | |
tree | aec63d2bc0d34a831f7d2fbb33d90b91c1b942a1 /util/sasl_cyrus.lua | |
parent | ec61c983ac04f22ac0700c2c83c1b382d72b47fc (diff) | |
download | prosody-6a6004339d3085dd8da68de98852c9c08ae0d94d.tar.gz prosody-6a6004339d3085dd8da68de98852c9c08ae0d94d.zip |
first working version with Cyrus SASL support.
Diffstat (limited to 'util/sasl_cyrus.lua')
-rw-r--r-- | util/sasl_cyrus.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua index 9a81eb97..7e689f62 100644 --- a/util/sasl_cyrus.lua +++ b/util/sasl_cyrus.lua @@ -25,6 +25,7 @@ local keys = keys; local print = print local pcall = pcall +local s_match, s_gmatch = string.match, string.gmatch module "sasl_cyrus" @@ -38,7 +39,7 @@ function new(realm, service_name) local sasl_i = {}; sasl_i.realm = realm; sasl_i.service_name = service_name; - sasl_i.cyrus = cyrussasl.server_new(service_name, realm, realm, nil, nil) + sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil) if sasl_i.cyrus == 0 then log("error", "got NULL return value from server_new") return nil; @@ -62,7 +63,7 @@ end -- get a list of possible SASL mechanims to use function method:mechanisms() local mechanisms = {} - local cyrus_mechs = cyrussasl.listmech(self.cyrus) + local cyrus_mechs = cyrussasl.listmech(self.cyrus, nil, "", " ", "") for w in s_gmatch(cyrus_mechs, "%a+") do mechanisms[w] = true; end @@ -73,17 +74,18 @@ end -- select a mechanism to use function method:select(mechanism) self.mechanism = mechanism; - return not self.mechanisms[mechanisms]; + return self.mechanisms[mechanism]; end -- feed new messages to process into the library function method:process(message) local err; local data; + if self.mechanism then - err, data = cyrussasl.server_start(self.cyrus, self.mechanism, message) + err, data = cyrussasl.server_start(self.cyrus, self.mechanism, message or "") else - err, data = cyrussasl.server_step(self.cyrus, message) + err, data = cyrussasl.server_step(self.cyrus, message or "") end self.username = cyrussasl.get_username(self.cyrus) |