From c09d450db815f51802caf0ea761ee01617a4ad19 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Sat, 15 Nov 2014 11:19:42 -0500 Subject: Add security error status --- .../eu/siacs/conversations/entities/Account.java | 27 ++++++++++++---------- .../conversations/ui/adapter/AccountAdapter.java | 4 ++++ .../siacs/conversations/xmpp/XmppConnection.java | 3 ++- src/main/res/values/strings.xml | 1 + 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index ea6c0187..d5a316ab 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -42,17 +42,18 @@ public class Account extends AbstractEntity { public static final int OPTION_USECOMPRESSION = 3; public static enum State { - DISABLED, - OFFLINE, - CONNECTING, - ONLINE, - NO_INTERNET, + DISABLED, + OFFLINE, + CONNECTING, + ONLINE, + NO_INTERNET, UNAUTHORIZED(true), SERVER_NOT_FOUND(true), REGISTRATION_FAILED(true), REGISTRATION_CONFLICT(true), - REGISTRATION_SUCCESSFUL, - REGISTRATION_NOT_SUPPORTED(true); + REGISTRATION_SUCCESSFUL, + REGISTRATION_NOT_SUPPORTED(true), + SECURITY_ERROR(true); private boolean isError; @@ -92,6 +93,8 @@ public class Account extends AbstractEntity { return R.string.account_status_regis_success; case REGISTRATION_NOT_SUPPORTED: return R.string.account_status_regis_not_sup; + case SECURITY_ERROR: + return R.string.account_status_security_error; default: return R.string.account_status_unknown; } @@ -126,8 +129,8 @@ public class Account extends AbstractEntity { } public Account(final String uuid, final Jid jid, - final String password, final int options, final String rosterVersion, final String keys, - final String avatar) { + final String password, final int options, final String rosterVersion, final String keys, + final String avatar) { this.uuid = uuid; this.jid = jid; if (jid.isBareJid()) { @@ -293,7 +296,7 @@ public class Account extends AbstractEntity { if (this.otrFingerprint == null) { try { DSAPublicKey pubkey = (DSAPublicKey) this.otrEngine - .getPublicKey(); + .getPublicKey(); if (pubkey == null) { return null; } @@ -394,12 +397,12 @@ public class Account extends AbstractEntity { } public int getReadableStatusId() { - return this.getStatus().getReadableId(); + return this.getStatus().getReadableId(); } public void activateGracePeriod() { this.mEndGracePeriod = SystemClock.elapsedRealtime() - + (Config.CARBON_GRACE_PERIOD * 1000); + + (Config.CARBON_GRACE_PERIOD * 1000); } public void deactivateGracePeriod() { diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java index 25e0f99d..7404e161 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java @@ -92,6 +92,10 @@ public class AccountAdapter extends ArrayAdapter { R.string.account_status_regis_not_sup)); statusView.setTextColor(activity.getWarningTextColor()); break; + case SECURITY_ERROR: + statusView.setText(getContext().getString + (R.string.account_status_security_error)); + statusView.setTextColor(activity.getWarningTextColor()); default: statusView.setText(""); break; diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 16ef1b50..42a89610 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -649,7 +649,8 @@ public class XmppConnection implements Runnable { ") than pinned priority (" + keys.getInt(Account.PINNED_MECHANISM_KEY) + "). Possible downgrade attack?"); disconnect(true); - } + account.setStatus(Account.State.SECURITY_ERROR); + } } catch (final JSONException e) { Log.d(Config.LOGTAG, "Parse error while checking pinned auth mechanism"); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index e720101c..4a1ec675 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -141,6 +141,7 @@ Username already in use Registration completed Server does not support registration + Security error Plain text OTR OpenPGP -- cgit v1.2.3