Remove caching from OpenPGP trust store

This commit is contained in:
Paul Schaub 2021-01-13 22:32:07 +01:00
parent 2c1af41249
commit 77f4273c3a
1 changed files with 0 additions and 27 deletions

View File

@ -17,8 +17,6 @@
package org.jivesoftware.smackx.ox.store.abstr;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.jivesoftware.smackx.ox.store.definition.OpenPgpTrustStore;
@ -27,8 +25,6 @@ import org.pgpainless.key.OpenPgpV4Fingerprint;
public abstract class AbstractOpenPgpTrustStore implements OpenPgpTrustStore {
private final Map<BareJid, Map<OpenPgpV4Fingerprint, Trust>> trustCache = new HashMap<>();
/**
* Read the trust record for the key with fingerprint {@code fingerprint} of user {@code owner} from local storage.
* This method returns {@link Trust#undecided} in case that no trust record has been found.
@ -55,37 +51,14 @@ public abstract class AbstractOpenPgpTrustStore implements OpenPgpTrustStore {
@Override
public Trust getTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint) throws IOException {
Trust trust;
Map<OpenPgpV4Fingerprint, Trust> trustMap = trustCache.get(owner);
if (trustMap != null) {
trust = trustMap.get(fingerprint);
if (trust != null) {
return trust;
}
} else {
trustMap = new HashMap<>();
trustCache.put(owner, trustMap);
}
trust = readTrust(owner, fingerprint);
trustMap.put(fingerprint, trust);
return trust;
}
@Override
public void setTrust(BareJid owner, OpenPgpV4Fingerprint fingerprint, Trust trust) throws IOException {
Map<OpenPgpV4Fingerprint, Trust> trustMap = trustCache.get(owner);
if (trustMap == null) {
trustMap = new HashMap<>();
trustCache.put(owner, trustMap);
}
if (trustMap.get(fingerprint) == trust) {
return;
}
trustMap.put(fingerprint, trust);
writeTrust(owner, fingerprint, trust);
}
}