From 1771f2ce9f106fa8d6b54ac208eb894be577c282 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 17 Jul 2018 15:49:52 +0200 Subject: [PATCH] show repo title on certificate error toast messages closes #1262 --- .../main/java/org/fdroid/fdroid/IndexV1Updater.java | 8 ++++---- app/src/main/java/org/fdroid/fdroid/RepoUpdater.java | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java index 2c25c4874..8e11fbf4c 100644 --- a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java +++ b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java @@ -429,14 +429,14 @@ public class IndexV1Updater extends RepoUpdater { String certFromJar = Hasher.hex(rawCertFromJar); if (TextUtils.isEmpty(certFromJar)) { - throw new SigningException(SIGNED_FILE_NAME + " must have an included signing certificate!"); + throw new SigningException(repo, SIGNED_FILE_NAME + " must have an included signing certificate!"); } if (repo.signingCertificate == null) { if (repo.fingerprint != null) { String fingerprintFromJar = Utils.calcFingerprint(rawCertFromJar); if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) { - throw new SigningException("Supplied certificate fingerprint does not match!"); + throw new SigningException(repo, "Supplied certificate fingerprint does not match!"); } } Utils.debugLog(TAG, "Saving new signing certificate to database for " + repo.address); @@ -448,14 +448,14 @@ public class IndexV1Updater extends RepoUpdater { } if (TextUtils.isEmpty(repo.signingCertificate)) { - throw new SigningException("A empty repo signing certificate is invalid!"); + throw new SigningException(repo, "A empty repo signing certificate is invalid!"); } if (repo.signingCertificate.equals(certFromJar)) { return; // we have a match! } - throw new SigningException("Signing certificate does not match!"); + throw new SigningException(repo, "Signing certificate does not match!"); } /** diff --git a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java index 566a77124..92d78bbc1 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java @@ -351,6 +351,10 @@ public class RepoUpdater { public SigningException(String message) { super("Repository was not signed correctly: " + message); } + + public SigningException(Repo repo, String message) { + super((repo == null ? "Repository" : repo.name) + " was not signed correctly: " + message); + } } /** @@ -395,7 +399,7 @@ public class RepoUpdater { String fingerprintFromJar = Utils.calcFingerprint(rawCertFromJar); if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromIndexXml) || !repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) { - throw new SigningException("Supplied certificate fingerprint does not match!"); + throw new SigningException(repo, "Supplied certificate fingerprint does not match!"); } } // else - no info to check things are valid, so just Trust On First Use @@ -426,7 +430,7 @@ public class RepoUpdater { if (TextUtils.isEmpty(repo.signingCertificate) || TextUtils.isEmpty(certFromJar) || TextUtils.isEmpty(certFromIndexXml)) { - throw new SigningException("A empty repo or signing certificate is invalid!"); + throw new SigningException(repo, "A empty repo or signing certificate is invalid!"); } // though its called repo.signingCertificate, its actually a X509 certificate @@ -435,7 +439,7 @@ public class RepoUpdater { && certFromIndexXml.equals(certFromJar)) { return; // we have a match! } - throw new SigningException("Signing certificate does not match!"); + throw new SigningException(repo, "Signing certificate does not match!"); } /**