diff options
author | Sam Whited <sam@samwhited.com> | 2014-11-15 08:48:40 -0500 |
---|---|---|
committer | Sam Whited <sam@samwhited.com> | 2014-11-15 08:49:00 -0500 |
commit | 4b5d6f5b4fd29a4ee6d469f3b540dc5ba826f1a3 (patch) | |
tree | b65f5d7b6e0861182be4774976d3601a46416bcc /src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | |
parent | 0e550789d372a1a83caa432e93a4f969a0607c9a (diff) |
Improve auth error handling and state machine
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 899ebf562..c34a08a84 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -39,7 +39,6 @@ import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import eu.siacs.conversations.Config; -import eu.siacs.conversations.crypto.sasl.AuthenticationException; import eu.siacs.conversations.crypto.sasl.DigestMd5; import eu.siacs.conversations.crypto.sasl.Plain; import eu.siacs.conversations.crypto.sasl.SaslMechanism; @@ -284,14 +283,14 @@ public class XmppConnection implements Runnable { } else if (nextTag.isStart("compressed")) { switchOverToZLib(nextTag); } else if (nextTag.isStart("success")) { - Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": logged in"); final String challenge = tagReader.readElement(nextTag).getContent(); try { saslMechanism.getResponse(challenge); - } catch (final AuthenticationException e) { + } catch (final SaslMechanism.AuthenticationException e) { disconnect(true); Log.e(Config.LOGTAG, String.valueOf(e)); } + Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": logged in"); tagReader.reset(); sendStartStream(); processStream(tagReader.readTag()); @@ -306,7 +305,7 @@ public class XmppConnection implements Runnable { "urn:ietf:params:xml:ns:xmpp-sasl"); try { response.setContent(saslMechanism.getResponse(challenge)); - } catch (final AuthenticationException e) { + } catch (final SaslMechanism.AuthenticationException e) { // TODO: Send auth abort tag. Log.e(Config.LOGTAG, e.toString()); } @@ -643,10 +642,10 @@ public class XmppConnection implements Runnable { saslMechanism = new Plain(tagWriter, account); auth.setAttribute("mechanism", Plain.getMechanism()); } - if (!saslMechanism.getClientFirstMessage().isEmpty()) { - auth.setContent(saslMechanism.getClientFirstMessage()); - } - tagWriter.writeElement(auth); + if (!saslMechanism.getClientFirstMessage().isEmpty()) { + auth.setContent(saslMechanism.getClientFirstMessage()); + } + tagWriter.writeElement(auth); } else if (this.streamFeatures.hasChild("sm", "urn:xmpp:sm:" + smVersion) && streamId != null) { |