code cleanup

This commit is contained in:
Daniel Gultsch 2015-12-23 22:30:14 +01:00
parent f46cbb38a9
commit c40372fc0d
3 changed files with 5 additions and 25 deletions

View File

@ -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();
}
}
}

View File

@ -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.
*/

View File

@ -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>