aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-23 22:30:14 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-23 22:30:14 +0100
commitc40372fc0d1bc81650321b0166c06a0be05ac0a2 (patch)
treec88cb92a6531e9884bdb1c53064317786b053058 /src/main
parentf46cbb38a92ff5281a974ecc0932ba5459c7334e (diff)
code cleanup
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java7
-rw-r--r--src/main/java/eu/siacs/conversations/utils/CryptoHelper.java22
-rw-r--r--src/main/res/values/strings.xml1
3 files changed, 5 insertions, 25 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 5143190f..04885ad1 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -28,6 +28,7 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.QuickContactBadge;
import android.widget.TextView;
+import android.widget.Toast;
import org.openintents.openpgp.util.OpenPgpUtils;
@@ -455,13 +456,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
}
private void onOmemoKeyClicked(Account account, String fingerprint) {
- Log.d(Config.LOGTAG,"on omemo key clicked");
final XmppAxolotlSession.Trust trust = account.getAxolotlService().getFingerprintTrust(fingerprint);
- if (trust != null) {
+ if (trust != null && trust == XmppAxolotlSession.Trust.TRUSTED_X509) {
X509Certificate x509Certificate = account.getAxolotlService().getFingerprintCertificate(fingerprint);
if (x509Certificate != null) {
- Log.d(Config.LOGTAG, "certificate for fingerprint " + fingerprint + " was not null");
showCertificateInformationDialog(CryptoHelper.extractCertificateInformation(x509Certificate));
+ } else {
+ Toast.makeText(this,R.string.certificate_not_found, Toast.LENGTH_SHORT).show();
}
}
}
diff --git a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
index d1b90ab6..5c504e04 100644
--- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
@@ -1,21 +1,17 @@
package eu.siacs.conversations.utils;
import android.os.Bundle;
-import android.util.Log;
import android.util.Pair;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.style.BCStyle;
import org.bouncycastle.asn1.x500.style.IETFUtils;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
-import org.bouncycastle.jce.PrincipalUtil;
import java.security.MessageDigest;
-import java.security.SecureRandom;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
-import java.security.cert.X509Extension;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,8 +29,6 @@ import eu.siacs.conversations.xmpp.jid.Jid;
public final class CryptoHelper {
public static final String FILETRANSFER = "?FILETRANSFERv1:";
private final static char[] hexArray = "0123456789abcdef".toCharArray();
- private final static char[] vowels = "aeiou".toCharArray();
- private final static char[] consonants = "bcdfghjklmnpqrstvwxyz".toCharArray();
final public static byte[] ONE = new byte[] { 0, 0, 0, 1 };
public static String bytesToHex(byte[] bytes) {
@@ -68,22 +62,6 @@ public final class CryptoHelper {
return result;
}
- public static String randomMucName(SecureRandom random) {
- return randomWord(3, random) + "." + randomWord(7, random);
- }
-
- private static String randomWord(int lenght, SecureRandom random) {
- StringBuilder builder = new StringBuilder(lenght);
- for (int i = 0; i < lenght; ++i) {
- if (i % 2 == 0) {
- builder.append(consonants[random.nextInt(consonants.length)]);
- } else {
- builder.append(vowels[random.nextInt(vowels.length)]);
- }
- }
- return builder.toString();
- }
-
/**
* Escapes usernames or passwords for SASL.
*/
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 2666e98d..1035ff83 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -567,4 +567,5 @@
<string name="certificate_o">Organization</string>
<string name="certificate_sha1">SHA1</string>
<string name="certicate_info_not_available">(Not available)</string>
+ <string name="certificate_not_found">No certificate found</string>
</resources>