extract DatabaseReadWriteInteractor
This commit is contained in:
@@ -38,8 +38,8 @@ import com.nispok.snackbar.Snackbar;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
@@ -97,7 +97,7 @@ public class TestHelpers {
|
||||
IteratorWithIOThrow<UncachedKeyRing> stream = UncachedKeyRing.fromStream(
|
||||
getInstrumentation().getContext().getAssets().open(name));
|
||||
|
||||
DatabaseInteractor helper = new DatabaseInteractor(context);
|
||||
DatabaseReadWriteInteractor helper = new DatabaseReadWriteInteractor(context);
|
||||
while(stream.hasNext()) {
|
||||
UncachedKeyRing ring = stream.next();
|
||||
if (ring.isSecret()) {
|
||||
|
||||
@@ -27,7 +27,7 @@ import android.view.View;
|
||||
import com.tokenautocomplete.TokenCompleteTextView;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter;
|
||||
|
||||
import static android.support.test.InstrumentationRegistry.getTargetContext;
|
||||
@@ -37,7 +37,7 @@ public abstract class CustomActions {
|
||||
|
||||
public static ViewAction tokenEncryptViewAddToken(long keyId) throws Exception {
|
||||
CanonicalizedPublicKeyRing ring =
|
||||
new DatabaseInteractor(getTargetContext()).getCanonicalizedPublicKeyRing(keyId);
|
||||
new DatabaseReadWriteInteractor(getTargetContext()).getCanonicalizedPublicKeyRing(keyId);
|
||||
final Object item = new KeyAdapter.KeyItem(ring);
|
||||
|
||||
return new ViewAction() {
|
||||
|
||||
@@ -51,9 +51,9 @@ import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
|
||||
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -32,9 +35,7 @@ import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public abstract class BaseOperation <T extends Parcelable> implements PassphraseCacheInterface {
|
||||
public abstract class BaseOperation<T extends Parcelable> implements PassphraseCacheInterface {
|
||||
|
||||
final public Context mContext;
|
||||
final public Progressable mProgressable;
|
||||
@@ -72,7 +73,7 @@ public abstract class BaseOperation <T extends Parcelable> implements Passphrase
|
||||
}
|
||||
|
||||
public BaseOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
mContext = context;
|
||||
mProgressable = progressable;
|
||||
mDatabaseInteractor = databaseInteractor;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
|
||||
|
||||
abstract class BaseReadWriteOperation<T extends Parcelable> extends BaseOperation<T> {
|
||||
final DatabaseReadWriteInteractor mDatabaseReadWriteInteractor;
|
||||
|
||||
BaseReadWriteOperation(Context context,
|
||||
DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
|
||||
mDatabaseReadWriteInteractor = databaseInteractor;
|
||||
}
|
||||
|
||||
BaseReadWriteOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
|
||||
mDatabaseReadWriteInteractor = databaseInteractor;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants.OpenKeychainSymm
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptData;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.BenchmarkInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -55,7 +55,7 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
|
||||
|
||||
public BenchmarkOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
|
||||
public BenchmarkOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
|
||||
progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
@@ -60,9 +60,9 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
*
|
||||
* @see CertifyActionsParcel
|
||||
*/
|
||||
public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
|
||||
public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParcel> {
|
||||
|
||||
public CertifyOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable, AtomicBoolean
|
||||
public CertifyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable, AtomicBoolean
|
||||
cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public class CertifyOperation extends BaseOperation<CertifyActionsParcel> {
|
||||
KeyFormattingUtils.convertKeyIdToHex(certifiedKey.getMasterKeyId()));
|
||||
// store the signed key in our local cache
|
||||
mDatabaseInteractor.clearLog();
|
||||
SaveKeyringResult result = mDatabaseInteractor.savePublicKeyRing(certifiedKey);
|
||||
SaveKeyringResult result = mDatabaseReadWriteInteractor.savePublicKeyRing(certifiedKey);
|
||||
|
||||
if (uploadOperation != null) {
|
||||
UploadKeyringParcel uploadInput =
|
||||
|
||||
@@ -29,16 +29,16 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
|
||||
public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||
public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockParcel> {
|
||||
|
||||
public ChangeUnlockOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
public ChangeUnlockOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||
log.add(modifyResult, 1);
|
||||
return new EditKeyResult(log, modifyResult);
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
log.add(OperationResult.LogType.MSG_ED_ERROR_KEY_NOT_FOUND, 2);
|
||||
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class ChangeUnlockOperation extends BaseOperation<ChangeUnlockParcel> {
|
||||
// It's a success, so this must be non-null now
|
||||
UncachedKeyRing ring = modifyResult.getRing();
|
||||
|
||||
SaveKeyringResult saveResult = mDatabaseInteractor
|
||||
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
|
||||
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 70, 95, 100));
|
||||
log.add(saveResult, 1);
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ConsolidateInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
|
||||
public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel> {
|
||||
public class ConsolidateOperation extends BaseReadWriteOperation<ConsolidateInputParcel> {
|
||||
|
||||
public ConsolidateOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
|
||||
public ConsolidateOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
|
||||
progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
@@ -40,9 +40,9 @@ public class ConsolidateOperation extends BaseOperation<ConsolidateInputParcel>
|
||||
public ConsolidateResult execute(ConsolidateInputParcel consolidateInputParcel,
|
||||
CryptoInputParcel cryptoInputParcel) {
|
||||
if (consolidateInputParcel.mConsolidateRecovery) {
|
||||
return mDatabaseInteractor.consolidateDatabaseStep2(mProgressable);
|
||||
return mDatabaseReadWriteInteractor.consolidateDatabaseStep2(mProgressable);
|
||||
} else {
|
||||
return mDatabaseInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
return mDatabaseReadWriteInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -41,9 +41,9 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
* a list.
|
||||
*
|
||||
*/
|
||||
public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
|
||||
public class DeleteOperation extends BaseReadWriteOperation<DeleteKeyringParcel> {
|
||||
|
||||
public DeleteOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
public DeleteOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DeleteOperation extends BaseOperation<DeleteKeyringParcel> {
|
||||
|
||||
if (isSecret && success > 0) {
|
||||
log.add(LogType.MSG_DEL_CONSOLIDATE, 1);
|
||||
ConsolidateResult sub = mDatabaseInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
ConsolidateResult sub = mDatabaseReadWriteInteractor.consolidateDatabaseStep1(mProgressable);
|
||||
log.add(sub, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
@@ -55,9 +55,9 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
* @see SaveKeyringParcel
|
||||
*
|
||||
*/
|
||||
public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
|
||||
public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel> {
|
||||
|
||||
public EditKeyOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public EditKeyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class EditKeyOperation extends BaseOperation<SaveKeyringParcel> {
|
||||
}
|
||||
|
||||
// Save the new keyring.
|
||||
SaveKeyringResult saveResult = mDatabaseInteractor
|
||||
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
|
||||
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 60, 95, 100));
|
||||
log.add(saveResult, 1);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -80,18 +80,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* method here will generally import keyrings in the order given by the
|
||||
* iterator, so this should be ensured beforehand.
|
||||
*/
|
||||
public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
public class ImportOperation extends BaseReadWriteOperation<ImportKeyringParcel> {
|
||||
|
||||
private static final int MAX_THREADS = 10;
|
||||
|
||||
public static final String CACHE_FILE_NAME = "key_import.pcl";
|
||||
|
||||
public ImportOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
|
||||
public ImportOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
|
||||
progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
public ImportOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public ImportOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -319,10 +319,10 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
ProgressScaler progressScaler = new ProgressScaler(progressable, (int) (position * progSteps),
|
||||
(int) ((position + 1) * progSteps), 100);
|
||||
if (key.isSecret()) {
|
||||
result = mDatabaseInteractor.saveSecretKeyRing(key, progressScaler,
|
||||
result = mDatabaseReadWriteInteractor.saveSecretKeyRing(key, progressScaler,
|
||||
canKeyRings, skipSave);
|
||||
} else {
|
||||
result = mDatabaseInteractor.savePublicKeyRing(key, progressScaler,
|
||||
result = mDatabaseReadWriteInteractor.savePublicKeyRing(key, progressScaler,
|
||||
entry.mExpectedFingerprint, canKeyRings, skipSave);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
// synonymous to isDownloadFromKeyserver.
|
||||
// If no byte data was supplied, import from keyserver took place
|
||||
// this prevents file imports being noted as keyserver imports
|
||||
mDatabaseInteractor.renewKeyLastUpdatedTime(key.getMasterKeyId(),
|
||||
mDatabaseReadWriteInteractor.renewKeyLastUpdatedTime(key.getMasterKeyId(),
|
||||
GregorianCalendar.getInstance().getTimeInMillis(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
}
|
||||
@@ -366,7 +366,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
setPreventCancel();
|
||||
ConsolidateResult result;
|
||||
synchronized (mDatabaseInteractor) {
|
||||
result = mDatabaseInteractor.consolidateDatabaseStep1(progressable);
|
||||
result = mDatabaseReadWriteInteractor.consolidateDatabaseStep1(progressable);
|
||||
}
|
||||
log.add(result, 1);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.KeybaseVerificationParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -59,7 +59,7 @@ import de.measite.minidns.record.TXT;
|
||||
|
||||
public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificationParcel> {
|
||||
|
||||
public KeybaseVerificationOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public KeybaseVerificationOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -47,9 +47,8 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
* without secret key material, using a GNU_DUMMY s2k type.
|
||||
*
|
||||
*/
|
||||
public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
||||
|
||||
public PromoteKeyOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
public class PromoteKeyOperation extends BaseReadWriteOperation<PromoteKeyringParcel> {
|
||||
public PromoteKeyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class PromoteKeyOperation extends BaseOperation<PromoteKeyringParcel> {
|
||||
setPreventCancel();
|
||||
|
||||
// Save the new keyring.
|
||||
SaveKeyringResult saveResult = mDatabaseInteractor
|
||||
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
|
||||
.saveSecretKeyRing(promotedRing, new ProgressScaler(mProgressable, 60, 95, 100));
|
||||
log.add(saveResult, 1);
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ import org.sufficientlysecure.keychain.operations.results.RevokeResult;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.RevokeKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
|
||||
public class RevokeOperation extends BaseReadWriteOperation<RevokeKeyringParcel> {
|
||||
|
||||
public RevokeOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
public RevokeOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
|
||||
saveKeyringParcel.mRevokeSubKeys.add(masterKeyId);
|
||||
|
||||
EditKeyResult revokeAndUploadResult = new EditKeyOperation(mContext,
|
||||
mDatabaseInteractor, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
|
||||
mDatabaseReadWriteInteractor, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
|
||||
|
||||
if (revokeAndUploadResult.isPending()) {
|
||||
return revokeAndUploadResult;
|
||||
@@ -97,7 +97,7 @@ public class RevokeOperation extends BaseOperation<RevokeKeyringParcel> {
|
||||
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
|
||||
}
|
||||
|
||||
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "could not find key to revoke", e);
|
||||
log.add(OperationResult.LogType.MSG_REVOKE_ERROR_KEY_FAIL, 1);
|
||||
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
package org.sufficientlysecure.keychain.operations;
|
||||
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -36,15 +40,11 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.RequiredInputType;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.SecurityTokenSignOperationsBuilder;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
||||
/**
|
||||
* This is a high-level operation, which encapsulates one or more sign/encrypt
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -59,7 +60,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
|
||||
|
||||
public UploadOperation(Context context, DatabaseInteractor databaseInteractor,
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
|
||||
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(canonicalizedRing.getMasterKeyId()));
|
||||
return (CanonicalizedPublicKeyRing) canonicalizedRing;
|
||||
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
log.add(LogType.MSG_UPLOAD_ERROR_NOT_FOUND, 1);
|
||||
return null;
|
||||
} catch (IOException | PgpGeneralException e) {
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.bouncycastle.openpgp.operator.jcajce.SessionKeySecretKeyDecryptorBuil
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
@@ -127,7 +127,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
* passphrase in the process.
|
||||
*
|
||||
* This method can potentially take a LONG time (i.e. seconds), so it should only
|
||||
* ever be called by {@link DatabaseInteractor} for the purpose of caching its output
|
||||
* ever be called by {@link DatabaseReadWriteInteractor} for the purpose of caching its output
|
||||
* in the database.
|
||||
*/
|
||||
public SecretKeyType getSecretKeyTypeSuperExpensive() {
|
||||
|
||||
@@ -71,8 +71,9 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -668,7 +669,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
encryptedDataAsymmetric = encData;
|
||||
decryptionKey = candidateDecryptionKey;
|
||||
|
||||
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
// continue with the next packet in the while loop
|
||||
log.add(LogType.MSG_DC_ASKIP_NO_KEY, indent + 1);
|
||||
continue;
|
||||
|
||||
@@ -44,8 +44,9 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -292,7 +293,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
|
||||
}
|
||||
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
log.add(LogType.MSG_PSE_ERROR_SIGN_KEY, indent);
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
} catch (PgpGeneralException e) {
|
||||
@@ -356,7 +357,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
log.add(LogType.MSG_PSE_ERROR_REVOKED_OR_EXPIRED, indent);
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
log.add(LogType.MSG_PSE_KEY_UNKNOWN, indent + 1,
|
||||
KeyFormattingUtils.convertKeyIdToHex(id));
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProv
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -161,7 +162,7 @@ class PgpSignatureChecker {
|
||||
signingKey = keyCandidate;
|
||||
onePassSignature = sigList.get(i);
|
||||
return;
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found, trying next signature...");
|
||||
}
|
||||
}
|
||||
@@ -184,7 +185,7 @@ class PgpSignatureChecker {
|
||||
signingKey = keyCandidate;
|
||||
signature = sigList.get(i);
|
||||
return;
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found, trying next signature...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
Object data = mDatabaseInteractor.getGenericData(mUri,
|
||||
KeychainContract.KeyRings.MASTER_KEY_ID, DatabaseInteractor.FIELD_TYPE_INTEGER);
|
||||
return (Long) data;
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
Object data = mDatabaseInteractor.getGenericData(mUri,
|
||||
KeychainContract.KeyRings.FINGERPRINT, DatabaseInteractor.FIELD_TYPE_BLOB);
|
||||
return (byte[]) data;
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeychainContract.KeyRings.USER_ID,
|
||||
DatabaseInteractor.FIELD_TYPE_STRING);
|
||||
return (String) data;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeyRings.NAME,
|
||||
DatabaseInteractor.FIELD_TYPE_STRING);
|
||||
return (String) data;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeyRings.EMAIL,
|
||||
DatabaseInteractor.FIELD_TYPE_STRING);
|
||||
return (String) data;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeyRings.COMMENT,
|
||||
DatabaseInteractor.FIELD_TYPE_STRING);
|
||||
return (String) data;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeychainContract.KeyRings.IS_REVOKED,
|
||||
DatabaseInteractor.FIELD_TYPE_INTEGER);
|
||||
return (Long) data > 0;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeychainContract.KeyRings.HAS_CERTIFY,
|
||||
DatabaseInteractor.FIELD_TYPE_NULL);
|
||||
return !((Boolean) data);
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeyRings.HAS_ENCRYPT,
|
||||
DatabaseInteractor.FIELD_TYPE_INTEGER);
|
||||
return (Long) data;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeyRings.HAS_SIGN,
|
||||
DatabaseInteractor.FIELD_TYPE_INTEGER);
|
||||
return (Long) data;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeychainContract.KeyRings.VERIFIED,
|
||||
DatabaseInteractor.FIELD_TYPE_INTEGER);
|
||||
return ((Long) data).intValue();
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
||||
DatabaseInteractor.FIELD_TYPE_INTEGER);
|
||||
return (Long) data > 0;
|
||||
} catch(DatabaseInteractor.NotFoundException e) {
|
||||
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -63,10 +63,10 @@ import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAccounts;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.remote.OpenPgpServiceKeyIdExtractor.KeyIdResult;
|
||||
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -97,7 +97,7 @@ public class OpenPgpService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mApiPermissionHelper = new ApiPermissionHelper(this, new ApiDataAccessObject(this));
|
||||
mDatabaseInteractor = new DatabaseInteractor(this);
|
||||
mDatabaseInteractor = new DatabaseInteractor(getContentResolver());
|
||||
mApiDao = new ApiDataAccessObject(this);
|
||||
|
||||
mApiPendingIntentFactory = new ApiPendingIntentFactory(getBaseContext());
|
||||
@@ -167,7 +167,7 @@ public class OpenPgpService extends Service {
|
||||
}
|
||||
|
||||
// execute PGP operation!
|
||||
PgpSignEncryptOperation pse = new PgpSignEncryptOperation(this, new DatabaseInteractor(this), null);
|
||||
PgpSignEncryptOperation pse = new PgpSignEncryptOperation(this, mDatabaseInteractor, null);
|
||||
PgpSignEncryptResult pgpResult = pse.execute(pseInput, inputParcel, inputData, outputStream);
|
||||
|
||||
if (pgpResult.isPending()) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
@@ -40,7 +41,7 @@ class RequestKeyPermissionPresenter {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
ApiDataAccessObject apiDataAccessObject = new ApiDataAccessObject(context);
|
||||
ApiPermissionHelper apiPermissionHelper = new ApiPermissionHelper(context, apiDataAccessObject);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(context);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(context);
|
||||
|
||||
return new RequestKeyPermissionPresenter(context, apiDataAccessObject, apiPermissionHelper, packageManager,
|
||||
databaseInteractor);
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler.MessageStatus;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -111,36 +111,37 @@ public class KeychainService extends Service implements Progressable {
|
||||
|
||||
// just for brevity
|
||||
KeychainService outerThis = KeychainService.this;
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(outerThis);
|
||||
if (inputParcel instanceof SignEncryptParcel) {
|
||||
op = new SignEncryptOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new SignEncryptOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof PgpDecryptVerifyInputParcel) {
|
||||
op = new PgpDecryptVerifyOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new PgpDecryptVerifyOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof SaveKeyringParcel) {
|
||||
op = new EditKeyOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new EditKeyOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof ChangeUnlockParcel) {
|
||||
op = new ChangeUnlockOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new ChangeUnlockOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof RevokeKeyringParcel) {
|
||||
op = new RevokeOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new RevokeOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof CertifyActionsParcel) {
|
||||
op = new CertifyOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new CertifyOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof DeleteKeyringParcel) {
|
||||
op = new DeleteOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new DeleteOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof PromoteKeyringParcel) {
|
||||
op = new PromoteKeyOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new PromoteKeyOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof ImportKeyringParcel) {
|
||||
op = new ImportOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new ImportOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof BackupKeyringParcel) {
|
||||
op = new BackupOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new BackupOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof UploadKeyringParcel) {
|
||||
op = new UploadOperation(outerThis, new DatabaseInteractor(outerThis), outerThis, mActionCanceled);
|
||||
op = new UploadOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||
} else if (inputParcel instanceof ConsolidateInputParcel) {
|
||||
op = new ConsolidateOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new ConsolidateOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof KeybaseVerificationParcel) {
|
||||
op = new KeybaseVerificationOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new KeybaseVerificationOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof InputDataParcel) {
|
||||
op = new InputDataOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new InputDataOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else if (inputParcel instanceof BenchmarkInputParcel) {
|
||||
op = new BenchmarkOperation(outerThis, new DatabaseInteractor(outerThis), outerThis);
|
||||
op = new BenchmarkOperation(outerThis, databaseInteractor, outerThis);
|
||||
} else {
|
||||
throw new AssertionError("Unrecognized input parcel in KeychainService!");
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.network.NetworkReceiver;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.OrbotRequiredDialogActivity;
|
||||
@@ -320,7 +320,7 @@ public class KeyserverSyncAdapterService extends Service {
|
||||
private ImportKeyResult directUpdate(Context context, ArrayList<ParcelableKeyRing> keyList,
|
||||
CryptoInputParcel cryptoInputParcel) {
|
||||
Log.d(Constants.TAG, "Starting normal update");
|
||||
ImportOperation importOp = new ImportOperation(context, new DatabaseInteractor(context), null);
|
||||
ImportOperation importOp = new ImportOperation(context, new DatabaseReadWriteInteractor(context), null);
|
||||
return importOp.execute(
|
||||
new ImportKeyringParcel(keyList,
|
||||
Preferences.getPreferences(context).getPreferredKeyserver()),
|
||||
@@ -380,7 +380,7 @@ public class KeyserverSyncAdapterService extends Service {
|
||||
new OperationResult.OperationLog());
|
||||
}
|
||||
ImportKeyResult result =
|
||||
new ImportOperation(context, new DatabaseInteractor(context), null, mCancelled)
|
||||
new ImportOperation(context, new DatabaseReadWriteInteractor(context), null, mCancelled)
|
||||
.execute(
|
||||
new ImportKeyringParcel(
|
||||
keyWrapper,
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
@@ -224,7 +224,7 @@ public class PassphraseCacheService extends Service {
|
||||
/**
|
||||
* Internal implementation to get cached passphrase.
|
||||
*/
|
||||
private Passphrase getCachedPassphraseImpl(long masterKeyId, long subKeyId) throws DatabaseInteractor.NotFoundException {
|
||||
private Passphrase getCachedPassphraseImpl(long masterKeyId, long subKeyId) throws DatabaseReadWriteInteractor.NotFoundException {
|
||||
// on "none" key, just do nothing
|
||||
if (masterKeyId == Constants.key.none) {
|
||||
return null;
|
||||
@@ -245,16 +245,16 @@ public class PassphraseCacheService extends Service {
|
||||
+ masterKeyId + ", subKeyId " + subKeyId);
|
||||
|
||||
// get the type of key (from the database)
|
||||
CachedPublicKeyRing keyRing = new DatabaseInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
||||
CachedPublicKeyRing keyRing = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
||||
SecretKeyType keyType = keyRing.getSecretKeyType(subKeyId);
|
||||
|
||||
switch (keyType) {
|
||||
case PASSPHRASE_EMPTY:
|
||||
return new Passphrase("");
|
||||
case UNAVAILABLE:
|
||||
throw new DatabaseInteractor.NotFoundException("secret key for this subkey is not available");
|
||||
throw new DatabaseReadWriteInteractor.NotFoundException("secret key for this subkey is not available");
|
||||
case GNU_DUMMY:
|
||||
throw new DatabaseInteractor.NotFoundException("secret key for stripped subkey is not available");
|
||||
throw new DatabaseReadWriteInteractor.NotFoundException("secret key for stripped subkey is not available");
|
||||
}
|
||||
|
||||
// get cached passphrase
|
||||
@@ -398,7 +398,7 @@ public class PassphraseCacheService extends Service {
|
||||
bundle.putParcelable(EXTRA_PASSPHRASE, passphrase);
|
||||
msg.setData(bundle);
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "PassphraseCacheService: Passphrase for unknown key was requested!");
|
||||
msg.what = MSG_PASSPHRASE_CACHE_GET_KEY_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.experimental.SentenceConfirm;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.base.LoaderFragment;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -213,7 +213,7 @@ public class CertifyFingerprintFragment extends LoaderFragment implements
|
||||
private void certify(Uri dataUri) {
|
||||
long keyId = 0;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(getActivity())
|
||||
keyId = new DatabaseReadWriteInteractor(getActivity())
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -68,7 +68,7 @@ public class CertifyKeyFragment
|
||||
.getLongExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none);
|
||||
if (certifyKeyId != Constants.key.none) {
|
||||
try {
|
||||
CachedPublicKeyRing key = (new DatabaseInteractor(getActivity()))
|
||||
CachedPublicKeyRing key = (new DatabaseReadWriteInteractor(getActivity()))
|
||||
.getCachedPublicKeyRing(certifyKeyId);
|
||||
if (key.canCertify()) {
|
||||
mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
|
||||
|
||||
@@ -29,8 +29,8 @@ import android.support.v4.app.TaskStackBuilder;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.securitytoken.KeyFormat;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -180,7 +180,7 @@ public class CreateKeyActivity extends BaseSecurityTokenActivity {
|
||||
if (containsKeys(mScannedFingerprints)) {
|
||||
try {
|
||||
long masterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(mScannedFingerprints);
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
||||
ring.getMasterKeyId();
|
||||
|
||||
Intent intent = new Intent(this, ViewKeyActivity.class);
|
||||
|
||||
@@ -43,8 +43,8 @@ import org.sufficientlysecure.keychain.operations.results.UploadResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
@@ -411,7 +411,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
CreateKeyActivity activity = (CreateKeyActivity) getActivity();
|
||||
|
||||
final SaveKeyringParcel changeKeyringParcel;
|
||||
CachedPublicKeyRing key = (new DatabaseInteractor(activity))
|
||||
CachedPublicKeyRing key = (new DatabaseReadWriteInteractor(activity))
|
||||
.getCachedPublicKeyRing(saveKeyResult.mMasterKeyId);
|
||||
try {
|
||||
changeKeyringParcel = new SaveKeyringParcel(key.getMasterKeyId(), key.getFingerprint());
|
||||
|
||||
@@ -45,9 +45,9 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -192,7 +192,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
try {
|
||||
|
||||
Intent viewKeyIntent = new Intent(getActivity(), ViewKeyActivity.class);
|
||||
long masterKeyId = new DatabaseInteractor(getActivity()).getCachedPublicKeyRing(
|
||||
long masterKeyId = new DatabaseReadWriteInteractor(getActivity()).getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(keyId)
|
||||
).getMasterKeyId();
|
||||
viewKeyIntent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableHkpKeyserver;
|
||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.RevokeResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
|
||||
@@ -89,7 +90,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
if (mMasterKeyIds.length == 1 && mHasSecret) {
|
||||
// if mMasterKeyIds.length == 0 we let the DeleteOperation respond
|
||||
try {
|
||||
HashMap<String, Object> data = new DatabaseInteractor(this).getUnifiedData(
|
||||
HashMap<String, Object> data = new DatabaseReadWriteInteractor(this).getUnifiedData(
|
||||
mMasterKeyIds[0], new String[]{
|
||||
KeychainContract.KeyRings.NAME,
|
||||
KeychainContract.KeyRings.IS_REVOKED
|
||||
@@ -112,7 +113,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
} else {
|
||||
showRevokeDeleteDialog(name);
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG,
|
||||
"Secret key to delete not found at DeleteKeyDialogActivity for "
|
||||
+ mMasterKeyIds[0], e);
|
||||
@@ -269,7 +270,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
long masterKeyId = masterKeyIds[0];
|
||||
|
||||
try {
|
||||
HashMap<String, Object> data = new DatabaseInteractor(activity).getUnifiedData(
|
||||
HashMap<String, Object> data = new DatabaseReadWriteInteractor(activity).getUnifiedData(
|
||||
masterKeyId, new String[]{
|
||||
KeychainContract.KeyRings.NAME,
|
||||
KeychainContract.KeyRings.HAS_ANY_SECRET
|
||||
@@ -293,7 +294,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
} else {
|
||||
mMainMessage.setText(getString(R.string.public_key_deletetion_confirmation, name));
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
dismiss();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ import org.sufficientlysecure.keychain.operations.results.UploadResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
@@ -170,7 +170,7 @@ public class EditIdentitiesFragment extends Fragment
|
||||
try {
|
||||
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||
CachedPublicKeyRing keyRing =
|
||||
new DatabaseInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
new DatabaseReadWriteInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
long masterKeyId = keyRing.getMasterKeyId();
|
||||
|
||||
// check if this is a master secret key we can work with
|
||||
|
||||
@@ -48,9 +48,9 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
@@ -203,7 +203,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
try {
|
||||
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||
CachedPublicKeyRing keyRing =
|
||||
new DatabaseInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
new DatabaseReadWriteInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
long masterKeyId = keyRing.getMasterKeyId();
|
||||
|
||||
// check if this is a master secret key we can work with
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
@@ -114,7 +115,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mDatabaseInteractor = new DatabaseInteractor(getActivity());
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(getActivity());
|
||||
|
||||
// preselect keys given, from state or arguments
|
||||
if (savedInstanceState == null) {
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.sufficientlysecure.keychain.operations.results.BenchmarkResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||
@@ -486,7 +487,7 @@ public class KeyListFragment extends RecyclerFragment<KeySectionedListAdapter>
|
||||
return;
|
||||
}
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(activity);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(activity);
|
||||
Cursor cursor = databaseInteractor.getContentResolver().query(
|
||||
KeyRings.buildUnifiedKeyRingsUri(), new String[]{
|
||||
KeyRings.FINGERPRINT
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
@@ -112,7 +113,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
// handle empty passphrases by directly returning an empty crypto input parcel
|
||||
try {
|
||||
CachedPublicKeyRing pubRing =
|
||||
new DatabaseInteractor(this).getCachedPublicKeyRing(requiredInput.getMasterKeyId());
|
||||
new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(requiredInput.getMasterKeyId());
|
||||
// use empty passphrase for empty passphrase
|
||||
if (pubRing.getSecretKeyType(requiredInput.getSubKeyId()) == SecretKeyType.PASSPHRASE_EMPTY) {
|
||||
// also return passphrase back to activity
|
||||
@@ -231,7 +232,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
try {
|
||||
long subKeyId = mRequiredInput.getSubKeyId();
|
||||
|
||||
DatabaseInteractor helper = new DatabaseInteractor(activity);
|
||||
DatabaseInteractor helper = new DatabaseReadWriteInteractor(activity);
|
||||
CachedPublicKeyRing cachedPublicKeyRing = helper.getCachedPublicKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||
// yes the inner try/catch block is necessary, otherwise the final variable
|
||||
@@ -266,7 +267,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
throw new AssertionError("Unhandled SecretKeyType (should not happen)");
|
||||
}
|
||||
|
||||
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
alert.setTitle(R.string.title_key_not_found);
|
||||
alert.setMessage(getString(R.string.key_not_found, mRequiredInput.getSubKeyId()));
|
||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@@ -457,7 +458,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
|
||||
Long subKeyId = mRequiredInput.getSubKeyId();
|
||||
CanonicalizedSecretKeyRing secretKeyRing =
|
||||
new DatabaseInteractor(getActivity()).getCanonicalizedSecretKeyRing(
|
||||
new DatabaseReadWriteInteractor(getActivity()).getCanonicalizedSecretKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||
CanonicalizedSecretKey secretKeyToUnlock =
|
||||
secretKeyRing.getSecretKey(subKeyId);
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.widget.ImageView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||
@@ -74,7 +75,7 @@ public class QrCodeViewActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
try {
|
||||
byte[] blob = (byte[]) databaseInteractor.getGenericData(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
|
||||
@@ -102,7 +103,7 @@ public class QrCodeViewActivity extends BaseActivity {
|
||||
mQrCode.setImageBitmap(scaled);
|
||||
}
|
||||
});
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "key not found!", e);
|
||||
Notify.create(this, R.string.error_key_not_found, Style.ERROR).show();
|
||||
ActivityCompat.finishAfterTransition(QrCodeViewActivity.this);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
@@ -105,7 +106,7 @@ public class SafeSlingerActivity extends BaseActivity
|
||||
// retrieve public key blob and start SafeSlinger
|
||||
Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(masterKeyId);
|
||||
try {
|
||||
byte[] keyBlob = (byte[]) new DatabaseInteractor(this).getGenericData(
|
||||
byte[] keyBlob = (byte[]) new DatabaseReadWriteInteractor(this).getGenericData(
|
||||
uri, KeychainContract.KeyRingData.KEY_RING_DATA, DatabaseInteractor.FIELD_TYPE_BLOB);
|
||||
|
||||
Intent slingerIntent = new Intent(this, ExchangeActivity.class);
|
||||
@@ -114,7 +115,7 @@ public class SafeSlingerActivity extends BaseActivity
|
||||
slingerIntent.putExtra(ExchangeConfig.extra.USER_DATA, keyBlob);
|
||||
slingerIntent.putExtra(ExchangeConfig.extra.HOST_NAME, Constants.SAFESLINGER_SERVER);
|
||||
startActivityForResult(slingerIntent, REQUEST_CODE_SAFE_SLINGER);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "personal key not found", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.securitytoken.KeyType;
|
||||
@@ -193,12 +194,12 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity {
|
||||
throw new IOException(getString(R.string.error_wrong_security_token));
|
||||
}
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
CanonicalizedPublicKeyRing publicKeyRing;
|
||||
try {
|
||||
publicKeyRing = databaseInteractor.getCanonicalizedPublicKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mRequiredInput.getMasterKeyId()));
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new IOException("Couldn't find subkey for key to token operation.");
|
||||
}
|
||||
|
||||
@@ -232,13 +233,13 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity {
|
||||
mSecurityTokenHelper.setPin(new Passphrase("123456"));
|
||||
mSecurityTokenHelper.setAdminPin(new Passphrase("12345678"));
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
CanonicalizedSecretKeyRing secretKeyRing;
|
||||
try {
|
||||
secretKeyRing = databaseInteractor.getCanonicalizedSecretKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mRequiredInput.getMasterKeyId())
|
||||
);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new IOException("Couldn't find subkey for key to token operation.");
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
@@ -184,7 +185,7 @@ public class ViewCertActivity extends BaseActivity
|
||||
Intent viewIntent = new Intent(ViewCertActivity.this, ViewKeyActivity.class);
|
||||
|
||||
try {
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(ViewCertActivity.this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(ViewCertActivity.this);
|
||||
long signerMasterKeyId = databaseInteractor.getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mCertifierKeyId)).getMasterKeyId();
|
||||
viewIntent.setData(KeyRings.buildGenericKeyRingUri(signerMasterKeyId));
|
||||
|
||||
@@ -72,6 +72,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
@@ -185,7 +186,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mDatabaseInteractor = new DatabaseInteractor(this);
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
mImportOpHelper = new CryptoOperationHelper<>(1, this, this, null);
|
||||
|
||||
setTitle(null);
|
||||
@@ -400,7 +401,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
case R.id.menu_key_view_refresh: {
|
||||
try {
|
||||
updateFromKeyserver(mDataUri, mDatabaseInteractor);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Notify.create(this, R.string.error_key_not_found, Notify.Style.ERROR).show();
|
||||
}
|
||||
return true;
|
||||
@@ -741,7 +742,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
return;
|
||||
}
|
||||
try {
|
||||
long keyId = new DatabaseInteractor(this)
|
||||
long keyId = new DatabaseReadWriteInteractor(this)
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
long[] encryptionKeyIds = new long[]{keyId};
|
||||
@@ -765,7 +766,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
private void startSafeSlinger(Uri dataUri) {
|
||||
long keyId = 0;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(this)
|
||||
keyId = new DatabaseReadWriteInteractor(this)
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
@@ -1119,7 +1120,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
|
||||
|
||||
private void updateFromKeyserver(Uri dataUri, DatabaseInteractor databaseInteractor)
|
||||
throws DatabaseInteractor.NotFoundException {
|
||||
throws DatabaseReadWriteInteractor.NotFoundException {
|
||||
|
||||
mIsRefreshing = true;
|
||||
mRefreshItem.setEnabled(false);
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.astuetz.PagerSlidingTabStrip;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||
@@ -88,7 +89,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
||||
}
|
||||
});
|
||||
|
||||
mDatabaseInteractor = new DatabaseInteractor(this);
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
|
||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
@@ -93,7 +94,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
View root = super.onCreateView(inflater, superContainer, savedInstanceState);
|
||||
View view = inflater.inflate(R.layout.view_key_adv_share_fragment, getContainer());
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(ViewKeyAdvShareFragment.this.getActivity());
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(ViewKeyAdvShareFragment.this.getActivity());
|
||||
mNfcHelper = new NfcHelper(getActivity(), databaseInteractor);
|
||||
|
||||
mFingerprintView = (TextView) view.findViewById(R.id.view_key_fingerprint);
|
||||
@@ -200,7 +201,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
private void startSafeSlinger(Uri dataUri) {
|
||||
long keyId = 0;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(getActivity())
|
||||
keyId = new DatabaseReadWriteInteractor(getActivity())
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
@@ -216,7 +217,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
if (activity == null || mFingerprint == null) {
|
||||
return;
|
||||
}
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(activity);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(activity);
|
||||
|
||||
try {
|
||||
String content = databaseInteractor.getKeyRingAsArmoredString(
|
||||
@@ -273,7 +274,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
} catch (PgpGeneralException | IOException e) {
|
||||
Log.e(Constants.TAG, "error processing key!", e);
|
||||
Notify.create(activity, R.string.error_key_processing, Notify.Style.ERROR).show();
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "key not found!", e);
|
||||
Notify.create(activity, R.string.error_key_not_found, Notify.Style.ERROR).show();
|
||||
}
|
||||
@@ -457,7 +458,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
private void uploadToKeyserver() {
|
||||
long keyId;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(getActivity())
|
||||
keyId = new DatabaseReadWriteInteractor(getActivity())
|
||||
.getCachedPublicKeyRing(mDataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
@@ -74,7 +75,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
mListener = listener;
|
||||
mNonInteractive = nonInteractive;
|
||||
|
||||
mDatabaseInteractor = new DatabaseInteractor(activity);
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(activity);
|
||||
}
|
||||
|
||||
public void setData(List<ImportKeysListEntry> data) {
|
||||
@@ -95,7 +96,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
}
|
||||
keyState.mAlreadyPresent = true;
|
||||
keyState.mVerified = keyRing.getVerified() > 0;
|
||||
} catch (DatabaseInteractor.NotFoundException | PgpKeyNotFoundException ignored) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException | PgpKeyNotFoundException ignored) {
|
||||
}
|
||||
|
||||
mKeyStates[i] = keyState;
|
||||
|
||||
@@ -37,8 +37,8 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -105,7 +105,7 @@ public abstract class BaseSecurityTokenActivity extends BaseActivity
|
||||
final long subKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(mSecurityTokenFingerprints);
|
||||
|
||||
try {
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(this).getCachedPublicKeyRing(
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||
long masterKeyId = ring.getMasterKeyId();
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class LinkedIdWizard extends BaseActivity {
|
||||
try {
|
||||
Uri uri = getIntent().getData();
|
||||
uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(uri);
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(this).getCachedPublicKeyRing(uri);
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(uri);
|
||||
if (!ring.hasAnySecret()) {
|
||||
Log.e(Constants.TAG, "Linked Identities can only be added to secret keys!");
|
||||
finish();
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.provider.Settings;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
@@ -132,7 +133,7 @@ public class NfcHelper {
|
||||
blobUri,
|
||||
KeychainContract.KeyRingData.KEY_RING_DATA,
|
||||
DatabaseInteractor.FIELD_TYPE_BLOB);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "key not found!", e);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
|
||||
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
@@ -135,7 +135,7 @@ public class BackupOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -150,7 +150,7 @@ public class BackupOperationTest {
|
||||
@Test
|
||||
public void testExportAllLocalStripped() throws Exception {
|
||||
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
// make sure there is a local cert (so the later checks that there are none are meaningful)
|
||||
assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
|
||||
@@ -249,7 +249,7 @@ public class BackupOperationTest {
|
||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||
|
||||
BackupOperation op = new BackupOperation(spyApplication,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
BackupKeyringParcel parcel = new BackupKeyringParcel(
|
||||
new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri);
|
||||
@@ -306,7 +306,7 @@ public class BackupOperationTest {
|
||||
|
||||
{ // export encrypted
|
||||
BackupOperation op = new BackupOperation(spyApplication,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
BackupKeyringParcel parcel = new BackupKeyringParcel(
|
||||
new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri);
|
||||
@@ -324,7 +324,7 @@ public class BackupOperationTest {
|
||||
|
||||
{
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(outStream.toByteArray());
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowLog;
|
||||
import org.sufficientlysecure.keychain.KeychainTestRunner;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.BenchmarkInputParcel;
|
||||
|
||||
import java.io.PrintStream;
|
||||
@@ -47,7 +47,7 @@ public class BenchmarkOperationTest {
|
||||
@Test
|
||||
public void testBenchmark() throws Exception {
|
||||
BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
op.execute(new BenchmarkInputParcel(), null);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
@@ -117,7 +117,7 @@ public class CertifyOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -132,7 +132,7 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testSelfCertifyFlag() throws Exception {
|
||||
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
|
||||
Assert.assertEquals("secret key must be marked self-certified in database",
|
||||
// TODO this should be more correctly be VERIFIED_SELF at some point!
|
||||
@@ -143,10 +143,10 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testCertifyId() throws Exception {
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||
Certs.UNVERIFIED, ring.getVerified());
|
||||
@@ -160,7 +160,7 @@ public class CertifyOperationTest {
|
||||
Assert.assertTrue("certification must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("new key must be verified now",
|
||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||
@@ -171,10 +171,10 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testCertifyAttribute() throws Exception {
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||
Certs.UNVERIFIED, ring.getVerified());
|
||||
@@ -188,7 +188,7 @@ public class CertifyOperationTest {
|
||||
Assert.assertTrue("certification must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||
Assert.assertEquals("new key must be verified now",
|
||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||
@@ -200,7 +200,7 @@ public class CertifyOperationTest {
|
||||
@Test
|
||||
public void testCertifySelf() throws Exception {
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
||||
@@ -217,7 +217,7 @@ public class CertifyOperationTest {
|
||||
public void testCertifyNonexistent() throws Exception {
|
||||
|
||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
{
|
||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedPublicKey;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
@@ -90,7 +90,7 @@ public class PromoteKeyOperationTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -104,14 +104,14 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromote() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null);
|
||||
|
||||
Assert.assertTrue("promotion must succeed", result.success());
|
||||
|
||||
{
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
|
||||
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
|
||||
|
||||
@@ -128,7 +128,7 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromoteDivert() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||
|
||||
@@ -137,7 +137,7 @@ public class PromoteKeyOperationTest {
|
||||
Assert.assertTrue("promotion must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||
|
||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||
@@ -153,7 +153,7 @@ public class PromoteKeyOperationTest {
|
||||
@Test
|
||||
public void testPromoteDivertSpecific() throws Exception {
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null, null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||
|
||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||
|
||||
@@ -167,7 +167,7 @@ public class PromoteKeyOperationTest {
|
||||
Assert.assertTrue("promotion must succeed", result.success());
|
||||
|
||||
{
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseInteractor(RuntimeEnvironment.application)
|
||||
CanonicalizedSecretKeyRing ring = new DatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||
|
||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.KeychainTestRunner;
|
||||
import org.sufficientlysecure.keychain.operations.InputDataOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.InputDataResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
|
||||
import org.sufficientlysecure.keychain.service.InputDataParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -126,7 +126,7 @@ public class InputDataOperationTest {
|
||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||
|
||||
InputDataOperation op = new InputDataOperation(spyApplication,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputDataParcel input = new InputDataParcel(fakeInputUri, null);
|
||||
|
||||
@@ -306,7 +306,7 @@ public class InputDataOperationTest {
|
||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||
|
||||
InputDataOperation op = new InputDataOperation(spyApplication,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputDataParcel input = new InputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
|
||||
return op.execute(input, new CryptoInputParcel());
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||
@@ -149,7 +149,7 @@ public class PgpEncryptDecryptTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
// don't log verbosely here, we're not here to test imports
|
||||
ShadowLog.stream = oldShadowStream;
|
||||
@@ -172,7 +172,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -197,7 +197,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(
|
||||
@@ -227,7 +227,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
@@ -249,7 +249,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(true);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
@@ -270,7 +270,7 @@ public class PgpEncryptDecryptTest {
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
|
||||
input.setAllowSymmetricDecryption(false);
|
||||
DecryptVerifyResult result = op.execute(input,
|
||||
@@ -297,7 +297,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -353,7 +353,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -415,7 +415,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -472,7 +472,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -575,7 +575,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -626,11 +626,11 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
|
||||
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
|
||||
|
||||
@@ -648,11 +648,11 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
|
||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
|
||||
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
|
||||
|
||||
@@ -675,7 +675,7 @@ public class PgpEncryptDecryptTest {
|
||||
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
|
||||
new CryptoInputParcel(new Date(), mKeyPhrase1));
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -730,7 +730,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -824,7 +824,7 @@ public class PgpEncryptDecryptTest {
|
||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||
|
||||
// delete first key from database
|
||||
new DatabaseInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||
);
|
||||
|
||||
@@ -859,7 +859,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -907,7 +907,7 @@ public class PgpEncryptDecryptTest {
|
||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||
|
||||
// delete first key from database
|
||||
new DatabaseInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||
);
|
||||
|
||||
@@ -946,7 +946,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -1018,7 +1018,7 @@ public class PgpEncryptDecryptTest {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||
|
||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null);
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
||||
|
||||
InputData data = new InputData(in, in.available());
|
||||
|
||||
@@ -1069,7 +1069,7 @@ public class PgpEncryptDecryptTest {
|
||||
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
||||
|
||||
return new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||
new DatabaseInteractor(RuntimeEnvironment.application), null) {
|
||||
new DatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
|
||||
@Override
|
||||
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
||||
throws NoSecretKeyException {
|
||||
|
||||
@@ -43,7 +43,7 @@ import java.util.Iterator;
|
||||
@RunWith(KeychainTestRunner.class)
|
||||
public class DatabaseInteractorSaveTest {
|
||||
|
||||
DatabaseInteractor mDatabaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor mDatabaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpOnce() throws Exception {
|
||||
@@ -61,17 +61,17 @@ public class DatabaseInteractorSaveTest {
|
||||
SaveKeyringResult result;
|
||||
|
||||
// insert both keys, second should fail
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
Assert.assertFalse("second keyring import should fail", result.success());
|
||||
|
||||
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
|
||||
|
||||
// and the other way around
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||
Assert.assertFalse("second keyring import should fail", result.success());
|
||||
|
||||
}
|
||||
@@ -90,13 +90,13 @@ public class DatabaseInteractorSaveTest {
|
||||
SaveKeyringResult result;
|
||||
|
||||
// insert secret, this should fail because of missing self-cert
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
||||
|
||||
// insert pubkey, then seckey - both should succeed
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||
Assert.assertTrue("public keyring import should succeed", result.success());
|
||||
result = new DatabaseInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
result = new DatabaseReadWriteInteractor(RuntimeEnvironment.application).saveSecretKeyRing(seckey, new ProgressScaler());
|
||||
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
||||
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public class InteropTest {
|
||||
final Uri verifyUri = verify != null ?
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null;
|
||||
|
||||
DatabaseInteractor helper = new DatabaseInteractor(RuntimeEnvironment.application) {
|
||||
DatabaseReadWriteInteractor helper = new DatabaseReadWriteInteractor(RuntimeEnvironment.application) {
|
||||
|
||||
@Override
|
||||
public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException {
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainExternalContract.EmailStatus;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractorSaveTest;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
@@ -45,7 +45,7 @@ public class KeychainExternalProviderTest {
|
||||
static final long KEY_ID_PUBLIC = 0x9A282CE2AB44A382L;
|
||||
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(RuntimeEnvironment.application);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
||||
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||
ApiPermissionHelper apiPermissionHelper;
|
||||
ApiDataAccessObject apiDao;
|
||||
|
||||
@@ -21,9 +21,10 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
|
||||
class DatabaseInteractorStub extends DatabaseInteractor {
|
||||
|
||||
class DatabaseInteractorStub extends DatabaseReadWriteInteractor {
|
||||
public DatabaseInteractorStub(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -50,7 +51,7 @@ public class KeyringTestingHelper {
|
||||
|
||||
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(context);
|
||||
DatabaseReadWriteInteractor databaseInteractor = new DatabaseReadWriteInteractor(context);
|
||||
|
||||
byte[] data = TestDataUtil.readAllFully(blobFiles);
|
||||
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
||||
@@ -349,7 +350,7 @@ public class KeyringTestingHelper {
|
||||
try {
|
||||
databaseInteractor.getCanonicalizedPublicKeyRing(masterKeyId);
|
||||
throw new AssertionError("Was expecting the previous call to fail!");
|
||||
} catch (DatabaseInteractor.NotFoundException expectedException) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException expectedException) {
|
||||
// good
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user