aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-10-13 23:34:09 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-10-13 23:34:09 +0200
commit76828950ee6529a6da98af484507a48f992d9442 (patch)
treeb4ff1081b69ea4964066da29b3afda2c78b51516 /src/main/java/eu/siacs
parent8b44400940b67f53dbafef01f915c98821a6f1d0 (diff)
cleaned up some code. log last tag
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java22
1 files changed, 14 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 fc9c98122..999aecc9f 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -29,7 +29,6 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
-import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@@ -286,7 +285,7 @@ public class XmppConnection implements Runnable {
Tag nextTag;
while ((nextTag = tagReader.readTag()) != null) {
if (nextTag.isStart("stream")) {
- processStream(nextTag);
+ processStream();
break;
} else {
throw new IOException("unknown tag on connect");
@@ -338,11 +337,9 @@ public class XmppConnection implements Runnable {
connect();
}
- private void processStream(final Tag currentTag) throws XmlPullParserException,
- IOException, NoSuchAlgorithmException {
+ private void processStream() throws XmlPullParserException, IOException, NoSuchAlgorithmException {
Tag nextTag = tagReader.readTag();
-
- while ((nextTag != null) && (!nextTag.isEnd("stream"))) {
+ while (nextTag != null && !nextTag.isEnd("stream")) {
if (nextTag.isStart("error")) {
processStreamError(nextTag);
} else if (nextTag.isStart("features")) {
@@ -362,7 +359,11 @@ public class XmppConnection implements Runnable {
String.valueOf(saslMechanism.getPriority()));
tagReader.reset();
sendStartStream();
- processStream(tagReader.readTag());
+ if (tagReader.readTag().isStart("stream")) {
+ processStream();
+ } else {
+ throw new IOException("server didn't restart stream after successful auth");
+ }
break;
} else if (nextTag.isStart("failure")) {
throw new UnauthorizedException();
@@ -458,6 +459,7 @@ public class XmppConnection implements Runnable {
}
nextTag = tagReader.readTag();
}
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": last tag was "+nextTag);
if (account.getStatus() == Account.State.ONLINE) {
account. setStatus(Account.State.OFFLINE);
if (statusListener != null) {
@@ -644,7 +646,11 @@ public class XmppConnection implements Runnable {
sendStartStream();
Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
features.encryptionEnabled = true;
- processStream(tagReader.readTag());
+ if (tagReader.readTag().isStart("stream")) {
+ processStream();
+ } else {
+ throw new IOException("server didn't restart stream after STARTTLS");
+ }
sslSocket.close();
} catch (final NoSuchAlgorithmException | KeyManagementException e1) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": TLS certificate verification failed");