8 onWrite(stanza.stanza("challenge", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):text(challenge)) |
8 onWrite(stanza.stanza("challenge", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):text(challenge)) |
9 object.feed = function(self, stanza) |
9 object.feed = function(self, stanza) |
10 if (stanza.name ~= "response") then self.onFail() end |
10 if (stanza.name ~= "response") then self.onFail() end |
11 if (stanza.attr.xmlns ~= "urn:ietf:params:xml:ns:xmpp-sasl") then self.onFail() end |
11 if (stanza.attr.xmlns ~= "urn:ietf:params:xml:ns:xmpp-sasl") then self.onFail() end |
12 local response = base64.decode(stanza.tag[1]) |
12 local response = base64.decode(stanza.tag[1]) |
13 local authorization = string.match(response, [[([^&\0]+)]]) |
13 local authorization = string.match(response, "([^&\0]+)") |
14 local authentication = string.match(response, [[\0([^&\0]+)\0]]) |
14 local authentication = string.match(response, "\0([^&\0]+)\0") |
15 local password = string.match(response, [[\0[^&\0]+\0([^&\0]+)]]) |
15 local password = string.match(response, "\0[^&\0]+\0([^&\0]+)") |
16 if self.onAuth(authorization, password) == true then |
16 if self.onAuth(authorization, password) == true then |
17 self.onWrite(stanza.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"})) |
17 self.onWrite(stanza.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"})) |
18 self.onSuccess() |
18 self.onSuccess() |
19 else |
19 else |
20 self.onWrite(stanza.stanza("failure", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):tag("temporary-auth-failure")); |
20 self.onWrite(stanza.stanza("failure", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):tag("temporary-auth-failure")); |