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