get rid of payment required account state
This commit is contained in:
parent
7d34c894d0
commit
b5a47000c9
|
@ -1,15 +1,10 @@
|
|||
package im.conversations.android;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import im.conversations.android.xmpp.ConnectionPool;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
24
src/main/java/im/conversations/android/xmpp/Closables.java
Normal file
24
src/main/java/im/conversations/android/xmpp/Closables.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package im.conversations.android.xmpp;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class Closables {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Closables.class);
|
||||
|
||||
private Closables() {}
|
||||
|
||||
public static void close(final Closeable closeable) {
|
||||
if (closeable == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (final IOException e) {
|
||||
LOGGER.warn("Could not close closable", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,11 +21,9 @@ import com.google.common.util.concurrent.SettableFuture;
|
|||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.XmppDomainVerifier;
|
||||
import eu.siacs.conversations.persistance.FileBackend;
|
||||
import eu.siacs.conversations.services.MemorizingTrustManager;
|
||||
import eu.siacs.conversations.services.NotificationService;
|
||||
import eu.siacs.conversations.ui.util.PendingItem;
|
||||
import eu.siacs.conversations.utils.Patterns;
|
||||
import eu.siacs.conversations.utils.PhoneHelper;
|
||||
import eu.siacs.conversations.utils.Resolver;
|
||||
import eu.siacs.conversations.utils.SocksSocketFactory;
|
||||
|
@ -96,7 +94,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
|
@ -422,7 +419,7 @@ public class XmppConnection implements Runnable {
|
|||
}
|
||||
break; // successfully connected to server that speaks xmpp
|
||||
} else {
|
||||
FileBackend.close(localSocket);
|
||||
Closables.close(localSocket);
|
||||
throw new StateChangingException(ConnectionState.STREAM_OPENING_ERROR);
|
||||
}
|
||||
} catch (final StateChangingException e) {
|
||||
|
@ -895,24 +892,6 @@ public class XmppConnection implements Runnable {
|
|||
}
|
||||
if (failure.hasChild("temporary-auth-failure")) {
|
||||
throw new StateChangingException(ConnectionState.TEMPORARY_AUTH_FAILURE);
|
||||
} else if (failure.hasChild("account-disabled")) {
|
||||
final String text = failure.findChildContent("text");
|
||||
if (Strings.isNullOrEmpty(text)) {
|
||||
throw new StateChangingException(ConnectionState.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()));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
throw new StateChangingException(ConnectionState.UNAUTHORIZED);
|
||||
}
|
||||
if (url.isHttps()) {
|
||||
this.redirectionUrl = url;
|
||||
throw new StateChangingException(ConnectionState.PAYMENT_REQUIRED);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SaslMechanism.hashedToken(this.saslMechanism)) {
|
||||
Log.d(
|
||||
|
@ -1193,11 +1172,11 @@ public class XmppConnection implements Runnable {
|
|||
Log.d(
|
||||
Config.LOGTAG,
|
||||
account.address + ": TLS certificate domain verification failed");
|
||||
FileBackend.close(sslSocket);
|
||||
Closables.close(sslSocket);
|
||||
throw new StateChangingException(ConnectionState.TLS_ERROR_DOMAIN);
|
||||
}
|
||||
} catch (final SSLPeerUnverifiedException e) {
|
||||
FileBackend.close(sslSocket);
|
||||
Closables.close(sslSocket);
|
||||
throw new StateChangingException(ConnectionState.TLS_ERROR);
|
||||
}
|
||||
return sslSocket;
|
||||
|
@ -1978,8 +1957,8 @@ public class XmppConnection implements Runnable {
|
|||
}
|
||||
|
||||
private void forceCloseSocket() {
|
||||
FileBackend.close(this.socket);
|
||||
FileBackend.close(this.tagReader);
|
||||
Closables.close(this.socket);
|
||||
Closables.close(this.tagReader);
|
||||
}
|
||||
|
||||
public void interrupt() {
|
||||
|
@ -2025,7 +2004,7 @@ public class XmppConnection implements Runnable {
|
|||
+ e.getMessage()
|
||||
+ ")");
|
||||
} finally {
|
||||
FileBackend.close(currentSocket);
|
||||
Closables.close(currentSocket);
|
||||
}
|
||||
} else {
|
||||
forceCloseSocket();
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
package im.conversations.android.xmpp.sasl;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
import im.conversations.android.IDs;
|
||||
import im.conversations.android.database.model.Account;
|
||||
import im.conversations.android.database.model.Credential;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
public class DigestMd5 extends SaslMechanism {
|
||||
|
@ -71,14 +67,11 @@ public class DigestMd5 extends SaslMechanism {
|
|||
.getBytes(Charset.defaultCharset()));
|
||||
final String a2 = "AUTHENTICATE:" + digestUri;
|
||||
final String ha1 = bytesToHex(md.digest(a1));
|
||||
final String ha2 =
|
||||
bytesToHex(
|
||||
md.digest(a2.getBytes(Charset.defaultCharset())));
|
||||
final String ha2 = bytesToHex(md.digest(a2.getBytes(Charset.defaultCharset())));
|
||||
final String kd =
|
||||
ha1 + ":" + nonce + ":" + nonceCount + ":" + cNonce + ":auth:" + ha2;
|
||||
final String response =
|
||||
bytesToHex(
|
||||
md.digest(kd.getBytes(Charset.defaultCharset())));
|
||||
bytesToHex(md.digest(kd.getBytes(Charset.defaultCharset())));
|
||||
final String saslString =
|
||||
"username=\""
|
||||
+ account.address.getLocalpartOrThrow().toString()
|
||||
|
|
Loading…
Reference in a new issue