mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
consolidate: add logging
This commit is contained in:
parent
b4974d922e
commit
d8b0015d25
@ -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;
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,12 @@ public abstract class WrappedKeyRing extends KeyRing {
|
||||
getRing().encode(stream);
|
||||
}
|
||||
|
||||
/** Returns an UncachedKeyRing which wraps the same data as this ring. This method should
|
||||
* only be used */
|
||||
public UncachedKeyRing getUncachedKeyRing() {
|
||||
return new UncachedKeyRing(getRing());
|
||||
}
|
||||
|
||||
abstract PGPKeyRing getRing();
|
||||
|
||||
abstract public IterableIterator<WrappedPublicKey> publicKeyIterator();
|
||||
|
@ -284,6 +284,14 @@ public class ProviderHelper {
|
||||
new String[]{ PgpKeyHelper.convertKeyIdToHex(masterKeyId) });
|
||||
mIndent += 1;
|
||||
|
||||
try {
|
||||
WrappedPublicKeyRing ring = getWrappedPublicKeyRing(KeyRings.buildUnifiedKeyRingUri(masterKeyId));
|
||||
// ring.get
|
||||
|
||||
} catch(NotFoundException e) {
|
||||
// no biggie
|
||||
}
|
||||
|
||||
// Canonicalize this key, to assert a number of assumptions made about it.
|
||||
keyRing = keyRing.canonicalizePublic(mLog, mIndent);
|
||||
if (keyRing == null) {
|
||||
|
@ -3,8 +3,10 @@ package org.sufficientlysecure.keychain.service;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -218,6 +220,14 @@ public class OperationResultParcel implements Parcelable {
|
||||
MSG_KC_UID_NO_CERT (R.string.msg_kc_uid_no_cert),
|
||||
MSG_KC_UID_REVOKE_DUP (R.string.msg_kc_uid_revoke_dup),
|
||||
MSG_KC_UID_REVOKE_OLD (R.string.msg_kc_uid_revoke_old),
|
||||
|
||||
// keyring consolidation
|
||||
MSG_KO (R.string.msg_ko),
|
||||
MSG_KO_FATAL_ENCODE (R.string.msg_ko_fatal_encode),
|
||||
MSG_KO_HETEROGENEOUS (R.string.msg_ko_heterogeneous),
|
||||
MSG_KO_MERGING (R.string.msg_ko_merging),
|
||||
MSG_KO_NEW_SUBKEY (R.string.msg_ko_new_subkey),
|
||||
MSG_KO_FOUND_NEW (R.string.msg_ko_found_new),
|
||||
;
|
||||
|
||||
private final int mMsgId;
|
||||
@ -264,6 +274,7 @@ public class OperationResultParcel implements Parcelable {
|
||||
|
||||
/// Simple convenience method
|
||||
public void add(LogLevel level, LogType type, String[] parameters, int indent) {
|
||||
Log.d(Constants.TAG, type.toString());
|
||||
add(new OperationResultParcel.LogEntryParcel(level, type, parameters, indent));
|
||||
}
|
||||
|
||||
|
@ -598,6 +598,13 @@
|
||||
<string name="msg_kc_uid_revoke_old">Removing outdated revocation certificate for user id "%s"</string>
|
||||
<string name="msg_kc_uid_no_cert">No valid self-certificate found for user id %s, removing from ring</string>
|
||||
|
||||
<string name="msg_ko">Consolidating %1$s keyrings into %2$s</string>
|
||||
<string name="msg_ko_fatal_encode">Fatal error encoding signature</string>
|
||||
<string name="msg_ko_heterogeneous">Tried to consolidate heterogeneous keyrings</string>
|
||||
<string name="msg_ko_merging">Merging keyring #%s</string>
|
||||
<string name="msg_ko_new_subkey">Adding new subkey %s</string>
|
||||
<string name="msg_ko_found_new">Found %s new certificates in keyring</string>
|
||||
|
||||
<!-- unsorted -->
|
||||
<string name="section_certifier_id">Certifier</string>
|
||||
<string name="section_cert">Certificate Details</string>
|
||||
|
Loading…
Reference in New Issue
Block a user