62 session.sasl_handler = nil; |
62 session.sasl_handler = nil; |
63 session:reset_stream(); |
63 session:reset_stream(); |
64 end |
64 end |
65 end |
65 end |
66 |
66 |
67 local function password_callback(node, host, mechanism, decoder) |
67 local function password_callback(node, hostname, realm, mechanism, decoder) |
68 local password = (datamanager_load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords |
68 local password = (datamanager_load(node, hostname, "accounts") or {}).password; -- FIXME handle hashed passwords |
69 local func = function(x) return x; end; |
69 local func = function(x) return x; end; |
70 if password then |
70 if password then |
71 if mechanism == "PLAIN" then |
71 if mechanism == "PLAIN" then |
72 return func, password; |
72 return func, password; |
73 elseif mechanism == "DIGEST-MD5" then |
73 elseif mechanism == "DIGEST-MD5" then |
74 if decoder then node, host, password = decoder(node), decoder(host), decoder(password); end |
74 if decoder then node, hostname, password = decoder(node), decoder(hostname), decoder(password); end |
75 return func, md5(node..":"..host..":"..password); |
75 return func, md5(node..":"..realm..":"..password); |
76 end |
76 end |
77 end |
77 end |
78 return func, nil; |
78 return func, nil; |
79 end |
79 end |
80 |
80 |