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

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.TemporaryFileProvider;
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
@@ -135,8 +135,8 @@ public class BackupOperationTest {
@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;
@@ -151,7 +151,7 @@ public class BackupOperationTest {
@Test
public void testExportAllLocalStripped() throws Exception {
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(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));
@@ -250,7 +250,7 @@ public class BackupOperationTest {
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
BackupOperation op = new BackupOperation(spyApplication,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
BackupKeyringParcel parcel = new BackupKeyringParcel(
new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri);
@@ -307,7 +307,7 @@ public class BackupOperationTest {
{ // export encrypted
BackupOperation op = new BackupOperation(spyApplication,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
BackupKeyringParcel parcel = new BackupKeyringParcel(
new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri);
@@ -325,7 +325,7 @@ public class BackupOperationTest {
{
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(outStream.toByteArray());
input.setAllowSymmetricDecryption(true);

View File

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
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,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
op.execute(new BenchmarkInputParcel(), null);
}

View File

@@ -34,7 +34,7 @@ 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.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
@@ -117,8 +117,8 @@ public class CertifyOperationTest {
@Before
public void setUp() throws Exception {
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;
@@ -133,7 +133,7 @@ public class CertifyOperationTest {
@Test
public void testSelfCertifyFlag() throws Exception {
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(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!
@@ -144,10 +144,10 @@ public class CertifyOperationTest {
@Test
public void testCertifyId() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
{
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("public key must not be marked verified prior to certification",
Certs.UNVERIFIED, ring.getVerified());
@@ -161,7 +161,7 @@ public class CertifyOperationTest {
Assert.assertTrue("certification must succeed", result.success());
{
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("new key must be verified now",
Certs.VERIFIED_SECRET, ring.getVerified());
@@ -172,10 +172,10 @@ public class CertifyOperationTest {
@Test
public void testCertifyAttribute() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
{
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("public key must not be marked verified prior to certification",
Certs.UNVERIFIED, ring.getVerified());
@@ -189,7 +189,7 @@ public class CertifyOperationTest {
Assert.assertTrue("certification must succeed", result.success());
{
CanonicalizedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
Assert.assertEquals("new key must be verified now",
Certs.VERIFIED_SECRET, ring.getVerified());
@@ -201,7 +201,7 @@ public class CertifyOperationTest {
@Test
public void testCertifySelf() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
@@ -218,7 +218,7 @@ public class CertifyOperationTest {
public void testCertifyNonexistent() throws Exception {
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
{
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());

View File

@@ -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.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.service.PromoteKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
@@ -90,8 +90,8 @@ public class PromoteKeyOperationTest {
@Before
public void setUp() throws Exception {
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;
@@ -105,14 +105,14 @@ public class PromoteKeyOperationTest {
@Test
public void testPromote() throws Exception {
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
PromoteKeyResult result = op.execute(new PromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null);
Assert.assertTrue("promotion must succeed", result.success());
{
CachedPublicKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CachedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
@@ -129,7 +129,7 @@ public class PromoteKeyOperationTest {
@Test
public void testPromoteDivert() throws Exception {
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
byte[] aid = Hex.decode("D2760001240102000000012345670000");
@@ -138,7 +138,7 @@ public class PromoteKeyOperationTest {
Assert.assertTrue("promotion must succeed", result.success());
{
CanonicalizedSecretKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedSecretKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
@@ -154,7 +154,7 @@ public class PromoteKeyOperationTest {
@Test
public void testPromoteDivertSpecific() throws Exception {
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
byte[] aid = Hex.decode("D2760001240102000000012345670000");
@@ -168,7 +168,7 @@ public class PromoteKeyOperationTest {
Assert.assertTrue("promotion must succeed", result.success());
{
CanonicalizedSecretKeyRing ring = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
CanonicalizedSecretKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {

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 {

View File

@@ -243,7 +243,7 @@ public class InteropTest {
final Uri verifyUri = verify != null ?
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null;
DatabaseReadWriteInteractor helper = new DatabaseReadWriteInteractor(RuntimeEnvironment.application) {
KeyWritableRepository helper = new KeyWritableRepository(RuntimeEnvironment.application) {
@Override
public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException {

View File

@@ -30,7 +30,7 @@ import java.util.Collection;
import java.util.Collections;
@RunWith(KeychainTestRunner.class)
public class DatabaseInteractorKeyringTest {
public class KeyRepositoryKeyringTest {
@Test
public void testSavePublicKeyring() throws Exception {

View File

@@ -41,10 +41,10 @@ import java.util.Arrays;
import java.util.Iterator;
@RunWith(KeychainTestRunner.class)
public class DatabaseInteractorSaveTest {
public class KeyRepositorySaveTest {
DatabaseReadWriteInteractor mDatabaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
KeyWritableRepository mDatabaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
@BeforeClass
public static void setUpOnce() throws Exception {
@@ -62,17 +62,17 @@ public class DatabaseInteractorSaveTest {
SaveKeyringResult result;
// insert both keys, second should fail
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
Assert.assertTrue("first keyring import should succeed", result.success());
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
Assert.assertFalse("second keyring import should fail", result.success());
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
// and the other way around
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
Assert.assertTrue("first keyring import should succeed", result.success());
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
Assert.assertFalse("second keyring import should fail", result.success());
}
@@ -91,14 +91,14 @@ public class DatabaseInteractorSaveTest {
SaveKeyringResult result;
// insert secret, this should fail because of missing self-cert
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
result = KeyWritableRepository.createDatabaseReadWriteInteractor(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 = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
Assert.assertTrue("public keyring import should succeed", result.success());
result = DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
.saveSecretKeyRing(seckey, new ProgressScaler());
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
@@ -247,7 +247,7 @@ public class DatabaseInteractorSaveTest {
}
UncachedKeyRing readRingFromResource(String name) throws Exception {
return UncachedKeyRing.fromStream(DatabaseInteractorSaveTest.class.getResourceAsStream(name)).next();
return UncachedKeyRing.fromStream(KeyRepositorySaveTest.class.getResourceAsStream(name)).next();
}
}

View File

@@ -20,9 +20,9 @@ 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.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.KeychainExternalContract.EmailStatus;
import org.sufficientlysecure.keychain.provider.DatabaseInteractorSaveTest;
import org.sufficientlysecure.keychain.provider.KeyRepositorySaveTest;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -45,8 +45,8 @@ public class KeychainExternalProviderTest {
static final long KEY_ID_PUBLIC = 0x9A282CE2AB44A382L;
DatabaseReadWriteInteractor databaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
KeyWritableRepository databaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
ApiPermissionHelper apiPermissionHelper;
ApiDataAccessObject apiDao;
@@ -207,6 +207,6 @@ public class KeychainExternalProviderTest {
}
UncachedKeyRing readRingFromResource(String name) throws Exception {
return UncachedKeyRing.fromStream(DatabaseInteractorSaveTest.class.getResourceAsStream(name)).next();
return UncachedKeyRing.fromStream(KeyRepositorySaveTest.class.getResourceAsStream(name)).next();
}
}

View File

@@ -21,11 +21,11 @@ import android.content.Context;
import android.net.Uri;
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
class DatabaseInteractorStub extends DatabaseReadWriteInteractor {
public DatabaseInteractorStub(Context context) {
class KeyRepositoryStub extends KeyWritableRepository {
public KeyRepositoryStub(Context context) {
super(context);
}

View File

@@ -23,9 +23,9 @@ import android.content.Context;
import org.bouncycastle.util.Arrays;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.util.ProgressScaler;
import java.io.ByteArrayInputStream;
@@ -51,8 +51,8 @@ public class KeyringTestingHelper {
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
DatabaseReadWriteInteractor databaseInteractor =
DatabaseReadWriteInteractor.createDatabaseReadWriteInteractor(context);
KeyWritableRepository databaseInteractor =
KeyWritableRepository.createDatabaseReadWriteInteractor(context);
byte[] data = TestDataUtil.readAllFully(blobFiles);
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
@@ -347,11 +347,11 @@ public class KeyringTestingHelper {
return getNth(ring.getPublicKeys(), position).getKeyId();
}
private void retrieveKeyAndExpectNotFound(DatabaseInteractor databaseInteractor, long masterKeyId) {
private void retrieveKeyAndExpectNotFound(KeyRepository keyRepository, long masterKeyId) {
try {
databaseInteractor.getCanonicalizedPublicKeyRing(masterKeyId);
keyRepository.getCanonicalizedPublicKeyRing(masterKeyId);
throw new AssertionError("Was expecting the previous call to fail!");
} catch (DatabaseReadWriteInteractor.NotFoundException expectedException) {
} catch (KeyWritableRepository.NotFoundException expectedException) {
// good
}
}