From 30d5c08c3544369c2a8f9f53e0c64f97bc1515f4 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 16 Dec 2018 23:12:04 +0100 Subject: [PATCH] show accept button to confirm sasl downgrade. fixes #2498 --- .../conversations/ui/EditAccountActivity.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index a5fcc3423..ec6c4fe71 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -168,6 +168,15 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } return; } + + if (inNeedOfSaslAccept()) { + mAccount.setKey(Account.PINNED_MECHANISM_KEY, String.valueOf(-1)); + if (!xmppConnectionService.updateAccount(mAccount)) { + Toast.makeText(EditAccountActivity.this, R.string.unable_to_update_account, Toast.LENGTH_SHORT).show(); + } + return; + } + final boolean openRegistrationUrl = registerNewAccount && !accountInfoEdited && mAccount != null && mAccount.getStatus() == Account.State.REGISTRATION_WEB; final boolean openPaymentUrl = mAccount != null && mAccount.getStatus() == Account.State.PAYMENT_REQUIRED; final boolean redirectionWorthyStatus = openPaymentUrl || openRegistrationUrl; @@ -495,6 +504,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat URL url = connection != null && mAccount.getStatus() == Account.State.PAYMENT_REQUIRED ? connection.getRedirectionUrl() : null; if (url != null) { this.binding.saveButton.setText(R.string.open_website); + } else if (inNeedOfSaslAccept()) { + this.binding.saveButton.setText(R.string.accept); } else { this.binding.saveButton.setText(R.string.connect); } @@ -809,6 +820,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat return super.onOptionsItemSelected(item); } + private boolean inNeedOfSaslAccept() { + return mAccount != null && mAccount.getLastErrorStatus() == Account.State.DOWNGRADE_ATTACK && mAccount.getKeyAsInt(Account.PINNED_MECHANISM_KEY, -1) >= 0 && !accountInfoEdited(); + } + private void shareBarcode() { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, BarcodeProvider.getUriForAccount(this, mAccount)); @@ -1075,7 +1090,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } else { final TextInputLayout errorLayout; if (this.mAccount.errorStatus()) { - if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED) { + if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED || this.mAccount.getStatus() == Account.State.DOWNGRADE_ATTACK) { errorLayout = this.binding.accountPasswordLayout; } else if (mShowOptions && this.mAccount.getStatus() == Account.State.SERVER_NOT_FOUND