mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Move storage package to manager
This commit is contained in:
parent
9e6a353427
commit
b738f5740c
34 changed files with 148 additions and 141 deletions
|
@ -3,8 +3,8 @@ package org.asamk.signal;
|
|||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.groups.GroupId;
|
||||
import org.asamk.signal.manager.groups.GroupUtils;
|
||||
import org.asamk.signal.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.util.DateUtils;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.manager.storage.contacts.ContactInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
||||
import org.asamk.signal.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.storage.protocol.JsonIdentityKeyStore;
|
||||
import org.asamk.signal.manager.storage.protocol.IdentityInfo;
|
||||
import org.asamk.signal.util.Hex;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
|
||||
public class ListIdentitiesCommand implements LocalCommand {
|
||||
|
||||
private static void printIdentityFingerprint(Manager m, JsonIdentityKeyStore.Identity theirId) {
|
||||
private static void printIdentityFingerprint(Manager m, IdentityInfo theirId) {
|
||||
String digits = Util.formatSafetyNumber(m.computeSafetyNumber(theirId.getAddress(), theirId.getIdentityKey()));
|
||||
System.out.println(String.format("%s: %s Added: %s Fingerprint: %s Safety Number: %s",
|
||||
theirId.getAddress().getNumber().orNull(),
|
||||
|
@ -35,14 +35,14 @@ public class ListIdentitiesCommand implements LocalCommand {
|
|||
return 1;
|
||||
}
|
||||
if (ns.get("number") == null) {
|
||||
for (JsonIdentityKeyStore.Identity identity : m.getIdentities()) {
|
||||
for (IdentityInfo identity : m.getIdentities()) {
|
||||
printIdentityFingerprint(m, identity);
|
||||
}
|
||||
} else {
|
||||
String number = ns.getString("number");
|
||||
try {
|
||||
List<JsonIdentityKeyStore.Identity> identities = m.getIdentities(number);
|
||||
for (JsonIdentityKeyStore.Identity id : identities) {
|
||||
List<IdentityInfo> identities = m.getIdentities(number);
|
||||
for (IdentityInfo id : identities) {
|
||||
printIdentityFingerprint(m, id);
|
||||
}
|
||||
} catch (InvalidNumberException e) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.asamk.signal.manager.Manager;
|
|||
import org.asamk.signal.manager.groups.GroupId;
|
||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||
import org.asamk.signal.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.util.ErrorUtils;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.whispersystems.libsignal.util.Pair;
|
||||
|
|
|
@ -28,15 +28,15 @@ import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
|||
import org.asamk.signal.manager.helper.GroupHelper;
|
||||
import org.asamk.signal.manager.helper.ProfileHelper;
|
||||
import org.asamk.signal.manager.helper.UnidentifiedAccessHelper;
|
||||
import org.asamk.signal.storage.SignalAccount;
|
||||
import org.asamk.signal.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.storage.groups.GroupInfoV1;
|
||||
import org.asamk.signal.storage.groups.GroupInfoV2;
|
||||
import org.asamk.signal.storage.profiles.SignalProfile;
|
||||
import org.asamk.signal.storage.profiles.SignalProfileEntry;
|
||||
import org.asamk.signal.storage.protocol.JsonIdentityKeyStore;
|
||||
import org.asamk.signal.storage.stickers.Sticker;
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.asamk.signal.manager.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV1;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV2;
|
||||
import org.asamk.signal.manager.storage.profiles.SignalProfile;
|
||||
import org.asamk.signal.manager.storage.profiles.SignalProfileEntry;
|
||||
import org.asamk.signal.manager.storage.protocol.IdentityInfo;
|
||||
import org.asamk.signal.manager.storage.stickers.Sticker;
|
||||
import org.asamk.signal.util.IOUtils;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.signal.libsignal.metadata.InvalidMetadataMessageException;
|
||||
|
@ -2422,8 +2422,7 @@ public class Manager implements Closeable {
|
|||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos);
|
||||
for (ContactInfo record : account.getContactStore().getContacts()) {
|
||||
VerifiedMessage verifiedMessage = null;
|
||||
JsonIdentityKeyStore.Identity currentIdentity = account.getSignalProtocolStore()
|
||||
.getIdentity(record.getAddress());
|
||||
IdentityInfo currentIdentity = account.getSignalProtocolStore().getIdentity(record.getAddress());
|
||||
if (currentIdentity != null) {
|
||||
verifiedMessage = new VerifiedMessage(record.getAddress(),
|
||||
currentIdentity.getIdentityKey(),
|
||||
|
@ -2517,11 +2516,11 @@ public class Manager implements Closeable {
|
|||
return account.getGroupStore().getGroup(groupId);
|
||||
}
|
||||
|
||||
public List<JsonIdentityKeyStore.Identity> getIdentities() {
|
||||
public List<IdentityInfo> getIdentities() {
|
||||
return account.getSignalProtocolStore().getIdentities();
|
||||
}
|
||||
|
||||
public List<JsonIdentityKeyStore.Identity> getIdentities(String number) throws InvalidNumberException {
|
||||
public List<IdentityInfo> getIdentities(String number) throws InvalidNumberException {
|
||||
return account.getSignalProtocolStore().getIdentities(canonicalizeAndResolveSignalServiceAddress(number));
|
||||
}
|
||||
|
||||
|
@ -2533,11 +2532,11 @@ public class Manager implements Closeable {
|
|||
*/
|
||||
public boolean trustIdentityVerified(String name, byte[] fingerprint) throws InvalidNumberException {
|
||||
SignalServiceAddress address = canonicalizeAndResolveSignalServiceAddress(name);
|
||||
List<JsonIdentityKeyStore.Identity> ids = account.getSignalProtocolStore().getIdentities(address);
|
||||
List<IdentityInfo> ids = account.getSignalProtocolStore().getIdentities(address);
|
||||
if (ids == null) {
|
||||
return false;
|
||||
}
|
||||
for (JsonIdentityKeyStore.Identity id : ids) {
|
||||
for (IdentityInfo id : ids) {
|
||||
if (!Arrays.equals(id.getIdentityKey().serialize(), fingerprint)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2563,11 +2562,11 @@ public class Manager implements Closeable {
|
|||
*/
|
||||
public boolean trustIdentityVerifiedSafetyNumber(String name, String safetyNumber) throws InvalidNumberException {
|
||||
SignalServiceAddress address = canonicalizeAndResolveSignalServiceAddress(name);
|
||||
List<JsonIdentityKeyStore.Identity> ids = account.getSignalProtocolStore().getIdentities(address);
|
||||
List<IdentityInfo> ids = account.getSignalProtocolStore().getIdentities(address);
|
||||
if (ids == null) {
|
||||
return false;
|
||||
}
|
||||
for (JsonIdentityKeyStore.Identity id : ids) {
|
||||
for (IdentityInfo id : ids) {
|
||||
if (!safetyNumber.equals(computeSafetyNumber(address, id.getIdentityKey()))) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2592,11 +2591,11 @@ public class Manager implements Closeable {
|
|||
*/
|
||||
public boolean trustIdentityAllKeys(String name) {
|
||||
SignalServiceAddress address = resolveSignalServiceAddress(name);
|
||||
List<JsonIdentityKeyStore.Identity> ids = account.getSignalProtocolStore().getIdentities(address);
|
||||
List<IdentityInfo> ids = account.getSignalProtocolStore().getIdentities(address);
|
||||
if (ids == null) {
|
||||
return false;
|
||||
}
|
||||
for (JsonIdentityKeyStore.Identity id : ids) {
|
||||
for (IdentityInfo id : ids) {
|
||||
if (id.getTrustLevel() == TrustLevel.UNTRUSTED) {
|
||||
account.getSignalProtocolStore()
|
||||
.setIdentityTrustLevel(address, id.getIdentityKey(), TrustLevel.TRUSTED_UNVERIFIED);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.asamk.signal.manager;
|
||||
|
||||
import org.asamk.signal.storage.SignalAccount;
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.signal.zkgroup.InvalidInputException;
|
||||
import org.signal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.asamk.signal.manager.groups;
|
||||
|
||||
import org.asamk.signal.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.storage.groups.GroupInfoV1;
|
||||
import org.asamk.signal.storage.groups.GroupInfoV2;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV1;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV2;
|
||||
import org.signal.zkgroup.InvalidInputException;
|
||||
import org.signal.zkgroup.groups.GroupMasterKey;
|
||||
import org.signal.zkgroup.groups.GroupSecretParams;
|
||||
|
|
|
@ -5,8 +5,8 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
|||
import org.asamk.signal.manager.groups.GroupIdV2;
|
||||
import org.asamk.signal.manager.groups.GroupLinkPassword;
|
||||
import org.asamk.signal.manager.groups.GroupUtils;
|
||||
import org.asamk.signal.storage.groups.GroupInfoV2;
|
||||
import org.asamk.signal.storage.profiles.SignalProfile;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV2;
|
||||
import org.asamk.signal.manager.storage.profiles.SignalProfile;
|
||||
import org.asamk.signal.util.IOUtils;
|
||||
import org.signal.storageservice.protos.groups.AccessControl;
|
||||
import org.signal.storageservice.protos.groups.GroupChange;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.asamk.signal.manager.helper;
|
||||
|
||||
import org.asamk.signal.storage.profiles.SignalProfile;
|
||||
import org.asamk.signal.manager.storage.profiles.SignalProfile;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
public interface ProfileProvider {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.asamk.signal.manager.helper;
|
||||
|
||||
import org.asamk.signal.storage.profiles.SignalProfile;
|
||||
import org.asamk.signal.manager.storage.profiles.SignalProfile;
|
||||
import org.signal.libsignal.metadata.certificate.InvalidCertificateException;
|
||||
import org.signal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage;
|
||||
package org.asamk.signal.manager.storage;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
|
@ -11,20 +11,20 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
|||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import org.asamk.signal.manager.groups.GroupId;
|
||||
import org.asamk.signal.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.storage.contacts.JsonContactsStore;
|
||||
import org.asamk.signal.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.storage.groups.GroupInfoV1;
|
||||
import org.asamk.signal.storage.groups.JsonGroupStore;
|
||||
import org.asamk.signal.storage.profiles.ProfileStore;
|
||||
import org.asamk.signal.storage.protocol.JsonIdentityKeyStore;
|
||||
import org.asamk.signal.storage.protocol.JsonSignalProtocolStore;
|
||||
import org.asamk.signal.storage.protocol.RecipientStore;
|
||||
import org.asamk.signal.storage.protocol.SessionInfo;
|
||||
import org.asamk.signal.storage.protocol.SignalServiceAddressResolver;
|
||||
import org.asamk.signal.storage.stickers.StickerStore;
|
||||
import org.asamk.signal.storage.threads.LegacyJsonThreadStore;
|
||||
import org.asamk.signal.storage.threads.ThreadInfo;
|
||||
import org.asamk.signal.manager.storage.contacts.ContactInfo;
|
||||
import org.asamk.signal.manager.storage.contacts.JsonContactsStore;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfoV1;
|
||||
import org.asamk.signal.manager.storage.groups.JsonGroupStore;
|
||||
import org.asamk.signal.manager.storage.profiles.ProfileStore;
|
||||
import org.asamk.signal.manager.storage.protocol.IdentityInfo;
|
||||
import org.asamk.signal.manager.storage.protocol.JsonSignalProtocolStore;
|
||||
import org.asamk.signal.manager.storage.protocol.RecipientStore;
|
||||
import org.asamk.signal.manager.storage.protocol.SessionInfo;
|
||||
import org.asamk.signal.manager.storage.protocol.SignalServiceAddressResolver;
|
||||
import org.asamk.signal.manager.storage.stickers.StickerStore;
|
||||
import org.asamk.signal.manager.storage.threads.LegacyJsonThreadStore;
|
||||
import org.asamk.signal.manager.storage.threads.ThreadInfo;
|
||||
import org.asamk.signal.util.IOUtils;
|
||||
import org.asamk.signal.util.Util;
|
||||
import org.signal.zkgroup.InvalidInputException;
|
||||
|
@ -286,7 +286,7 @@ public class SignalAccount implements Closeable {
|
|||
session.address = recipientStore.resolveServiceAddress(session.address);
|
||||
}
|
||||
|
||||
for (JsonIdentityKeyStore.Identity identity : signalProtocolStore.getIdentities()) {
|
||||
for (IdentityInfo identity : signalProtocolStore.getIdentities()) {
|
||||
identity.setAddress(recipientStore.resolveServiceAddress(identity.getAddress()));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.contacts;
|
||||
package org.asamk.signal.manager.storage.contacts;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.contacts;
|
||||
package org.asamk.signal.manager.storage.contacts;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.groups;
|
||||
package org.asamk.signal.manager.storage.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.groups;
|
||||
package org.asamk.signal.manager.storage.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.groups;
|
||||
package org.asamk.signal.manager.storage.groups;
|
||||
|
||||
import org.asamk.signal.manager.groups.GroupIdV2;
|
||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.groups;
|
||||
package org.asamk.signal.manager.storage.groups;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.profiles;
|
||||
package org.asamk.signal.manager.storage.profiles;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.profiles;
|
||||
package org.asamk.signal.manager.storage.profiles;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.profiles;
|
||||
package org.asamk.signal.manager.storage.profiles;
|
||||
|
||||
import org.signal.zkgroup.profiles.ProfileKey;
|
||||
import org.signal.zkgroup.profiles.ProfileKeyCredential;
|
|
@ -0,0 +1,57 @@
|
|||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import org.asamk.signal.manager.TrustLevel;
|
||||
import org.whispersystems.libsignal.IdentityKey;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class IdentityInfo {
|
||||
|
||||
SignalServiceAddress address;
|
||||
IdentityKey identityKey;
|
||||
TrustLevel trustLevel;
|
||||
Date added;
|
||||
|
||||
public IdentityInfo(SignalServiceAddress address, IdentityKey identityKey, TrustLevel trustLevel) {
|
||||
this.address = address;
|
||||
this.identityKey = identityKey;
|
||||
this.trustLevel = trustLevel;
|
||||
this.added = new Date();
|
||||
}
|
||||
|
||||
IdentityInfo(SignalServiceAddress address, IdentityKey identityKey, TrustLevel trustLevel, Date added) {
|
||||
this.address = address;
|
||||
this.identityKey = identityKey;
|
||||
this.trustLevel = trustLevel;
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(final SignalServiceAddress address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
boolean isTrusted() {
|
||||
return trustLevel == TrustLevel.TRUSTED_UNVERIFIED || trustLevel == TrustLevel.TRUSTED_VERIFIED;
|
||||
}
|
||||
|
||||
public IdentityKey getIdentityKey() {
|
||||
return this.identityKey;
|
||||
}
|
||||
|
||||
public TrustLevel getTrustLevel() {
|
||||
return this.trustLevel;
|
||||
}
|
||||
|
||||
public Date getDateAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
public byte[] getFingerprint() {
|
||||
return identityKey.getPublicKey().serialize();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
|
@ -31,7 +31,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
|
||||
final static Logger logger = LoggerFactory.getLogger(JsonIdentityKeyStore.class);
|
||||
|
||||
private final List<Identity> identities = new ArrayList<>();
|
||||
private final List<IdentityInfo> identities = new ArrayList<>();
|
||||
|
||||
private final IdentityKeyPair identityKeyPair;
|
||||
private final int localRegistrationId;
|
||||
|
@ -85,7 +85,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
public boolean saveIdentity(
|
||||
SignalServiceAddress serviceAddress, IdentityKey identityKey, TrustLevel trustLevel, Date added
|
||||
) {
|
||||
for (Identity id : identities) {
|
||||
for (IdentityInfo id : identities) {
|
||||
if (!id.address.matches(serviceAddress) || !id.identityKey.equals(identityKey)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
return true;
|
||||
}
|
||||
|
||||
identities.add(new Identity(serviceAddress, identityKey, trustLevel, added != null ? added : new Date()));
|
||||
identities.add(new IdentityInfo(serviceAddress, identityKey, trustLevel, added != null ? added : new Date()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
public void setIdentityTrustLevel(
|
||||
SignalServiceAddress serviceAddress, IdentityKey identityKey, TrustLevel trustLevel
|
||||
) {
|
||||
for (Identity id : identities) {
|
||||
for (IdentityInfo id : identities) {
|
||||
if (!id.address.matches(serviceAddress) || !id.identityKey.equals(identityKey)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
return;
|
||||
}
|
||||
|
||||
identities.add(new Identity(serviceAddress, identityKey, trustLevel, new Date()));
|
||||
identities.add(new IdentityInfo(serviceAddress, identityKey, trustLevel, new Date()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,7 +132,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
SignalServiceAddress serviceAddress = resolveSignalServiceAddress(address.getName());
|
||||
boolean trustOnFirstUse = true;
|
||||
|
||||
for (Identity id : identities) {
|
||||
for (IdentityInfo id : identities) {
|
||||
if (!id.address.matches(serviceAddress)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -150,14 +150,14 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
@Override
|
||||
public IdentityKey getIdentity(SignalProtocolAddress address) {
|
||||
SignalServiceAddress serviceAddress = resolveSignalServiceAddress(address.getName());
|
||||
Identity identity = getIdentity(serviceAddress);
|
||||
IdentityInfo identity = getIdentity(serviceAddress);
|
||||
return identity == null ? null : identity.getIdentityKey();
|
||||
}
|
||||
|
||||
public Identity getIdentity(SignalServiceAddress serviceAddress) {
|
||||
public IdentityInfo getIdentity(SignalServiceAddress serviceAddress) {
|
||||
long maxDate = 0;
|
||||
Identity maxIdentity = null;
|
||||
for (Identity id : this.identities) {
|
||||
IdentityInfo maxIdentity = null;
|
||||
for (IdentityInfo id : this.identities) {
|
||||
if (!id.address.matches(serviceAddress)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -171,14 +171,14 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
return maxIdentity;
|
||||
}
|
||||
|
||||
public List<Identity> getIdentities() {
|
||||
public List<IdentityInfo> getIdentities() {
|
||||
// TODO deep copy
|
||||
return identities;
|
||||
}
|
||||
|
||||
public List<Identity> getIdentities(SignalServiceAddress serviceAddress) {
|
||||
List<Identity> identities = new ArrayList<>();
|
||||
for (Identity identity : this.identities) {
|
||||
public List<IdentityInfo> getIdentities(SignalServiceAddress serviceAddress) {
|
||||
List<IdentityInfo> identities = new ArrayList<>();
|
||||
for (IdentityInfo identity : this.identities) {
|
||||
if (identity.address.matches(serviceAddress)) {
|
||||
identities.add(identity);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
json.writeStringField("identityKey",
|
||||
Base64.encodeBytes(jsonIdentityKeyStore.getIdentityKeyPair().serialize()));
|
||||
json.writeArrayFieldStart("trustedKeys");
|
||||
for (Identity trustedKey : jsonIdentityKeyStore.identities) {
|
||||
for (IdentityInfo trustedKey : jsonIdentityKeyStore.identities) {
|
||||
json.writeStartObject();
|
||||
if (trustedKey.getAddress().getNumber().isPresent()) {
|
||||
json.writeStringField("name", trustedKey.getAddress().getNumber().get());
|
||||
|
@ -264,53 +264,4 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Identity {
|
||||
|
||||
SignalServiceAddress address;
|
||||
IdentityKey identityKey;
|
||||
TrustLevel trustLevel;
|
||||
Date added;
|
||||
|
||||
public Identity(SignalServiceAddress address, IdentityKey identityKey, TrustLevel trustLevel) {
|
||||
this.address = address;
|
||||
this.identityKey = identityKey;
|
||||
this.trustLevel = trustLevel;
|
||||
this.added = new Date();
|
||||
}
|
||||
|
||||
Identity(SignalServiceAddress address, IdentityKey identityKey, TrustLevel trustLevel, Date added) {
|
||||
this.address = address;
|
||||
this.identityKey = identityKey;
|
||||
this.trustLevel = trustLevel;
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(final SignalServiceAddress address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
boolean isTrusted() {
|
||||
return trustLevel == TrustLevel.TRUSTED_UNVERIFIED || trustLevel == TrustLevel.TRUSTED_VERIFIED;
|
||||
}
|
||||
|
||||
public IdentityKey getIdentityKey() {
|
||||
return this.identityKey;
|
||||
}
|
||||
|
||||
public TrustLevel getTrustLevel() {
|
||||
return this.trustLevel;
|
||||
}
|
||||
|
||||
public Date getDateAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
public byte[] getFingerprint() {
|
||||
return identityKey.getPublicKey().serialize();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
|
@ -91,11 +91,11 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
|||
identityKeyStore.setIdentityTrustLevel(serviceAddress, identityKey, trustLevel);
|
||||
}
|
||||
|
||||
public List<JsonIdentityKeyStore.Identity> getIdentities() {
|
||||
public List<IdentityInfo> getIdentities() {
|
||||
return identityKeyStore.getIdentities();
|
||||
}
|
||||
|
||||
public List<JsonIdentityKeyStore.Identity> getIdentities(SignalServiceAddress serviceAddress) {
|
||||
public List<IdentityInfo> getIdentities(SignalServiceAddress serviceAddress) {
|
||||
return identityKeyStore.getIdentities(serviceAddress);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
|||
return identityKeyStore.getIdentity(address);
|
||||
}
|
||||
|
||||
public JsonIdentityKeyStore.Identity getIdentity(SignalServiceAddress serviceAddress) {
|
||||
public IdentityInfo getIdentity(SignalServiceAddress serviceAddress) {
|
||||
return identityKeyStore.getIdentity(serviceAddress);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.protocol;
|
||||
package org.asamk.signal.manager.storage.protocol;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.stickers;
|
||||
package org.asamk.signal.manager.storage.stickers;
|
||||
|
||||
public class Sticker {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.stickers;
|
||||
package org.asamk.signal.manager.storage.stickers;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.threads;
|
||||
package org.asamk.signal.manager.storage.threads;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
@ -1,4 +1,4 @@
|
|||
package org.asamk.signal.storage.threads;
|
||||
package org.asamk.signal.manager.storage.threads;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue