aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-06-17 00:12:06 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-06-18 00:30:45 +0200
commitd8b0015d25b12f1b82e1a044fb3b130844141fda (patch)
tree1008fed78f89f99cc67f15febda3f72a459aa649 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
parentb4974d922e0a5472932e211d6a87b3ea901dfae6 (diff)
downloadopen-keychain-d8b0015d25b12f1b82e1a044fb3b130844141fda.tar.gz
open-keychain-d8b0015d25b12f1b82e1a044fb3b130844141fda.tar.bz2
open-keychain-d8b0015d25b12f1b82e1a044fb3b130844141fda.zip
consolidate: add logging
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java37
1 files changed, 29 insertions, 8 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
index 5f1c2cac3..5cd13c4a2 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -643,6 +643,7 @@ public class UncachedKeyRing {
*
* TODO work with secret keys
*
+ * @param list The list of UncachedKeyRings. Must not be empty, and all of the same masterKeyId
* @return A consolidated UncachedKeyRing with the data of all input keyrings.
*
*/
@@ -650,15 +651,12 @@ public class UncachedKeyRing {
OperationLog log, int indent) {
long masterKeyId = list.get(0).getMasterKeyId();
- for (UncachedKeyRing ring : new IterableIterator<UncachedKeyRing>(list.iterator())) {
- if (ring.getMasterKeyId() != masterKeyId) {
- // log.add(LogLevel.ERROR, LogType.MSG_KO, null, indent);
- return null;
- }
- }
- // log.add(LogLevel.START, LogType.MSG_KO,
- // new String[]{PgpKeyHelper.convertKeyIdToHex(masterKeyId)}, indent);
+ log.add(LogLevel.START, LogType.MSG_KO,
+ new String[]{
+ Integer.toString(list.size()),
+ PgpKeyHelper.convertKeyIdToHex(masterKeyId)
+ }, indent);
indent += 1;
// remember which certs we already added
@@ -666,13 +664,28 @@ public class UncachedKeyRing {
try {
PGPPublicKeyRing result = null;
+ int num = 1;
for (UncachedKeyRing uring : new IterableIterator<UncachedKeyRing>(list.iterator())) {
+
PGPPublicKeyRing ring = (PGPPublicKeyRing) uring.mRing;
+ if (uring.getMasterKeyId() != masterKeyId) {
+ log.add(LogLevel.ERROR, LogType.MSG_KO_HETEROGENEOUS, null, indent);
+ return null;
+ }
+
+ // If this is the first ring, just take it
if (result == null) {
result = ring;
continue;
}
+ log.add(LogLevel.DEBUG, LogType.MSG_KO_MERGING,
+ new String[] { Integer.toString(num++) }, indent);
+ indent += 1;
+
+ // keep track of the number of new certs we add
+ int newCerts = 0;
+
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(ring.getPublicKeys())) {
final PGPPublicKey resultkey = result.getPublicKey(key.getKeyID());
@@ -702,6 +715,7 @@ public class UncachedKeyRing {
}
certs.add(hash);
modified = PGPPublicKey.addCertification(modified, cert);
+ newCerts += 1;
}
// If this is a subkey, stop here
@@ -718,6 +732,7 @@ public class UncachedKeyRing {
if (certs.contains(hash)) {
continue;
}
+ newCerts += 1;
certs.add(hash);
modified = PGPPublicKey.addCertification(modified, userId, cert);
}
@@ -726,13 +741,19 @@ public class UncachedKeyRing {
if (modified != resultkey) {
result = PGPPublicKeyRing.insertPublicKey(result, modified);
}
+
}
+ log.add(LogLevel.DEBUG, LogType.MSG_KO_FOUND_NEW,
+ new String[] { Integer.toString(newCerts) }, indent);
+
+
}
return new UncachedKeyRing(result);
} catch (IOException e) {
+ log.add(LogLevel.ERROR, LogType.MSG_KO_FATAL_ENCODE, null, indent);
return null;
}