diff options
Diffstat (limited to 'src')
3 files changed, 26 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 476e2ead..15eb49b6 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -36,6 +36,8 @@ public final class Config { public static final String LOGTAG = "conversations"; + public static final String BUG_REPORTS = "bugs@conversations.im"; + public static final String DOMAIN_LOCK = null; //only allow account creation for this domain public static final String MAGIC_CREATE_DOMAIN = "conversations.im"; diff --git a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java index 1ef5fb3f..253584bf 100644 --- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java @@ -9,6 +9,7 @@ import org.bouncycastle.asn1.x500.style.IETFUtils; import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateParsingException; import java.security.cert.X509Certificate; @@ -184,9 +185,7 @@ public final class CryptoHelper { //ignored } try { - MessageDigest md = MessageDigest.getInstance("SHA-1"); - byte[] fingerprint = md.digest(certificate.getEncoded()); - information.putString("sha1", prettifyFingerprintCert(bytesToHex(fingerprint))); + information.putString("sha1", getFingerprintCert(certificate.getEncoded())); } catch (Exception e) { } @@ -196,6 +195,12 @@ public final class CryptoHelper { } } + public static String getFingerprintCert(byte[] input) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance("SHA-1"); + byte[] fingerprint = md.digest(input); + return prettifyFingerprintCert(bytesToHex(fingerprint)); + } + public static int encryptionTypeToText(int encryption) { switch (encryption) { case Message.ENCRYPTION_OTR: diff --git a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java index 58d74b58..962613fb 100644 --- a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java @@ -8,6 +8,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.Signature; import android.preference.PreferenceManager; import android.text.format.DateUtils; import android.util.Log; @@ -18,6 +19,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; import eu.siacs.conversations.Config; @@ -31,6 +34,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; public class ExceptionHelper { + private static SimpleDateFormat DATE_FORMATs = new SimpleDateFormat("yyyy-MM-dd"); public static void init(Context context) { if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler)) { Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler( @@ -43,7 +47,7 @@ public class ExceptionHelper { final SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(activity); boolean neverSend = preferences.getBoolean("never_send", false); - if (neverSend) { + if (neverSend || Config.BUG_REPORTS == null) { return false; } List<Account> accounts = service.getAccounts(); @@ -63,16 +67,18 @@ public class ExceptionHelper { BufferedReader stacktrace = new BufferedReader(inputStreamReader); final StringBuilder report = new StringBuilder(); PackageManager pm = activity.getPackageManager(); - PackageInfo packageInfo = null; + PackageInfo packageInfo; try { - packageInfo = pm.getPackageInfo(activity.getPackageName(), 0); + packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES); report.append("Version: " + packageInfo.versionName + '\n'); - report.append("Last Update: " - + DateUtils.formatDateTime(activity, - packageInfo.lastUpdateTime, - DateUtils.FORMAT_SHOW_TIME - | DateUtils.FORMAT_SHOW_DATE) + '\n'); - } catch (NameNotFoundException e) { + report.append("Last Update: " + DATE_FORMATs.format(new Date(packageInfo.lastUpdateTime)) + '\n'); + Signature[] signatures = packageInfo.signatures; + if (signatures != null && signatures.length >= 1) { + report.append("SHA-1: " + CryptoHelper.getFingerprintCert(packageInfo.signatures[0].toByteArray()) + "\n"); + } + report.append('\n'); + } catch (Exception e) { + e.printStackTrace(); return false; } String line; @@ -97,7 +103,7 @@ public class ExceptionHelper { Conversation conversation = null; try { conversation = service.findOrCreateConversation(finalAccount, - Jid.fromString("bugs@siacs.eu"), false); + Jid.fromString(Config.BUG_REPORTS), false); } catch (final InvalidJidException ignored) { } Message message = new Message(conversation, report |