Merge branch 'master' of github.com:open-keychain/open-keychain

This commit is contained in:
Dominik Schürmann 2014-07-31 23:13:33 +02:00
commit 38120ae77c
5 changed files with 43 additions and 46 deletions

View file

@ -354,7 +354,7 @@ public class PgpKeyOperation {
subProgressPush(15, 25); subProgressPush(15, 25);
for (int i = 0; i < saveParcel.mAddUserIds.size(); i++) { for (int i = 0; i < saveParcel.mAddUserIds.size(); i++) {
progress(R.string.progress_modify_adduid, (i-1) * (100 / saveParcel.mAddSubKeys.size())); progress(R.string.progress_modify_adduid, (i-1) * (100 / saveParcel.mAddUserIds.size()));
String userId = saveParcel.mAddUserIds.get(i); String userId = saveParcel.mAddUserIds.get(i);
log.add(LogLevel.INFO, LogType.MSG_MF_UID_ADD, indent); log.add(LogLevel.INFO, LogType.MSG_MF_UID_ADD, indent);
@ -399,7 +399,7 @@ public class PgpKeyOperation {
subProgressPush(25, 40); subProgressPush(25, 40);
for (int i = 0; i < saveParcel.mRevokeUserIds.size(); i++) { for (int i = 0; i < saveParcel.mRevokeUserIds.size(); i++) {
progress(R.string.progress_modify_revokeuid, (i-1) * (100 / saveParcel.mAddSubKeys.size())); progress(R.string.progress_modify_revokeuid, (i-1) * (100 / saveParcel.mRevokeUserIds.size()));
String userId = saveParcel.mRevokeUserIds.get(i); String userId = saveParcel.mRevokeUserIds.get(i);
log.add(LogLevel.INFO, LogType.MSG_MF_UID_REVOKE, indent, userId); log.add(LogLevel.INFO, LogType.MSG_MF_UID_REVOKE, indent, userId);
@ -522,7 +522,7 @@ public class PgpKeyOperation {
subProgressPush(50, 60); subProgressPush(50, 60);
for (int i = 0; i < saveParcel.mChangeSubKeys.size(); i++) { for (int i = 0; i < saveParcel.mChangeSubKeys.size(); i++) {
progress(R.string.progress_modify_subkeychange, (i-1) * (100 / saveParcel.mAddSubKeys.size())); progress(R.string.progress_modify_subkeychange, (i-1) * (100 / saveParcel.mChangeSubKeys.size()));
SaveKeyringParcel.SubkeyChange change = saveParcel.mChangeSubKeys.get(i); SaveKeyringParcel.SubkeyChange change = saveParcel.mChangeSubKeys.get(i);
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_CHANGE, log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_CHANGE,
indent, PgpKeyHelper.convertKeyIdToHex(change.mKeyId)); indent, PgpKeyHelper.convertKeyIdToHex(change.mKeyId));
@ -583,7 +583,7 @@ public class PgpKeyOperation {
subProgressPush(60, 70); subProgressPush(60, 70);
for (int i = 0; i < saveParcel.mRevokeSubKeys.size(); i++) { for (int i = 0; i < saveParcel.mRevokeSubKeys.size(); i++) {
progress(R.string.progress_modify_subkeyrevoke, (i-1) * (100 / saveParcel.mAddSubKeys.size())); progress(R.string.progress_modify_subkeyrevoke, (i-1) * (100 / saveParcel.mRevokeSubKeys.size()));
long revocation = saveParcel.mRevokeSubKeys.get(i); long revocation = saveParcel.mRevokeSubKeys.get(i);
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_REVOKE, log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_REVOKE,
indent, PgpKeyHelper.convertKeyIdToHex(revocation)); indent, PgpKeyHelper.convertKeyIdToHex(revocation));

View file

@ -300,14 +300,14 @@ public class UncachedKeyRing {
revocation = zert; revocation = zert;
// more revocations? at least one is superfluous, then. // more revocations? at least one is superfluous, then.
} else if (revocation.getCreationTime().before(zert.getCreationTime())) { } else if (revocation.getCreationTime().before(zert.getCreationTime())) {
log.add(LogLevel.INFO, LogType.MSG_KC_REVOKE_DUP, indent);
modified = PGPPublicKey.removeCertification(modified, revocation); modified = PGPPublicKey.removeCertification(modified, revocation);
redundantCerts += 1; redundantCerts += 1;
log.add(LogLevel.INFO, LogType.MSG_KC_REVOKE_DUP, indent);
revocation = zert; revocation = zert;
} else { } else {
log.add(LogLevel.INFO, LogType.MSG_KC_REVOKE_DUP, indent);
modified = PGPPublicKey.removeCertification(modified, zert); modified = PGPPublicKey.removeCertification(modified, zert);
redundantCerts += 1; redundantCerts += 1;
log.add(LogLevel.INFO, LogType.MSG_KC_REVOKE_DUP, indent);
} }
} }
@ -331,12 +331,13 @@ public class UncachedKeyRing {
indent, "0x" + Integer.toString(zert.getSignatureType(), 16)); indent, "0x" + Integer.toString(zert.getSignatureType(), 16));
modified = PGPPublicKey.removeCertification(modified, userId, zert); modified = PGPPublicKey.removeCertification(modified, userId, zert);
badCerts += 1; badCerts += 1;
continue;
} }
if (cert.getCreationTime().after(now)) { if (cert.getCreationTime().after(now)) {
// Creation date in the future? No way! // Creation date in the future? No way!
log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TIME, indent); log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TIME, indent);
modified = PGPPublicKey.removeCertification(modified, zert); modified = PGPPublicKey.removeCertification(modified, userId, zert);
badCerts += 1; badCerts += 1;
continue; continue;
} }
@ -344,7 +345,7 @@ public class UncachedKeyRing {
if (cert.isLocal()) { if (cert.isLocal()) {
// Creation date in the future? No way! // Creation date in the future? No way!
log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_LOCAL, indent); log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_LOCAL, indent);
modified = PGPPublicKey.removeCertification(modified, zert); modified = PGPPublicKey.removeCertification(modified, userId, zert);
badCerts += 1; badCerts += 1;
continue; continue;
} }
@ -387,35 +388,35 @@ public class UncachedKeyRing {
if (selfCert == null) { if (selfCert == null) {
selfCert = zert; selfCert = zert;
} else if (selfCert.getCreationTime().before(cert.getCreationTime())) { } else if (selfCert.getCreationTime().before(cert.getCreationTime())) {
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_DUP,
indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId, selfCert); modified = PGPPublicKey.removeCertification(modified, userId, selfCert);
redundantCerts += 1; redundantCerts += 1;
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_DUP,
indent, userId);
selfCert = zert; selfCert = zert;
} else { } else {
modified = PGPPublicKey.removeCertification(modified, userId, zert);
redundantCerts += 1;
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_DUP, log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_DUP,
indent, userId); indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId, zert);
redundantCerts += 1;
} }
// If there is a revocation certificate, and it's older than this, drop it // If there is a revocation certificate, and it's older than this, drop it
if (revocation != null if (revocation != null
&& revocation.getCreationTime().before(selfCert.getCreationTime())) { && revocation.getCreationTime().before(selfCert.getCreationTime())) {
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId, revocation); modified = PGPPublicKey.removeCertification(modified, userId, revocation);
revocation = null; revocation = null;
redundantCerts += 1; redundantCerts += 1;
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
indent, userId);
} }
break; break;
case PGPSignature.CERTIFICATION_REVOCATION: case PGPSignature.CERTIFICATION_REVOCATION:
// If this is older than the (latest) self cert, drop it // If this is older than the (latest) self cert, drop it
if (selfCert != null && selfCert.getCreationTime().after(zert.getCreationTime())) { if (selfCert != null && selfCert.getCreationTime().after(zert.getCreationTime())) {
modified = PGPPublicKey.removeCertification(modified, userId, zert);
redundantCerts += 1;
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD, log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_OLD,
indent, userId); indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId, zert);
redundantCerts += 1;
continue; continue;
} }
// first revocation? remember it. // first revocation? remember it.
@ -423,16 +424,16 @@ public class UncachedKeyRing {
revocation = zert; revocation = zert;
// more revocations? at least one is superfluous, then. // more revocations? at least one is superfluous, then.
} else if (revocation.getCreationTime().before(cert.getCreationTime())) { } else if (revocation.getCreationTime().before(cert.getCreationTime())) {
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId, revocation); modified = PGPPublicKey.removeCertification(modified, userId, revocation);
redundantCerts += 1; redundantCerts += 1;
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
indent, userId);
revocation = zert; revocation = zert;
} else { } else {
modified = PGPPublicKey.removeCertification(modified, userId, zert);
redundantCerts += 1;
log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP, log.add(LogLevel.DEBUG, LogType.MSG_KC_UID_REVOKE_DUP,
indent, userId); indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId, zert);
redundantCerts += 1;
} }
break; break;
@ -442,9 +443,9 @@ public class UncachedKeyRing {
// If no valid certificate (if only a revocation) remains, drop it // If no valid certificate (if only a revocation) remains, drop it
if (selfCert == null && revocation == null) { if (selfCert == null && revocation == null) {
modified = PGPPublicKey.removeCertification(modified, userId);
log.add(LogLevel.ERROR, LogType.MSG_KC_UID_REMOVE, log.add(LogLevel.ERROR, LogType.MSG_KC_UID_REMOVE,
indent, userId); indent, userId);
modified = PGPPublicKey.removeCertification(modified, userId);
} }
} }

View file

@ -233,6 +233,12 @@ public class ProviderHelper {
} }
private KeyRing getCanonicalizedKeyRing(Uri queryUri, boolean secret) throws NotFoundException { private KeyRing getCanonicalizedKeyRing(Uri queryUri, boolean secret) throws NotFoundException {
// if this is not a unified query, we /will/ get hard to trace errors below!
if ( ! queryUri.getPath().contains("unified")) {
throw new RuntimeException("only unified uris can be passed to getCanonicalizedKeyRing!");
}
Cursor cursor = mContentResolver.query(queryUri, Cursor cursor = mContentResolver.query(queryUri,
new String[]{ new String[]{
// we pick from cache only information that is not easily available from keyrings // we pick from cache only information that is not easily available from keyrings

View file

@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
@ -92,7 +93,7 @@ public class UploadKeyActivity extends ActionBarActivity {
intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING); intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING);
// set data uri as path to keyring // set data uri as path to keyring
Uri blobUri = KeychainContract.KeyRingData.buildPublicKeyRingUri(mDataUri); Uri blobUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
intent.setData(blobUri); intent.setData(blobUri);
// fill values for this action // fill values for this action

View file

@ -145,20 +145,27 @@ public class ViewKeyActivity extends ActionBarActivity implements
switchToTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB); switchToTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB);
} }
Uri dataUri = getDataUri(); mDataUri = getIntent().getData();
if (dataUri == null) { if (mDataUri == null) {
Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); Log.e(Constants.TAG, "Data missing. Should be uri of key!");
finish(); finish();
return; return;
} }
if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) {
mDataUri = ContactHelper.dataUriFromContactUri(this, mDataUri);
}
loadData(dataUri); Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
initNfc(dataUri); // Prepare the loaders. Either re-connect with an existing ones,
// or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
initNfc(mDataUri);
mShowAdvancedTabs = false; mShowAdvancedTabs = false;
initTabs(dataUri); initTabs(mDataUri);
// switch to tab selected by extra // switch to tab selected by extra
mViewPager.setCurrentItem(switchToTab); mViewPager.setCurrentItem(switchToTab);
@ -235,24 +242,6 @@ public class ViewKeyActivity extends ActionBarActivity implements
mSlidingTabLayout.setViewPager(mViewPager); mSlidingTabLayout.setViewPager(mViewPager);
} }
private Uri getDataUri() {
Uri dataUri = getIntent().getData();
if (dataUri != null && dataUri.getHost().equals(ContactsContract.AUTHORITY)) {
dataUri = ContactHelper.dataUriFromContactUri(this, dataUri);
}
return dataUri;
}
private void loadData(Uri dataUri) {
mDataUri = dataUri;
Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString());
// Prepare the loaders. Either re-connect with an existing ones,
// or start new ones.
getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this);
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);