diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2022-06-14 09:39:55 +0300 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2022-06-14 09:39:58 +0300 |
commit | a9dd5a3c7622c375b4f474514ec208ab0b4211cf (patch) | |
tree | eba7f584e4b0150aa9d10af2d07826ff3912264b | |
parent | d5ac6e35fcc62c886ae6cca1e58899eb1cb4f869 (diff) |
support sasl/temporary-auth-failure
if the server is unable to query the database throwing a temporary-auth-failure
might be more appropriate
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Account.java | 3 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 23 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 19 insertions, 8 deletions
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 @@ <string name="plain_text_document">Plain text document</string> <string name="account_registrations_are_not_supported">Account registrations are not supported</string> <string name="no_xmpp_adddress_found">No XMPP address found</string> + <string name="account_status_temporary_auth_failure">Temporary authentication failure</string> </resources> |