diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index 37f8114e8..dc354adc4 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -627,6 +627,7 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable ONLINE(false), NO_INTERNET(false), UNAUTHORIZED, + TEMPORARY_AUTH_FAILURE, SERVER_NOT_FOUND, REGISTRATION_SUCCESSFUL(false), REGISTRATION_FAILED(true, false), @@ -732,6 +733,8 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable return R.string.payment_required; case MISSING_INTERNET_PERMISSION: return R.string.missing_internet_permission; + case TEMPORARY_AUTH_FAILURE: + return R.string.account_status_temporary_auth_failure; default: return R.string.account_status_unknown; } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index c3a3b1532..06195aaed 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -12,6 +12,8 @@ import android.util.SparseArray; import androidx.annotation.NonNull; +import com.google.common.base.Strings; + import org.xmlpull.v1.XmlPullParserException; import java.io.ByteArrayInputStream; @@ -489,20 +491,25 @@ public class XmppConnection implements Runnable { } else if (nextTag.isStart("failure")) { final Element failure = tagReader.readElement(nextTag); if (Namespace.SASL.equals(failure.getNamespace())) { - final String text = failure.findChildContent("text"); - if (failure.hasChild("account-disabled") && text != null) { - Matcher matcher = Patterns.AUTOLINK_WEB_URL.matcher(text); + if (failure.hasChild("temporary-auth-failure")) { + throw new StateChangingException(Account.State.TEMPORARY_AUTH_FAILURE); + } else if (failure.hasChild("account-disabled")) { + final String text = failure.findChildContent("text"); + if ( Strings.isNullOrEmpty(text)) { + throw new StateChangingException(Account.State.UNAUTHORIZED); + } + final Matcher matcher = Patterns.AUTOLINK_WEB_URL.matcher(text); if (matcher.find()) { final HttpUrl url; try { url = HttpUrl.get(text.substring(matcher.start(), matcher.end())); - if (url.isHttps()) { - this.redirectionUrl = url; - throw new StateChangingException(Account.State.PAYMENT_REQUIRED); - } - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { throw new StateChangingException(Account.State.UNAUTHORIZED); } + if (url.isHttps()) { + this.redirectionUrl = url; + throw new StateChangingException(Account.State.PAYMENT_REQUIRED); + } } } throw new StateChangingException(Account.State.UNAUTHORIZED); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 20c7cbef8..ee5cbce81 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -976,5 +976,6 @@ Plain text document Account registrations are not supported No XMPP address found + Temporary authentication failure