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

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
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,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(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,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputDataParcel input = new InputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
return op.execute(input, new CryptoInputParcel());

View File

@@ -40,7 +40,7 @@ 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.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
@@ -149,8 +149,8 @@ public class PgpEncryptDecryptTest {
@Before
public void setUp() {
DatabaseReadWriteInteractor databaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
KeyWritableRepository databaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
// don't log verbosely here, we're not here to test imports
ShadowLog.stream = oldShadowStream;
@@ -173,7 +173,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -198,7 +198,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(true);
DecryptVerifyResult result = op.execute(
@@ -228,7 +228,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(true);
DecryptVerifyResult result = op.execute(input,
@@ -250,7 +250,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(true);
DecryptVerifyResult result = op.execute(input,
@@ -271,7 +271,7 @@ public class PgpEncryptDecryptTest {
InputData data = new InputData(in, in.available());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel();
input.setAllowSymmetricDecryption(false);
DecryptVerifyResult result = op.execute(input,
@@ -298,7 +298,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -354,7 +354,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -416,7 +416,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -473,7 +473,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -576,7 +576,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -627,12 +627,12 @@ public class PgpEncryptDecryptTest {
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
new CryptoInputParcel(new Date(), mKeyPhrase1));
DatabaseReadWriteInteractor databaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
KeyWritableRepository databaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
@@ -650,12 +650,12 @@ public class PgpEncryptDecryptTest {
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
new CryptoInputParcel(new Date(), mKeyPhrase1));
DatabaseReadWriteInteractor databaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
KeyWritableRepository databaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(ciphertext);
DecryptVerifyResult result = op.execute(input, new CryptoInputParcel(mKeyPhrase1));
@@ -678,8 +678,8 @@ public class PgpEncryptDecryptTest {
new ArrayList<RawPacket>(), new ArrayList<RawPacket>(),
new CryptoInputParcel(new Date(), mKeyPhrase1));
DatabaseReadWriteInteractor databaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
KeyWritableRepository databaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
databaseInteractor.saveSecretKeyRing(modified, new ProgressScaler());
}
@@ -689,7 +689,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -734,7 +734,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -828,7 +828,7 @@ public class PgpEncryptDecryptTest {
{ // decryption with passphrase cached should succeed for the other key if first is gone
// delete first key from database
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
);
@@ -863,7 +863,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -911,7 +911,7 @@ public class PgpEncryptDecryptTest {
{ // decryption with passphrase cached should succeed for the other key if first is gone
// delete first key from database
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
);
@@ -950,7 +950,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -1022,7 +1022,7 @@ public class PgpEncryptDecryptTest {
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
InputData data = new InputData(in, in.available());
@@ -1073,7 +1073,7 @@ public class PgpEncryptDecryptTest {
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
return new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
@Override
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
throws NoSecretKeyException {