show accept button to confirm sasl downgrade. fixes #2498

This commit is contained in:
Daniel Gultsch 2018-12-16 23:12:04 +01:00
parent 36e1d6d571
commit 30d5c08c35

View file

@ -168,6 +168,15 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} }
return; 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 openRegistrationUrl = registerNewAccount && !accountInfoEdited && mAccount != null && mAccount.getStatus() == Account.State.REGISTRATION_WEB;
final boolean openPaymentUrl = mAccount != null && mAccount.getStatus() == Account.State.PAYMENT_REQUIRED; final boolean openPaymentUrl = mAccount != null && mAccount.getStatus() == Account.State.PAYMENT_REQUIRED;
final boolean redirectionWorthyStatus = openPaymentUrl || openRegistrationUrl; 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; URL url = connection != null && mAccount.getStatus() == Account.State.PAYMENT_REQUIRED ? connection.getRedirectionUrl() : null;
if (url != null) { if (url != null) {
this.binding.saveButton.setText(R.string.open_website); this.binding.saveButton.setText(R.string.open_website);
} else if (inNeedOfSaslAccept()) {
this.binding.saveButton.setText(R.string.accept);
} else { } else {
this.binding.saveButton.setText(R.string.connect); this.binding.saveButton.setText(R.string.connect);
} }
@ -809,6 +820,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
return super.onOptionsItemSelected(item); 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() { private void shareBarcode() {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, BarcodeProvider.getUriForAccount(this, mAccount)); intent.putExtra(Intent.EXTRA_STREAM, BarcodeProvider.getUriForAccount(this, mAccount));
@ -1075,7 +1090,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} else { } else {
final TextInputLayout errorLayout; final TextInputLayout errorLayout;
if (this.mAccount.errorStatus()) { 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; errorLayout = this.binding.accountPasswordLayout;
} else if (mShowOptions } else if (mShowOptions
&& this.mAccount.getStatus() == Account.State.SERVER_NOT_FOUND && this.mAccount.getStatus() == Account.State.SERVER_NOT_FOUND