aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/entities/Account.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-16 16:32:15 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-16 16:32:15 +0100
commit9c7cacdbddf6ba1a34fd56b71718ba4e44e20efa (patch)
treea9f138b3bd8395b3a198235a1c8d559d71347ef4 /src/de/gultsch/chat/entities/Account.java
parent42c4c1789a75c87b67c38ef9ca3f57ddd10f0548 (diff)
show unknown otr fingerprint warining
Diffstat (limited to '')
-rw-r--r--src/de/gultsch/chat/entities/Account.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/de/gultsch/chat/entities/Account.java b/src/de/gultsch/chat/entities/Account.java
index 7f14b090..1bced45f 100644
--- a/src/de/gultsch/chat/entities/Account.java
+++ b/src/de/gultsch/chat/entities/Account.java
@@ -1,5 +1,10 @@
package de.gultsch.chat.entities;
+import java.security.interfaces.DSAPublicKey;
+
+import net.java.otr4j.crypto.OtrCryptoEngineImpl;
+import net.java.otr4j.crypto.OtrCryptoException;
+
import org.json.JSONException;
import org.json.JSONObject;
@@ -48,6 +53,8 @@ public class Account extends AbstractEntity{
transient OtrEngine otrEngine = null;
transient XmppConnection xmppConnection = null;
+
+ private String otrFingerprint;
public Account() {
this.uuid = "0";
@@ -177,4 +184,21 @@ public class Account extends AbstractEntity{
public String getFullJid() {
return this.getJid()+"/"+this.resource;
}
+
+ public String getOtrFingerprint() {
+ if (this.otrFingerprint == null) {
+ try {
+ DSAPublicKey pubkey = (DSAPublicKey) this.otrEngine.getPublicKey();
+ StringBuilder builder = new StringBuilder(new OtrCryptoEngineImpl().getFingerprint(pubkey));
+ builder.insert(8, " ");
+ builder.insert(17, " ");
+ builder.insert(26, " ");
+ builder.insert(35, " ");
+ this.otrFingerprint = builder.toString();
+ } catch (OtrCryptoException e) {
+
+ }
+ }
+ return this.otrFingerprint;
+ }
}