Add json output listIdentities command

This commit is contained in:
AsamK 2021-08-21 18:37:51 +02:00
parent 70fc2381d3
commit 11c90fa032
5 changed files with 94 additions and 25 deletions

View file

@ -2664,14 +2664,22 @@ public class Manager implements Closeable {
}
}
public String computeSafetyNumber(
SignalServiceAddress theirAddress, IdentityKey theirIdentityKey
) {
return Utils.computeSafetyNumber(ServiceConfig.capabilities.isUuid(),
public String computeSafetyNumber(SignalServiceAddress theirAddress, IdentityKey theirIdentityKey) {
final var fingerprint = Utils.computeSafetyNumber(capabilities.isUuid(),
account.getSelfAddress(),
getIdentityKeyPair().getPublicKey(),
theirAddress,
theirIdentityKey);
return fingerprint == null ? null : fingerprint.getDisplayableFingerprint().getDisplayText();
}
public byte[] computeSafetyNumberForScanning(SignalServiceAddress theirAddress, IdentityKey theirIdentityKey) {
final var fingerprint = Utils.computeSafetyNumber(capabilities.isUuid(),
account.getSelfAddress(),
getIdentityKeyPair().getPublicKey(),
theirAddress,
theirIdentityKey);
return fingerprint == null ? null : fingerprint.getScannableFingerprint().getSerialized();
}
@Deprecated

View file

@ -1,6 +1,7 @@
package org.asamk.signal.manager.util;
import org.whispersystems.libsignal.IdentityKey;
import org.whispersystems.libsignal.fingerprint.Fingerprint;
import org.whispersystems.libsignal.fingerprint.NumericFingerprintGenerator;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.StreamDetails;
@ -36,7 +37,7 @@ public class Utils {
return new StreamDetails(stream, mime, size);
}
public static String computeSafetyNumber(
public static Fingerprint computeSafetyNumber(
boolean isUuidCapable,
SignalServiceAddress ownAddress,
IdentityKey ownIdentityKey,
@ -56,18 +57,17 @@ public class Utils {
// Version 1: E164 user
version = 1;
if (!ownAddress.getNumber().isPresent() || !theirAddress.getNumber().isPresent()) {
return "INVALID ID";
return null;
}
ownId = ownAddress.getNumber().get().getBytes();
theirId = theirAddress.getNumber().get().getBytes();
}
var fingerprint = new NumericFingerprintGenerator(5200).createFor(version,
return new NumericFingerprintGenerator(5200).createFor(version,
ownId,
ownIdentityKey,
theirId,
theirIdentityKey);
return fingerprint.getDisplayableFingerprint().getDisplayText();
}
public static SignalServiceAddress getSignalServiceAddressFromIdentifier(final String identifier) {