Commit a8b641be authored by Finn Herzfeld's avatar Finn Herzfeld 🌵

Add inbound indentity failure

parent 41002a77
Pipeline #4043 passed with stages
in 8 minutes and 18 seconds
......@@ -20,6 +20,7 @@ import io.finn.signald.clientprotocol.v1.JsonAddress;
import io.finn.signald.util.SafetyNumberHelper;
import org.asamk.signal.util.Hex;
import org.whispersystems.libsignal.IdentityKey;
import org.whispersystems.libsignal.UntrustedIdentityException;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
......@@ -37,4 +38,9 @@ class JsonUntrustedIdentityException {
this.safety_number = SafetyNumberHelper.computeSafetyNumber(m.getOwnAddress(), m.getIdentity(), this.address.getSignalServiceAddress(), key);
this.request = request;
}
public JsonUntrustedIdentityException(UntrustedIdentityException exception) {
this.number = new JsonAddress(exception.getName());
this.fingerprint = Hex.toStringCondensed(exception.getUntrustedIdentity().getPublicKey().serialize());
}
}
......@@ -79,19 +79,23 @@ class MessageReceiver implements Manager.ReceiveMessageHandler, Runnable {
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
String type = "message";
if(exception != null) {
logger.catching(exception);
type = "unreadable_message";
logger.catching(exception);
type = "unreadable_message";
}
try {
if(envelope != null) {
JsonMessageEnvelope message = new JsonMessageEnvelope(envelope, content, username);
this.sockets.broadcast(new JsonMessageWrapper(type, message, exception));
} else {
this.sockets.broadcast(new JsonMessageWrapper(type, null, exception));
}
if(exception instanceof org.whispersystems.libsignal.UntrustedIdentityException) {
JsonUntrustedIdentityException message = new JsonUntrustedIdentityException((org.whispersystems.libsignal.UntrustedIdentityException) exception);
this.sockets.broadcast(new JsonMessageWrapper("inbound_identity_failure", message, (Throwable)null));
}
if(envelope != null) {
JsonMessageEnvelope message = new JsonMessageEnvelope(envelope, content, username);
this.sockets.broadcast(new JsonMessageWrapper(type, message, exception));
} else {
this.sockets.broadcast(new JsonMessageWrapper(type, null, exception));
}
} catch (IOException | NoSuchAccountException e) {
logger.catching(e);
logger.catching(e);
}
}
}
......@@ -122,7 +122,7 @@ public class IdentityKeyStore implements org.whispersystems.libsignal.state.Iden
if(!id.identityKey.equals(identityKey)) {
continue;
}
if(id.trustLevel.compareTo(trustLevel) < 0) {
if(id.trustLevel != null && id.trustLevel.compareTo(trustLevel) < 0) {
id.trustLevel = trustLevel;
}
if(added != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment