mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update signal-service-java
This commit is contained in:
parent
630803c3d1
commit
40fc712581
9 changed files with 46 additions and 44 deletions
|
@ -14,7 +14,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api("com.github.turasa:signal-service-java:2.15.3_unofficial_18")
|
api("com.github.turasa:signal-service-java:2.15.3_unofficial_19")
|
||||||
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
implementation("com.google.protobuf:protobuf-javalite:3.10.0")
|
||||||
implementation("org.bouncycastle:bcprov-jdk15on:1.68")
|
implementation("org.bouncycastle:bcprov-jdk15on:1.68")
|
||||||
implementation("org.slf4j:slf4j-api:1.7.30")
|
implementation("org.slf4j:slf4j-api:1.7.30")
|
||||||
|
|
|
@ -76,7 +76,6 @@ import org.whispersystems.libsignal.IdentityKey;
|
||||||
import org.whispersystems.libsignal.IdentityKeyPair;
|
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||||
import org.whispersystems.libsignal.InvalidKeyException;
|
import org.whispersystems.libsignal.InvalidKeyException;
|
||||||
import org.whispersystems.libsignal.InvalidMessageException;
|
import org.whispersystems.libsignal.InvalidMessageException;
|
||||||
import org.whispersystems.libsignal.InvalidVersionException;
|
|
||||||
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||||
|
@ -219,7 +218,6 @@ public class Manager implements Closeable {
|
||||||
new DynamicCredentialsProvider(account.getUuid(),
|
new DynamicCredentialsProvider(account.getUuid(),
|
||||||
account.getUsername(),
|
account.getUsername(),
|
||||||
account.getPassword(),
|
account.getPassword(),
|
||||||
account.getSignalingKey(),
|
|
||||||
account.getDeviceId()),
|
account.getDeviceId()),
|
||||||
userAgent,
|
userAgent,
|
||||||
groupsV2Operations,
|
groupsV2Operations,
|
||||||
|
@ -242,7 +240,6 @@ public class Manager implements Closeable {
|
||||||
account.getUsername(),
|
account.getUsername(),
|
||||||
account.getPassword(),
|
account.getPassword(),
|
||||||
account.getDeviceId(),
|
account.getDeviceId(),
|
||||||
account.getSignalingKey(),
|
|
||||||
userAgent,
|
userAgent,
|
||||||
null,
|
null,
|
||||||
timer,
|
timer,
|
||||||
|
@ -352,7 +349,7 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAccountAttributes() throws IOException {
|
public void updateAccountAttributes() throws IOException {
|
||||||
accountManager.setAccountAttributes(account.getSignalingKey(),
|
accountManager.setAccountAttributes(null,
|
||||||
account.getSignalProtocolStore().getLocalRegistrationId(),
|
account.getSignalProtocolStore().getLocalRegistrationId(),
|
||||||
true,
|
true,
|
||||||
// set legacy pin only if no KBS master key is set
|
// set legacy pin only if no KBS master key is set
|
||||||
|
@ -1747,9 +1744,6 @@ public class Manager implements Closeable {
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
if (returnOnTimeout) return;
|
if (returnOnTimeout) return;
|
||||||
continue;
|
continue;
|
||||||
} catch (InvalidVersionException e) {
|
|
||||||
logger.warn("Error while receiving messages, ignoring: {}", e.getMessage());
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (envelope.hasSource()) {
|
if (envelope.hasSource()) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ProvisioningManager {
|
||||||
groupsV2Operations = null;
|
groupsV2Operations = null;
|
||||||
}
|
}
|
||||||
accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(),
|
accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(),
|
||||||
new DynamicCredentialsProvider(null, null, password, null, SignalServiceAddress.DEFAULT_DEVICE_ID),
|
new DynamicCredentialsProvider(null, null, password, SignalServiceAddress.DEFAULT_DEVICE_ID),
|
||||||
userAgent,
|
userAgent,
|
||||||
groupsV2Operations,
|
groupsV2Operations,
|
||||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY,
|
ServiceConfig.AUTOMATIC_NETWORK_RETRY,
|
||||||
|
@ -95,10 +95,8 @@ public class ProvisioningManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String finishDeviceLink(String deviceName) throws IOException, InvalidKeyException, TimeoutException, UserAlreadyExists {
|
public String finishDeviceLink(String deviceName) throws IOException, InvalidKeyException, TimeoutException, UserAlreadyExists {
|
||||||
String signalingKey = KeyUtils.createSignalingKey();
|
|
||||||
SignalServiceAccountManager.NewDeviceRegistrationReturn ret = accountManager.finishNewDeviceRegistration(
|
SignalServiceAccountManager.NewDeviceRegistrationReturn ret = accountManager.finishNewDeviceRegistration(
|
||||||
identityKey,
|
identityKey,
|
||||||
signalingKey,
|
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
registrationId,
|
registrationId,
|
||||||
|
@ -130,7 +128,6 @@ public class ProvisioningManager {
|
||||||
ret.getDeviceId(),
|
ret.getDeviceId(),
|
||||||
ret.getIdentity(),
|
ret.getIdentity(),
|
||||||
registrationId,
|
registrationId,
|
||||||
signalingKey,
|
|
||||||
profileKey)) {
|
profileKey)) {
|
||||||
account.save();
|
account.save();
|
||||||
|
|
||||||
|
|
|
@ -77,11 +77,7 @@ public class RegistrationManager implements Closeable {
|
||||||
this.accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(),
|
this.accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(),
|
||||||
new DynamicCredentialsProvider(
|
new DynamicCredentialsProvider(
|
||||||
// Using empty UUID, because registering doesn't work otherwise
|
// Using empty UUID, because registering doesn't work otherwise
|
||||||
null,
|
null, account.getUsername(), account.getPassword(), SignalServiceAddress.DEFAULT_DEVICE_ID),
|
||||||
account.getUsername(),
|
|
||||||
account.getPassword(),
|
|
||||||
account.getSignalingKey(),
|
|
||||||
SignalServiceAddress.DEFAULT_DEVICE_ID),
|
|
||||||
userAgent,
|
userAgent,
|
||||||
groupsV2Operations,
|
groupsV2Operations,
|
||||||
ServiceConfig.AUTOMATIC_NETWORK_RETRY,
|
ServiceConfig.AUTOMATIC_NETWORK_RETRY,
|
||||||
|
@ -142,9 +138,6 @@ public class RegistrationManager implements Closeable {
|
||||||
String verificationCode, String pin
|
String verificationCode, String pin
|
||||||
) throws IOException, KeyBackupSystemNoDataException, KeyBackupServicePinException {
|
) throws IOException, KeyBackupSystemNoDataException, KeyBackupServicePinException {
|
||||||
verificationCode = verificationCode.replace("-", "");
|
verificationCode = verificationCode.replace("-", "");
|
||||||
if (account.getSignalingKey() == null) {
|
|
||||||
account.setSignalingKey(KeyUtils.createSignalingKey());
|
|
||||||
}
|
|
||||||
VerifyAccountResponse response;
|
VerifyAccountResponse response;
|
||||||
try {
|
try {
|
||||||
response = verifyAccountWithCode(verificationCode, pin, null);
|
response = verifyAccountWithCode(verificationCode, pin, null);
|
||||||
|
@ -176,6 +169,7 @@ public class RegistrationManager implements Closeable {
|
||||||
account.setRegistered(true);
|
account.setRegistered(true);
|
||||||
account.setUuid(UuidUtil.parseOrNull(response.getUuid()));
|
account.setUuid(UuidUtil.parseOrNull(response.getUuid()));
|
||||||
account.setRegistrationLockPin(pin);
|
account.setRegistrationLockPin(pin);
|
||||||
|
account.getSignalProtocolStore().archiveAllSessions();
|
||||||
account.getSignalProtocolStore()
|
account.getSignalProtocolStore()
|
||||||
.saveIdentity(account.getSelfAddress(),
|
.saveIdentity(account.getSelfAddress(),
|
||||||
account.getSignalProtocolStore().getIdentityKeyPair().getPublicKey(),
|
account.getSignalProtocolStore().getIdentityKeyPair().getPublicKey(),
|
||||||
|
@ -195,7 +189,7 @@ public class RegistrationManager implements Closeable {
|
||||||
final String verificationCode, final String legacyPin, final String registrationLock
|
final String verificationCode, final String legacyPin, final String registrationLock
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
return accountManager.verifyAccountWithCode(verificationCode,
|
return accountManager.verifyAccountWithCode(verificationCode,
|
||||||
account.getSignalingKey(),
|
null,
|
||||||
account.getSignalProtocolStore().getLocalRegistrationId(),
|
account.getSignalProtocolStore().getLocalRegistrationId(),
|
||||||
true,
|
true,
|
||||||
legacyPin,
|
legacyPin,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.whispersystems.signalservice.api.push.TrustStore;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl;
|
||||||
|
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalStorageUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalStorageUrl;
|
||||||
|
@ -40,6 +41,7 @@ class LiveConfig {
|
||||||
private final static TrustStore TRUST_STORE = new WhisperTrustStore();
|
private final static TrustStore TRUST_STORE = new WhisperTrustStore();
|
||||||
|
|
||||||
private final static Optional<Dns> dns = Optional.absent();
|
private final static Optional<Dns> dns = Optional.absent();
|
||||||
|
private final static Optional<SignalProxy> proxy = Optional.absent();
|
||||||
|
|
||||||
private final static byte[] zkGroupServerPublicParams = Base64.getDecoder()
|
private final static byte[] zkGroupServerPublicParams = Base64.getDecoder()
|
||||||
.decode("AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X0=");
|
.decode("AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X0=");
|
||||||
|
@ -58,6 +60,7 @@ class LiveConfig {
|
||||||
new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
|
new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
|
||||||
interceptors,
|
interceptors,
|
||||||
dns,
|
dns,
|
||||||
|
proxy,
|
||||||
zkGroupServerPublicParams);
|
zkGroupServerPublicParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.whispersystems.signalservice.api.push.TrustStore;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl;
|
||||||
|
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalStorageUrl;
|
import org.whispersystems.signalservice.internal.configuration.SignalStorageUrl;
|
||||||
|
@ -40,6 +41,7 @@ class SandboxConfig {
|
||||||
private final static TrustStore TRUST_STORE = new WhisperTrustStore();
|
private final static TrustStore TRUST_STORE = new WhisperTrustStore();
|
||||||
|
|
||||||
private final static Optional<Dns> dns = Optional.absent();
|
private final static Optional<Dns> dns = Optional.absent();
|
||||||
|
private final static Optional<SignalProxy> proxy = Optional.absent();
|
||||||
|
|
||||||
private final static byte[] zkGroupServerPublicParams = Base64.getDecoder()
|
private final static byte[] zkGroupServerPublicParams = Base64.getDecoder()
|
||||||
.decode("ABSY21VckQcbSXVNCGRYJcfWHiAMZmpTtTELcDmxgdFbtp/bWsSxZdMKzfCp8rvIs8ocCU3B37fT3r4Mi5qAemeGeR2X+/YmOGR5ofui7tD5mDQfstAI9i+4WpMtIe8KC3wU5w3Inq3uNWVmoGtpKndsNfwJrCg0Hd9zmObhypUnSkfYn2ooMOOnBpfdanRtrvetZUayDMSC5iSRcXKpdls=");
|
.decode("ABSY21VckQcbSXVNCGRYJcfWHiAMZmpTtTELcDmxgdFbtp/bWsSxZdMKzfCp8rvIs8ocCU3B37fT3r4Mi5qAemeGeR2X+/YmOGR5ofui7tD5mDQfstAI9i+4WpMtIe8KC3wU5w3Inq3uNWVmoGtpKndsNfwJrCg0Hd9zmObhypUnSkfYn2ooMOOnBpfdanRtrvetZUayDMSC5iSRcXKpdls=");
|
||||||
|
@ -58,6 +60,7 @@ class SandboxConfig {
|
||||||
new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
|
new SignalStorageUrl[]{new SignalStorageUrl(STORAGE_URL, TRUST_STORE)},
|
||||||
interceptors,
|
interceptors,
|
||||||
dns,
|
dns,
|
||||||
|
proxy,
|
||||||
zkGroupServerPublicParams);
|
zkGroupServerPublicParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ public class SignalAccount implements Closeable {
|
||||||
private String registrationLockPin;
|
private String registrationLockPin;
|
||||||
private MasterKey pinMasterKey;
|
private MasterKey pinMasterKey;
|
||||||
private StorageKey storageKey;
|
private StorageKey storageKey;
|
||||||
private String signalingKey;
|
|
||||||
private ProfileKey profileKey;
|
private ProfileKey profileKey;
|
||||||
private int preKeyIdOffset;
|
private int preKeyIdOffset;
|
||||||
private int nextSignedPreKeyId;
|
private int nextSignedPreKeyId;
|
||||||
|
@ -153,7 +152,6 @@ public class SignalAccount implements Closeable {
|
||||||
int deviceId,
|
int deviceId,
|
||||||
IdentityKeyPair identityKey,
|
IdentityKeyPair identityKey,
|
||||||
int registrationId,
|
int registrationId,
|
||||||
String signalingKey,
|
|
||||||
ProfileKey profileKey
|
ProfileKey profileKey
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
IOUtils.createPrivateDirectories(dataPath);
|
IOUtils.createPrivateDirectories(dataPath);
|
||||||
|
@ -170,7 +168,6 @@ public class SignalAccount implements Closeable {
|
||||||
account.password = password;
|
account.password = password;
|
||||||
account.profileKey = profileKey;
|
account.profileKey = profileKey;
|
||||||
account.deviceId = deviceId;
|
account.deviceId = deviceId;
|
||||||
account.signalingKey = signalingKey;
|
|
||||||
account.signalProtocolStore = new JsonSignalProtocolStore(identityKey, registrationId);
|
account.signalProtocolStore = new JsonSignalProtocolStore(identityKey, registrationId);
|
||||||
account.groupStore = new JsonGroupStore(getGroupCachePath(dataPath, username));
|
account.groupStore = new JsonGroupStore(getGroupCachePath(dataPath, username));
|
||||||
account.contactStore = new JsonContactsStore();
|
account.contactStore = new JsonContactsStore();
|
||||||
|
@ -268,13 +265,6 @@ public class SignalAccount implements Closeable {
|
||||||
if (rootNode.hasNonNull("storageKey")) {
|
if (rootNode.hasNonNull("storageKey")) {
|
||||||
storageKey = new StorageKey(Base64.getDecoder().decode(rootNode.get("storageKey").asText()));
|
storageKey = new StorageKey(Base64.getDecoder().decode(rootNode.get("storageKey").asText()));
|
||||||
}
|
}
|
||||||
if (rootNode.hasNonNull("signalingKey")) {
|
|
||||||
signalingKey = rootNode.get("signalingKey").asText();
|
|
||||||
if (signalingKey.equals("null")) {
|
|
||||||
// Workaround for load bug in older versions
|
|
||||||
signalingKey = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rootNode.hasNonNull("preKeyIdOffset")) {
|
if (rootNode.hasNonNull("preKeyIdOffset")) {
|
||||||
preKeyIdOffset = rootNode.get("preKeyIdOffset").asInt(0);
|
preKeyIdOffset = rootNode.get("preKeyIdOffset").asInt(0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -406,7 +396,6 @@ public class SignalAccount implements Closeable {
|
||||||
pinMasterKey == null ? null : Base64.getEncoder().encodeToString(pinMasterKey.serialize()))
|
pinMasterKey == null ? null : Base64.getEncoder().encodeToString(pinMasterKey.serialize()))
|
||||||
.put("storageKey",
|
.put("storageKey",
|
||||||
storageKey == null ? null : Base64.getEncoder().encodeToString(storageKey.serialize()))
|
storageKey == null ? null : Base64.getEncoder().encodeToString(storageKey.serialize()))
|
||||||
.put("signalingKey", signalingKey)
|
|
||||||
.put("preKeyIdOffset", preKeyIdOffset)
|
.put("preKeyIdOffset", preKeyIdOffset)
|
||||||
.put("nextSignedPreKeyId", nextSignedPreKeyId)
|
.put("nextSignedPreKeyId", nextSignedPreKeyId)
|
||||||
.put("profileKey", Base64.getEncoder().encodeToString(profileKey.serialize()))
|
.put("profileKey", Base64.getEncoder().encodeToString(profileKey.serialize()))
|
||||||
|
@ -552,14 +541,6 @@ public class SignalAccount implements Closeable {
|
||||||
this.storageKey = storageKey;
|
this.storageKey = storageKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSignalingKey() {
|
|
||||||
return signalingKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSignalingKey(final String signalingKey) {
|
|
||||||
this.signalingKey = signalingKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileKey getProfileKey() {
|
public ProfileKey getProfileKey() {
|
||||||
return profileKey;
|
return profileKey;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||||
import org.whispersystems.libsignal.state.SessionRecord;
|
import org.whispersystems.libsignal.state.SessionRecord;
|
||||||
import org.whispersystems.libsignal.state.SessionStore;
|
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
class JsonSessionStore implements SessionStore {
|
class JsonSessionStore implements SignalServiceSessionStore {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(JsonSessionStore.class);
|
private final static Logger logger = LoggerFactory.getLogger(JsonSessionStore.class);
|
||||||
|
|
||||||
|
@ -127,6 +127,27 @@ class JsonSessionStore implements SessionStore {
|
||||||
sessions.removeIf(info -> info.address.matches(serviceAddress));
|
sessions.removeIf(info -> info.address.matches(serviceAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void archiveSession(final SignalProtocolAddress address) {
|
||||||
|
final SessionRecord sessionRecord = loadSession(address);
|
||||||
|
if (sessionRecord == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sessionRecord.archiveCurrentState();
|
||||||
|
storeSession(address, sessionRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void archiveAllSessions() {
|
||||||
|
for (SessionInfo info : sessions) {
|
||||||
|
try {
|
||||||
|
final SessionRecord sessionRecord = new SessionRecord(info.sessionRecord);
|
||||||
|
sessionRecord.archiveCurrentState();
|
||||||
|
info.sessionRecord = sessionRecord.serialize();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class JsonSessionStoreDeserializer extends JsonDeserializer<JsonSessionStore> {
|
public static class JsonSessionStoreDeserializer extends JsonDeserializer<JsonSessionStore> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,13 +11,13 @@ import org.whispersystems.libsignal.InvalidKeyIdException;
|
||||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||||
import org.whispersystems.libsignal.state.SessionRecord;
|
import org.whispersystems.libsignal.state.SessionRecord;
|
||||||
import org.whispersystems.libsignal.state.SignalProtocolStore;
|
|
||||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||||
|
import org.whispersystems.signalservice.api.SignalServiceProtocolStore;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JsonSignalProtocolStore implements SignalProtocolStore {
|
public class JsonSignalProtocolStore implements SignalServiceProtocolStore {
|
||||||
|
|
||||||
@JsonProperty("preKeys")
|
@JsonProperty("preKeys")
|
||||||
@JsonDeserialize(using = JsonPreKeyStore.JsonPreKeyStoreDeserializer.class)
|
@JsonDeserialize(using = JsonPreKeyStore.JsonPreKeyStoreDeserializer.class)
|
||||||
|
@ -171,6 +171,15 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
||||||
sessionStore.deleteAllSessions(serviceAddress);
|
sessionStore.deleteAllSessions(serviceAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void archiveSession(final SignalProtocolAddress address) {
|
||||||
|
sessionStore.archiveSession(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void archiveAllSessions() {
|
||||||
|
sessionStore.archiveAllSessions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException {
|
public SignedPreKeyRecord loadSignedPreKey(int signedPreKeyId) throws InvalidKeyIdException {
|
||||||
return signedPreKeyStore.loadSignedPreKey(signedPreKeyId);
|
return signedPreKeyStore.loadSignedPreKey(signedPreKeyId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue