Commit 3d8faa45 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

1. Fixed retrieval of IQ elements (e.g. username, password, etc.)

2. Added a type attribute to probeResponse.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@629 b35dd754-fafc-0310-a699-88a17e54d16e
parent d6d4f91c
...@@ -66,6 +66,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo { ...@@ -66,6 +66,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
info = new IQHandlerInfo("query", "jabber:iq:auth"); info = new IQHandlerInfo("query", "jabber:iq:auth");
probeResponse = DocumentHelper.createElement(QName.get("query", "jabber:iq:auth")); probeResponse = DocumentHelper.createElement(QName.get("query", "jabber:iq:auth"));
probeResponse.addAttribute("type", "get");
probeResponse.add(DocumentHelper.createElement("username")); probeResponse.add(DocumentHelper.createElement("username"));
if (AuthFactory.isPlainSupported()) { if (AuthFactory.isPlainSupported()) {
probeResponse.add(DocumentHelper.createElement("password")); probeResponse.add(DocumentHelper.createElement("password"));
...@@ -83,9 +84,10 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo { ...@@ -83,9 +84,10 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
IQ response = null; IQ response = null;
try { try {
Element iq = packet.getElement(); Element iq = packet.getElement();
Element query = iq.element("query");
if (IQ.Type.get == packet.getType()) { if (IQ.Type.get == packet.getType()) {
String username = iq.element("username").getTextTrim(); String username = query.elementTextTrim("username");
probeResponse.element("username").setText(username); probeResponse.element("username").setText(username);
response = IQ.createResultIQ(new IQ(probeResponse)); response = IQ.createResultIQ(new IQ(probeResponse));
} }
...@@ -96,15 +98,12 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo { ...@@ -96,15 +98,12 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
response = anonymousLogin(session, packet); response = anonymousLogin(session, packet);
} }
else { else {
String username = iq.element("username").getTextTrim(); String username = query.elementTextTrim("username");
// Login authentication // Login authentication
String password = null; String password = query.elementTextTrim("password");
if (iq.element("password") != null) {
password = iq.element("password").getTextTrim();
}
String digest = null; String digest = null;
if (iq.element("digest") != null) { if (query.element("digest") != null) {
digest = iq.element("digest").getTextTrim().toLowerCase(); digest = query.elementTextTrim("digest").toLowerCase();
} }
// If we're already logged in, this is a password reset // If we're already logged in, this is a password reset
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment