Software /
code /
verse
Comparison
plugins/sasl.lua @ 197:7e98cf2c1d8d
plugins.*: Use verse.stanza() & co instead of require util.stanza
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 17 Mar 2011 18:33:52 +0100 |
parent | 147:c95b84ed366b |
child | 302:0c83cb476246 |
comparison
equal
deleted
inserted
replaced
196:eb9d69d3f0b5 | 197:7e98cf2c1d8d |
---|---|
1 local st = require "util.stanza"; | |
2 local base64 = require "mime".b64; | 1 local base64 = require "mime".b64; |
3 local xmlns_sasl = "urn:ietf:params:xml:ns:xmpp-sasl"; | 2 local xmlns_sasl = "urn:ietf:params:xml:ns:xmpp-sasl"; |
4 | 3 |
5 function verse.plugins.sasl(stream) | 4 function verse.plugins.sasl(stream) |
6 local function handle_features(features_stanza) | 5 local function handle_features(features_stanza) |
9 local initial_data = base64("\0"..stream.username.."\0"..stream.password); | 8 local initial_data = base64("\0"..stream.username.."\0"..stream.password); |
10 | 9 |
11 --stream.sasl_state, initial_data = sasl_new({"PLAIN"}, stream.username, stream.password, stream.jid); | 10 --stream.sasl_state, initial_data = sasl_new({"PLAIN"}, stream.username, stream.password, stream.jid); |
12 | 11 |
13 stream:debug("Selecting PLAIN mechanism..."); | 12 stream:debug("Selecting PLAIN mechanism..."); |
14 local auth_stanza = st.stanza("auth", { xmlns = xmlns_sasl, mechanism = "PLAIN" }); | 13 local auth_stanza = verse.stanza("auth", { xmlns = xmlns_sasl, mechanism = "PLAIN" }); |
15 if initial_data then | 14 if initial_data then |
16 auth_stanza:text(initial_data); | 15 auth_stanza:text(initial_data); |
17 end | 16 end |
18 stream:send(auth_stanza); | 17 stream:send(auth_stanza); |
19 return true; | 18 return true; |