small modifications for changing an account status in XmppConnection

This commit is contained in:
iNPUTmice 2014-11-15 20:54:28 +01:00
parent 69ab8a2adb
commit 5a634fdf47
1 changed files with 6 additions and 8 deletions

View File

@ -599,9 +599,9 @@ public class XmppConnection implements Runnable {
if (verifier != null if (verifier != null
&& !verifier.verify(account.getServer().getDomainpart(), && !verifier.verify(account.getServer().getDomainpart(),
sslSocket.getSession())) { sslSocket.getSession())) {
account.setStatus(Account.State.SECURITY_ERROR); Log.d(Config.LOGTAG,account.getJid().toBareJid()+": TLS certificate verification failed");
sslSocket.close(); disconnect(true);
throw new IOException("Host mismatch in TLS connection"); changeStatus(Account.State.SECURITY_ERROR);
} }
tagReader.setInputStream(sslSocket.getInputStream()); tagReader.setInputStream(sslSocket.getInputStream());
tagWriter.setOutputStream(sslSocket.getOutputStream()); tagWriter.setOutputStream(sslSocket.getOutputStream());
@ -653,12 +653,12 @@ public class XmppConnection implements Runnable {
") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) + ") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) +
"). Possible downgrade attack?"); "). Possible downgrade attack?");
disconnect(true); disconnect(true);
account.setStatus(Account.State.SECURITY_ERROR); changeStatus(Account.State.SECURITY_ERROR);
} }
} catch (final JSONException e) { } catch (final JSONException e) {
Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism"); Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism");
} }
Log.d(Config.LOGTAG, "Authenticating with " + saslMechanism.getMechanism()); Log.d(Config.LOGTAG,account.getJid().toString()+": Authenticating with " + saslMechanism.getMechanism());
auth.setAttribute("mechanism", saslMechanism.getMechanism()); auth.setAttribute("mechanism", saslMechanism.getMechanism());
if (!saslMechanism.getClientFirstMessage().isEmpty()) { if (!saslMechanism.getClientFirstMessage().isEmpty()) {
auth.setContent(saslMechanism.getClientFirstMessage()); auth.setContent(saslMechanism.getClientFirstMessage());
@ -673,10 +673,8 @@ public class XmppConnection implements Runnable {
} else if (this.streamFeatures.hasChild("bind") && shouldBind) { } else if (this.streamFeatures.hasChild("bind") && shouldBind) {
sendBindRequest(); sendBindRequest();
} else { } else {
account.setStatus(Account.State.INCOMPATIBLE_SERVER);
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": incompatible server. disconnecting");
disconnect(true); disconnect(true);
changeStatus(Account.State.INCOMPATIBLE_SERVER);
} }
} }