aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/crypto
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-09-06 15:08:42 +0200
committerAndreas Straub <andy@strb.org>2015-09-06 15:15:57 +0200
commita95c451f1e6ee69fbf3b0072d672c3609a4b1e7d (patch)
tree860e3300c65c837e4e4770a473e9f15cf6525886 /src/main/java/eu/siacs/conversations/crypto
parent2bb033267b80f8ee030a20e5c447df6a22226f61 (diff)
Only show that have sessions in fingerprint list
Doesn't access database directly anymore but goes through AxolotlService now to obtain list of fingerprints associated with an Account/Contact. This should prevent orphaned keys littering the UI which previously couldn't be removed through the Clear Devices function. Together with 1c79982da84964c1d81179a0927d9cd1eadf53de this fixes #1393
Diffstat (limited to 'src/main/java/eu/siacs/conversations/crypto')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java24
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java2
2 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
index e4c49e7c..a8e414f0 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
@@ -190,8 +190,8 @@ public class AxolotlService {
this.executor = new SerialSingleThreadExecutor();
}
- public IdentityKey getOwnPublicKey() {
- return axolotlStore.getIdentityKeyPair().getPublicKey();
+ public String getOwnFingerprint() {
+ return axolotlStore.getIdentityKeyPair().getPublicKey().getFingerprint().replaceAll("\\s", "");
}
public Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust) {
@@ -222,6 +222,22 @@ public class AxolotlService {
return sessions;
}
+ public Set<String> getFingerprintsForOwnSessions() {
+ Set<String> fingerprints = new HashSet<>();
+ for (XmppAxolotlSession session : findOwnSessions()) {
+ fingerprints.add(session.getFingerprint());
+ }
+ return fingerprints;
+ }
+
+ public Set<String> getFingerprintsForContact(final Contact contact) {
+ Set<String> fingerprints = new HashSet<>();
+ for (XmppAxolotlSession session : findSessionsforContact(contact)) {
+ fingerprints.add(session.getFingerprint());
+ }
+ return fingerprints;
+ }
+
private boolean hasAny(Contact contact) {
AxolotlAddress contactAddress = getAddressForJid(contact.getJid());
return sessions.hasAny(contactAddress);
@@ -310,8 +326,8 @@ public class AxolotlService {
});
}
- public void purgeKey(IdentityKey identityKey) {
- axolotlStore.setFingerprintTrust(identityKey.getFingerprint().replaceAll("\\s", ""), XmppAxolotlSession.Trust.COMPROMISED);
+ public void purgeKey(final String fingerprint) {
+ axolotlStore.setFingerprintTrust(fingerprint.replaceAll("\\s", ""), XmppAxolotlSession.Trust.COMPROMISED);
}
public void publishOwnDeviceIdIfNeeded() {
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
index c4053854..d582db40 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
@@ -91,7 +91,7 @@ public class XmppAxolotlSession {
public XmppAxolotlSession(Account account, SQLiteAxolotlStore store, AxolotlAddress remoteAddress, String fingerprint) {
this(account, store, remoteAddress);
- this.fingerprint = fingerprint;
+ this.fingerprint = fingerprint.replaceAll("\\s","");
}
public XmppAxolotlSession(Account account, SQLiteAxolotlStore store, AxolotlAddress remoteAddress) {