17 if stanza.attr.xmlns ~= "urn:ietf:params:xml:ns:xmpp-sasl" then self.onFail("invalid-stanza-namespace") end |
17 if stanza.attr.xmlns ~= "urn:ietf:params:xml:ns:xmpp-sasl" then self.onFail("invalid-stanza-namespace") end |
18 local response = base64.decode(stanza[1]) |
18 local response = base64.decode(stanza[1]) |
19 local authorization = s_match(response, "([^&%z]+)") |
19 local authorization = s_match(response, "([^&%z]+)") |
20 local authentication = s_match(response, "%z([^&%z]+)%z") |
20 local authentication = s_match(response, "%z([^&%z]+)%z") |
21 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") |
21 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") |
22 if self.onAuth(authorization, password) == true then |
22 if self.onAuth(authentication, password) == true then |
23 self.onWrite(st.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"})) |
23 self.onWrite(st.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"})) |
24 self.onSuccess(authentication) |
24 self.onSuccess(authentication) |
25 else |
25 else |
26 self.onWrite(st.stanza("failure", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):tag("temporary-auth-failure")); |
26 self.onWrite(st.stanza("failure", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):tag("temporary-auth-failure")); |
27 end |
27 end |