DatabaseInteractor -> KeyRepository

This commit is contained in:
Vincent Breitmoser
2017-02-24 18:24:11 +01:00
parent c7e01926e1
commit 2124a4598a
65 changed files with 419 additions and 419 deletions

View File

@@ -52,8 +52,8 @@ 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.DatabaseInteractor.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
@@ -84,14 +84,14 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
private static final int INDEX_MASTER_KEY_ID = 0;
private static final int INDEX_HAS_ANY_SECRET = 1;
public BackupOperation(Context context, DatabaseInteractor databaseInteractor, Progressable
public BackupOperation(Context context, KeyRepository keyRepository, Progressable
progressable) {
super(context, databaseInteractor, progressable);
super(context, keyRepository, progressable);
}
public BackupOperation(Context context, DatabaseInteractor databaseInteractor,
public BackupOperation(Context context, KeyRepository keyRepository,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
super(context, keyRepository, progressable, cancelled);
}
@NonNull
@@ -168,7 +168,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
private PgpSignEncryptResult encryptBackupData(@NonNull BackupKeyringParcel backupInput,
@NonNull CryptoInputParcel cryptoInput, @Nullable OutputStream outputStream, Uri plainUri, long exportedDataSize)
throws FileNotFoundException {
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mDatabaseInteractor, mProgressable, mCancelled);
PgpSignEncryptOperation signEncryptOperation = new PgpSignEncryptOperation(mContext, mKeyRepository, mProgressable, mCancelled);
PgpSignEncryptData data = new PgpSignEncryptData();
data.setSymmetricPassphrase(cryptoInput.getPassphrase());
@@ -270,7 +270,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
try {
arOutStream = new ArmoredOutputStream(outStream);
byte[] data = mDatabaseInteractor.loadPublicKeyRingData(masterKeyId);
byte[] data = mKeyRepository.loadPublicKeyRingData(masterKeyId);
UncachedKeyRing uncachedKeyRing = UncachedKeyRing.decodeFromData(data);
CanonicalizedPublicKeyRing ring = (CanonicalizedPublicKeyRing) uncachedKeyRing.canonicalize(log, 2, true);
ring.encode(arOutStream);
@@ -290,7 +290,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
try {
arOutStream = new ArmoredOutputStream(outStream);
byte[] data = mDatabaseInteractor.loadSecretKeyRingData(masterKeyId);
byte[] data = mKeyRepository.loadSecretKeyRingData(masterKeyId);
UncachedKeyRing uncachedKeyRing = UncachedKeyRing.decodeFromData(data);
CanonicalizedSecretKeyRing ring = (CanonicalizedSecretKeyRing) uncachedKeyRing.canonicalize(log, 2, true);
ring.encode(arOutStream);
@@ -323,7 +323,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
+ " IN (" + placeholders + ")";
}
return mDatabaseInteractor.getContentResolver().query(
return mKeyRepository.getContentResolver().query(
KeyRings.buildUnifiedKeyRingsUri(), PROJECTION, selection, selectionArgs,
Tables.KEYS + "." + KeyRings.MASTER_KEY_ID
);

View File

@@ -29,8 +29,8 @@ import org.sufficientlysecure.keychain.Constants.key;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.util.Passphrase;
@@ -41,7 +41,7 @@ public abstract class BaseOperation<T extends Parcelable> implements PassphraseC
final public Progressable mProgressable;
final public AtomicBoolean mCancelled;
final public DatabaseInteractor mDatabaseInteractor;
final public KeyRepository mKeyRepository;
/** An abstract base class for all *Operation classes. It provides a number
* of common methods for progress, cancellation and passphrase cache handling.
@@ -65,18 +65,18 @@ public abstract class BaseOperation<T extends Parcelable> implements PassphraseC
* if there is no prefix it is considered Android-related.
*
*/
public BaseOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
public BaseOperation(Context context, KeyRepository keyRepository, Progressable progressable) {
this.mContext = context;
this.mProgressable = progressable;
this.mDatabaseInteractor = databaseInteractor;
this.mKeyRepository = keyRepository;
mCancelled = null;
}
public BaseOperation(Context context, DatabaseInteractor databaseInteractor,
public BaseOperation(Context context, KeyRepository keyRepository,
Progressable progressable, AtomicBoolean cancelled) {
mContext = context;
mProgressable = progressable;
mDatabaseInteractor = databaseInteractor;
mKeyRepository = keyRepository;
mCancelled = cancelled;
}
@@ -115,7 +115,7 @@ public abstract class BaseOperation<T extends Parcelable> implements PassphraseC
public Passphrase getCachedPassphrase(long subKeyId) throws NoSecretKeyException {
try {
if (subKeyId != key.symmetric) {
long masterKeyId = mDatabaseInteractor.getMasterKeyId(subKeyId);
long masterKeyId = mKeyRepository.getMasterKeyId(subKeyId);
return getCachedPassphrase(masterKeyId, subKeyId);
}
return getCachedPassphrase(key.symmetric, key.symmetric);

View File

@@ -7,24 +7,24 @@ import android.content.Context;
import android.os.Parcelable;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
abstract class BaseReadWriteOperation<T extends Parcelable> extends BaseOperation<T> {
final DatabaseReadWriteInteractor mDatabaseReadWriteInteractor;
final KeyWritableRepository mKeyWritableRepository;
BaseReadWriteOperation(Context context,
DatabaseReadWriteInteractor databaseInteractor,
KeyWritableRepository databaseInteractor,
Progressable progressable) {
super(context, databaseInteractor, progressable);
mDatabaseReadWriteInteractor = databaseInteractor;
mKeyWritableRepository = databaseInteractor;
}
BaseReadWriteOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
BaseReadWriteOperation(Context context, KeyWritableRepository databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
mDatabaseReadWriteInteractor = databaseInteractor;
mKeyWritableRepository = databaseInteractor;
}
}

View File

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
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, DatabaseReadWriteInteractor databaseInteractor, Progressable
public BenchmarkOperation(Context context, KeyWritableRepository databaseInteractor, Progressable
progressable) {
super(context, databaseInteractor, progressable);
}
@@ -81,7 +81,7 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
int i = 0;
do {
SignEncryptOperation op =
new SignEncryptOperation(mContext, mDatabaseInteractor,
new SignEncryptOperation(mContext, mKeyRepository,
new ProgressScaler(mProgressable, i*(50/numRepeats), (i+1)*(50/numRepeats), 100), mCancelled);
PgpSignEncryptData data = new PgpSignEncryptData();
data.setSymmetricPassphrase(passphrase);
@@ -103,7 +103,7 @@ public class BenchmarkOperation extends BaseOperation<BenchmarkInputParcel> {
do {
DecryptVerifyResult decryptResult;
PgpDecryptVerifyOperation op =
new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor,
new PgpDecryptVerifyOperation(mContext, mKeyRepository,
new ProgressScaler(mProgressable, 50 +i*(50/numRepeats), 50 +(i+1)*(50/numRepeats), 100));
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(encryptResult.getResultBytes());
input.setAllowSymmetricDecryption(true);

View File

@@ -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.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
@@ -62,7 +62,7 @@ import org.sufficientlysecure.keychain.util.Passphrase;
*/
public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParcel> {
public CertifyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable, AtomicBoolean
public CertifyOperation(Context context, KeyWritableRepository databaseInteractor, Progressable progressable, AtomicBoolean
cancelled) {
super(context, databaseInteractor, progressable, cancelled);
}
@@ -81,7 +81,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
log.add(LogType.MSG_CRT_MASTER_FETCH, 1);
CachedPublicKeyRing cachedPublicKeyRing = mDatabaseInteractor.getCachedPublicKeyRing(masterKeyId);
CachedPublicKeyRing cachedPublicKeyRing = mKeyRepository.getCachedPublicKeyRing(masterKeyId);
Passphrase passphrase;
switch (cachedPublicKeyRing.getSecretKeyType(masterKeyId)) {
@@ -121,7 +121,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
// Get actual secret key
CanonicalizedSecretKeyRing secretKeyRing =
mDatabaseInteractor.getCanonicalizedSecretKeyRing(parcel.mMasterKeyId);
mKeyRepository.getCanonicalizedSecretKeyRing(parcel.mMasterKeyId);
certificationKey = secretKeyRing.getSecretKey();
log.add(LogType.MSG_CRT_UNLOCK, 1);
@@ -165,7 +165,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
}
CanonicalizedPublicKeyRing publicRing =
mDatabaseInteractor.getCanonicalizedPublicKeyRing(action.mMasterKeyId);
mKeyRepository.getCanonicalizedPublicKeyRing(action.mMasterKeyId);
PgpCertifyOperation op = new PgpCertifyOperation();
PgpCertifyResult result = op.certify(certificationKey, publicRing,
@@ -206,7 +206,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
// these variables are used inside the following loop, but they need to be created only once
UploadOperation uploadOperation = null;
if (parcel.keyServerUri != null) {
uploadOperation = new UploadOperation(mContext, mDatabaseInteractor, mProgressable, mCancelled);
uploadOperation = new UploadOperation(mContext, mKeyRepository, mProgressable, mCancelled);
}
// Write all certified keys into the database
@@ -222,8 +222,8 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
log.add(LogType.MSG_CRT_SAVE, 2,
KeyFormattingUtils.convertKeyIdToHex(certifiedKey.getMasterKeyId()));
// store the signed key in our local cache
mDatabaseInteractor.clearLog();
SaveKeyringResult result = mDatabaseReadWriteInteractor.savePublicKeyRing(certifiedKey);
mKeyRepository.clearLog();
SaveKeyringResult result = mKeyWritableRepository.savePublicKeyRing(certifiedKey);
if (uploadOperation != null) {
UploadKeyringParcel uploadInput =

View File

@@ -29,7 +29,7 @@ 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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@@ -38,7 +38,7 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockParcel> {
public ChangeUnlockOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
public ChangeUnlockOperation(Context context, KeyWritableRepository databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@@ -63,7 +63,7 @@ public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockPa
KeyFormattingUtils.convertKeyIdToHex(unlockParcel.mMasterKeyId));
CanonicalizedSecretKeyRing secRing =
mDatabaseInteractor.getCanonicalizedSecretKeyRing(unlockParcel.mMasterKeyId);
mKeyRepository.getCanonicalizedSecretKeyRing(unlockParcel.mMasterKeyId);
modifyResult = keyOperations.modifyKeyRingPassphrase(secRing, cryptoInput, unlockParcel);
if (modifyResult.isPending()) {
@@ -71,7 +71,7 @@ public class ChangeUnlockOperation extends BaseReadWriteOperation<ChangeUnlockPa
log.add(modifyResult, 1);
return new EditKeyResult(log, modifyResult);
}
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
} catch (KeyWritableRepository.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 BaseReadWriteOperation<ChangeUnlockPa
// It's a success, so this must be non-null now
UncachedKeyRing ring = modifyResult.getRing();
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
SaveKeyringResult saveResult = mKeyWritableRepository
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 70, 95, 100));
log.add(saveResult, 1);

View File

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.ConsolidateInputParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
public class ConsolidateOperation extends BaseReadWriteOperation<ConsolidateInputParcel> {
public ConsolidateOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
public ConsolidateOperation(Context context, KeyWritableRepository databaseInteractor, Progressable
progressable) {
super(context, databaseInteractor, progressable);
}
@@ -40,9 +40,9 @@ public class ConsolidateOperation extends BaseReadWriteOperation<ConsolidateInpu
public ConsolidateResult execute(ConsolidateInputParcel consolidateInputParcel,
CryptoInputParcel cryptoInputParcel) {
if (consolidateInputParcel.mConsolidateRecovery) {
return mDatabaseReadWriteInteractor.consolidateDatabaseStep2(mProgressable);
return mKeyWritableRepository.consolidateDatabaseStep2(mProgressable);
} else {
return mDatabaseReadWriteInteractor.consolidateDatabaseStep1(mProgressable);
return mKeyWritableRepository.consolidateDatabaseStep1(mProgressable);
}
}
}

View File

@@ -26,7 +26,7 @@ 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.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
@@ -43,7 +43,7 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
*/
public class DeleteOperation extends BaseReadWriteOperation<DeleteKeyringParcel> {
public DeleteOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
public DeleteOperation(Context context, KeyWritableRepository databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@@ -81,7 +81,7 @@ public class DeleteOperation extends BaseReadWriteOperation<DeleteKeyringParcel>
cancelled = true;
break;
}
int count = mDatabaseInteractor.getContentResolver().delete(
int count = mKeyRepository.getContentResolver().delete(
KeyRingData.buildPublicKeyRingUri(masterKeyId), null, null
);
if (count > 0) {
@@ -95,7 +95,7 @@ public class DeleteOperation extends BaseReadWriteOperation<DeleteKeyringParcel>
if (isSecret && success > 0) {
log.add(LogType.MSG_DEL_CONSOLIDATE, 1);
ConsolidateResult sub = mDatabaseReadWriteInteractor.consolidateDatabaseStep1(mProgressable);
ConsolidateResult sub = mKeyWritableRepository.consolidateDatabaseStep1(mProgressable);
log.add(sub, 2);
}

View File

@@ -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.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
@@ -57,7 +57,7 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
*/
public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel> {
public EditKeyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
public EditKeyOperation(Context context, KeyWritableRepository databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
}
@@ -94,7 +94,7 @@ public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel>
log.add(LogType.MSG_ED_FETCHING, 1,
KeyFormattingUtils.convertKeyIdToHex(saveParcel.mMasterKeyId));
CanonicalizedSecretKeyRing secRing =
mDatabaseInteractor.getCanonicalizedSecretKeyRing(saveParcel.mMasterKeyId);
mKeyRepository.getCanonicalizedSecretKeyRing(saveParcel.mMasterKeyId);
modifyResult = keyOperations.modifySecretKeyRing(secRing, cryptoInput, saveParcel);
if (modifyResult.isPending()) {
@@ -147,7 +147,7 @@ public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel>
new UploadKeyringParcel(saveParcel.getUploadKeyserver(), keyringBytes);
UploadResult uploadResult =
new UploadOperation(mContext, mDatabaseInteractor, mProgressable, mCancelled)
new UploadOperation(mContext, mKeyRepository, mProgressable, mCancelled)
.execute(exportKeyringParcel, cryptoInput);
log.add(uploadResult, 2);
@@ -161,7 +161,7 @@ public class EditKeyOperation extends BaseReadWriteOperation<SaveKeyringParcel>
}
// Save the new keyring.
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
SaveKeyringResult saveResult = mKeyWritableRepository
.saveSecretKeyRing(ring, new ProgressScaler(mProgressable, 60, 95, 100));
log.add(saveResult, 1);

View File

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -86,12 +86,12 @@ public class ImportOperation extends BaseReadWriteOperation<ImportKeyringParcel>
public static final String CACHE_FILE_NAME = "key_import.pcl";
public ImportOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable
public ImportOperation(Context context, KeyWritableRepository databaseInteractor, Progressable
progressable) {
super(context, databaseInteractor, progressable);
}
public ImportOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
public ImportOperation(Context context, KeyWritableRepository databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
}
@@ -314,15 +314,15 @@ public class ImportOperation extends BaseReadWriteOperation<ImportKeyringParcel>
SaveKeyringResult result;
// synchronizing prevents https://github.com/open-keychain/open-keychain/issues/1221
// and https://github.com/open-keychain/open-keychain/issues/1480
synchronized (mDatabaseInteractor) {
mDatabaseInteractor.clearLog();
synchronized (mKeyRepository) {
mKeyRepository.clearLog();
ProgressScaler progressScaler = new ProgressScaler(progressable, (int) (position * progSteps),
(int) ((position + 1) * progSteps), 100);
if (key.isSecret()) {
result = mDatabaseReadWriteInteractor.saveSecretKeyRing(key, progressScaler,
result = mKeyWritableRepository.saveSecretKeyRing(key, progressScaler,
canKeyRings, skipSave);
} else {
result = mDatabaseReadWriteInteractor.savePublicKeyRing(key, progressScaler,
result = mKeyWritableRepository.savePublicKeyRing(key, progressScaler,
entry.mExpectedFingerprint, canKeyRings, skipSave);
}
}
@@ -343,7 +343,7 @@ public class ImportOperation extends BaseReadWriteOperation<ImportKeyringParcel>
// synonymous to isDownloadFromKeyserver.
// If no byte data was supplied, import from keyserver took place
// this prevents file imports being noted as keyserver imports
mDatabaseReadWriteInteractor.renewKeyLastUpdatedTime(key.getMasterKeyId(),
mKeyWritableRepository.renewKeyLastUpdatedTime(key.getMasterKeyId(),
GregorianCalendar.getInstance().getTimeInMillis(),
TimeUnit.MILLISECONDS);
}
@@ -365,8 +365,8 @@ public class ImportOperation extends BaseReadWriteOperation<ImportKeyringParcel>
if (!skipSave && (secret > 0)) {
setPreventCancel();
ConsolidateResult result;
synchronized (mDatabaseInteractor) {
result = mDatabaseReadWriteInteractor.consolidateDatabaseStep1(progressable);
synchronized (mKeyRepository) {
result = mKeyWritableRepository.consolidateDatabaseStep1(progressable);
}
log.add(result, 1);
}

View File

@@ -50,7 +50,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
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.KeyRepository;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
import org.sufficientlysecure.keychain.service.InputDataParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -71,8 +71,8 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
private final byte[] buf = new byte[256];
public InputDataOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
public InputDataOperation(Context context, KeyRepository keyRepository, Progressable progressable) {
super(context, keyRepository, progressable);
}
Uri mSignedDataUri;
@@ -101,7 +101,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
log.add(LogType.MSG_DATA_OPENPGP, 1);
PgpDecryptVerifyOperation op =
new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor, mProgressable);
new PgpDecryptVerifyOperation(mContext, mKeyRepository, mProgressable);
decryptInput.setInputUri(input.getInputUri());
@@ -269,7 +269,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
decryptInput.setDetachedSignature(detachedSig.toByteArray());
PgpDecryptVerifyOperation op =
new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor, mProgressable);
new PgpDecryptVerifyOperation(mContext, mKeyRepository, mProgressable);
DecryptVerifyResult verifyResult = op.execute(decryptInput, cryptoInput);
log.addByMerge(verifyResult, 4);

View File

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
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, DatabaseReadWriteInteractor databaseInteractor,
public KeybaseVerificationOperation(Context context, KeyWritableRepository databaseInteractor,
Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@@ -147,7 +147,7 @@ public class KeybaseVerificationOperation extends BaseOperation<KeybaseVerificat
}
}
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(mContext, mDatabaseInteractor, mProgressable);
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(mContext, mKeyRepository, mProgressable);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(messageBytes)
.setRequiredSignerFingerprint(requiredFingerprint);

View File

@@ -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.NotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@@ -48,7 +48,7 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
*
*/
public class PromoteKeyOperation extends BaseReadWriteOperation<PromoteKeyringParcel> {
public PromoteKeyOperation(Context context, DatabaseReadWriteInteractor databaseInteractor,
public PromoteKeyOperation(Context context, KeyWritableRepository databaseInteractor,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
}
@@ -69,7 +69,7 @@ public class PromoteKeyOperation extends BaseReadWriteOperation<PromoteKeyringPa
log.add(LogType.MSG_PR_FETCHING, 1,
KeyFormattingUtils.convertKeyIdToHex(promoteKeyringParcel.mKeyRingId));
CanonicalizedPublicKeyRing pubRing =
mDatabaseInteractor.getCanonicalizedPublicKeyRing(promoteKeyringParcel.mKeyRingId);
mKeyRepository.getCanonicalizedPublicKeyRing(promoteKeyringParcel.mKeyRingId);
if (promoteKeyringParcel.mSubKeyIds == null) {
log.add(LogType.MSG_PR_ALL, 1);
@@ -113,7 +113,7 @@ public class PromoteKeyOperation extends BaseReadWriteOperation<PromoteKeyringPa
setPreventCancel();
// Save the new keyring.
SaveKeyringResult saveResult = mDatabaseReadWriteInteractor
SaveKeyringResult saveResult = mKeyWritableRepository
.saveSecretKeyRing(promotedRing, new ProgressScaler(mProgressable, 60, 95, 100));
log.add(saveResult, 1);

View File

@@ -31,7 +31,7 @@ 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.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.service.RevokeKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
@@ -41,7 +41,7 @@ import org.sufficientlysecure.keychain.util.Log;
public class RevokeOperation extends BaseReadWriteOperation<RevokeKeyringParcel> {
public RevokeOperation(Context context, DatabaseReadWriteInteractor databaseInteractor, Progressable progressable) {
public RevokeOperation(Context context, KeyWritableRepository databaseInteractor, Progressable progressable) {
super(context, databaseInteractor, progressable);
}
@@ -62,7 +62,7 @@ public class RevokeOperation extends BaseReadWriteOperation<RevokeKeyringParcel>
try {
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(masterKeyId);
CachedPublicKeyRing keyRing = mDatabaseInteractor.getCachedPublicKeyRing(secretUri);
CachedPublicKeyRing keyRing = mKeyRepository.getCachedPublicKeyRing(secretUri);
// check if this is a master secret key we can work with
switch (keyRing.getSecretKeyType(masterKeyId)) {
@@ -81,7 +81,7 @@ public class RevokeOperation extends BaseReadWriteOperation<RevokeKeyringParcel>
saveKeyringParcel.mRevokeSubKeys.add(masterKeyId);
EditKeyResult revokeAndUploadResult = new EditKeyOperation(mContext,
mDatabaseReadWriteInteractor, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
mKeyWritableRepository, mProgressable, mCancelled).execute(saveKeyringParcel, cryptoInputParcel);
if (revokeAndUploadResult.isPending()) {
return revokeAndUploadResult;
@@ -97,7 +97,7 @@ public class RevokeOperation extends BaseReadWriteOperation<RevokeKeyringParcel>
return new RevokeResult(RevokeResult.RESULT_ERROR, log, masterKeyId);
}
} catch (PgpKeyNotFoundException | DatabaseReadWriteInteractor.NotFoundException e) {
} catch (PgpKeyNotFoundException | KeyWritableRepository.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);

View File

@@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
import org.sufficientlysecure.keychain.pgp.Progressable;
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.RequiredInputType;
@@ -55,9 +55,9 @@ import org.sufficientlysecure.keychain.util.ProgressScaler;
*/
public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
public SignEncryptOperation(Context context, DatabaseInteractor databaseInteractor,
public SignEncryptOperation(Context context, KeyRepository keyRepository,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
super(context, keyRepository, progressable, cancelled);
}
@@ -81,7 +81,7 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
if (data.getSignatureMasterKeyId() != Constants.key.none
&& data.getSignatureSubKeyId() == null) {
try {
long signKeyId = mDatabaseInteractor.getCachedPublicKeyRing(
long signKeyId = mKeyRepository.getCachedPublicKeyRing(
data.getSignatureMasterKeyId()).getSecretSignId();
data.setSignatureSubKeyId(signKeyId);
} catch (PgpKeyNotFoundException e) {
@@ -96,7 +96,7 @@ public class SignEncryptOperation extends BaseOperation<SignEncryptParcel> {
return new SignEncryptResult(SignEncryptResult.RESULT_CANCELLED, log, results);
}
PgpSignEncryptOperation op = new PgpSignEncryptOperation(mContext, mDatabaseInteractor,
PgpSignEncryptOperation op = new PgpSignEncryptOperation(mContext, mKeyRepository,
new ProgressScaler(mProgressable, 100 * count / total, 100 * ++count / total, 100), mCancelled);
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(input.getData());
if (inputBytes != null) {

View File

@@ -37,8 +37,8 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
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.provider.KeyRepository;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
@@ -59,9 +59,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
public UploadOperation(Context context, DatabaseInteractor databaseInteractor,
public UploadOperation(Context context, KeyRepository keyRepository,
Progressable progressable, AtomicBoolean cancelled) {
super(context, databaseInteractor, progressable, cancelled);
super(context, keyRepository, progressable, cancelled);
}
@NonNull
@@ -121,7 +121,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
if (hasMasterKeyId) {
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(uploadInput.mMasterKeyId));
return mDatabaseInteractor.getCanonicalizedPublicKeyRing(uploadInput.mMasterKeyId);
return mKeyRepository.getCanonicalizedPublicKeyRing(uploadInput.mMasterKeyId);
}
CanonicalizedKeyRing canonicalizedRing =
@@ -133,7 +133,7 @@ public class UploadOperation extends BaseOperation<UploadKeyringParcel> {
log.add(LogType.MSG_UPLOAD_KEY, 0, KeyFormattingUtils.convertKeyIdToHex(canonicalizedRing.getMasterKeyId()));
return (CanonicalizedPublicKeyRing) canonicalizedRing;
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
} catch (KeyWritableRepository.NotFoundException e) {
log.add(LogType.MSG_UPLOAD_ERROR_NOT_FOUND, 1);
return null;
} catch (IOException | PgpGeneralException e) {