support sasl/temporary-auth-failure (Daniel Gultsch)

This commit is contained in:
Arne 2022-06-20 21:17:17 +02:00
parent 4b51ce3bc5
commit e0aed9e393
7 changed files with 21 additions and 11 deletions

View file

@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.2.1'
}
}

View file

@ -57,7 +57,7 @@ public final class Config {
public static final String LOGTAG = BuildConfig.LOGTAG;
public static final Jid BUG_REPORTS = Jid.of("support@monocles.de");
public static final Uri HELP = Uri.parse("https://monocles.de/howto");
public static final Uri HELP = Uri.parse("https://monocles.wiki");
public static final String inviteUserURL = "https://" + monocles() + "/i/";
public static final String inviteMUCURL = "https://" + monocles() + "/j/";

View file

@ -665,6 +665,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),

View file

@ -53,6 +53,7 @@ import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509KeyManager;
import javax.net.ssl.X509TrustManager;
import com.google.common.base.Strings;
import eu.siacs.conversations.BuildConfig;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@ -519,20 +520,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);

View file

@ -1176,4 +1176,6 @@
<string name="orbot_not_found">Orbot nicht gefunden</string>
<string name="participants">Teilnehmer</string>
<string name="download_failed_invalid_file">Download fehlgeschlagen: Ungültige Datei</string>
<string name="account_status_temporary_auth_failure">Temporärer Authentifizierungsfehler</string>
</resources>

View file

@ -119,7 +119,7 @@
</string-array>
<string-array name="support_site">
<item>https://monocles.de/howto/</item>
<item>https://monocles.wiki</item>
<item>https://www.jabber.de/support/</item>
<item>https://dismail.de/contact.html</item>
<item>https://www.draugr.de/kontakt/</item>

View file

@ -1203,4 +1203,5 @@
<string name="participants">Participants</string>
<string name="download_failed_invalid_file">Download failed: Invalid file</string>
<string name="orbot_not_found">Orbot not found</string>
<string name="account_status_temporary_auth_failure">Temporary authentication failure</string>
</resources>