mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 11:00:38 +00:00
Refactor identity key store
This commit is contained in:
parent
afb22deada
commit
8a0c6cae15
19 changed files with 717 additions and 563 deletions
|
@ -8,11 +8,12 @@ import org.asamk.signal.PlainTextWriterImpl;
|
|||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.storage.protocol.IdentityInfo;
|
||||
import org.asamk.signal.manager.storage.identities.IdentityInfo;
|
||||
import org.asamk.signal.util.Hex;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -22,9 +23,10 @@ public class ListIdentitiesCommand implements LocalCommand {
|
|||
private final static Logger logger = LoggerFactory.getLogger(ListIdentitiesCommand.class);
|
||||
|
||||
private static void printIdentityFingerprint(PlainTextWriter writer, Manager m, IdentityInfo theirId) {
|
||||
var digits = Util.formatSafetyNumber(m.computeSafetyNumber(theirId.getAddress(), theirId.getIdentityKey()));
|
||||
final SignalServiceAddress address = m.resolveSignalServiceAddress(theirId.getRecipientId());
|
||||
var digits = Util.formatSafetyNumber(m.computeSafetyNumber(address, theirId.getIdentityKey()));
|
||||
writer.println("{}: {} Added: {} Fingerprint: {} Safety Number: {}",
|
||||
theirId.getAddress().getNumber().orNull(),
|
||||
address.getNumber().orNull(),
|
||||
theirId.getTrustLevel(),
|
||||
theirId.getDateAdded(),
|
||||
Hex.toString(theirId.getFingerprint()),
|
||||
|
|
|
@ -29,7 +29,12 @@ public class TrustCommand implements LocalCommand {
|
|||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||
var number = ns.getString("number");
|
||||
if (ns.getBoolean("trust_all_known_keys")) {
|
||||
var res = m.trustIdentityAllKeys(number);
|
||||
boolean res;
|
||||
try {
|
||||
res = m.trustIdentityAllKeys(number);
|
||||
} catch (InvalidNumberException e) {
|
||||
throw new UserErrorException("Failed to parse recipient: " + e.getMessage());
|
||||
}
|
||||
if (!res) {
|
||||
throw new UserErrorException("Failed to set the trust for this number, make sure the number is correct.");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue