From 15083fa3b0e4a4500c5ca0e9e4581236e7b609d2 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 29 Jan 2018 18:37:04 +0100 Subject: [PATCH] Stale devices: Consider date of deviceId publication --- .../smackx/omemo/CachingOmemoStore.java | 23 ++++++++ .../smackx/omemo/FileBasedOmemoStore.java | 30 ++++++++--- .../smackx/omemo/OmemoManager.java | 8 +++ .../smackx/omemo/OmemoService.java | 52 ++++++++++++++++--- .../jivesoftware/smackx/omemo/OmemoStore.java | 34 ++++++++++-- .../exceptions/StaleDeviceException.java | 35 +++++++++++-- 6 files changed, 160 insertions(+), 22 deletions(-) diff --git a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/CachingOmemoStore.java b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/CachingOmemoStore.java index cc1c06250..2e7b5cda0 100644 --- a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/CachingOmemoStore.java +++ b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/CachingOmemoStore.java @@ -165,6 +165,28 @@ public class CachingOmemoStore> sessions = new HashMap<>(); private final HashMap identityKeys = new HashMap<>(); private final HashMap lastMessagesDates = new HashMap<>(); + private final HashMap lastDeviceIdPublicationDates = new HashMap<>(); private final HashMap deviceLists = new HashMap<>(); private Date lastRenewalDate = null; } diff --git a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/FileBasedOmemoStore.java b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/FileBasedOmemoStore.java index 9adb6f5ba..f44f6d7e0 100644 --- a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/FileBasedOmemoStore.java +++ b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/FileBasedOmemoStore.java @@ -105,12 +105,6 @@ public abstract class FileBasedOmemoStore localDeviceIdsOf(BareJid localUser) { SortedSet deviceIds = new TreeSet<>(); @@ -128,6 +122,12 @@ public abstract class FileBasedOmemoStore getUndecidedDevices(OmemoDevice userDevice, OmemoTrustCallback callback, Set devices) { Set undecidedDevices = new HashSet<>(); @@ -883,6 +901,15 @@ public abstract class OmemoService getUntrustedDeviced(OmemoDevice userDevice, OmemoTrustCallback trustCallback, Set devices) { Set untrustedDevices = new HashSet<>(); @@ -1009,13 +1036,22 @@ public abstract class OmemoService