slight cleanup
This commit is contained in:
@@ -96,7 +96,7 @@ public class TestHelpers {
|
|||||||
IteratorWithIOThrow<UncachedKeyRing> stream = UncachedKeyRing.fromStream(
|
IteratorWithIOThrow<UncachedKeyRing> stream = UncachedKeyRing.fromStream(
|
||||||
getInstrumentation().getContext().getAssets().open(name));
|
getInstrumentation().getContext().getAssets().open(name));
|
||||||
|
|
||||||
KeyWritableRepository helper = KeyWritableRepository.createDatabaseReadWriteInteractor(context);
|
KeyWritableRepository helper = KeyWritableRepository.create(context);
|
||||||
while(stream.hasNext()) {
|
while(stream.hasNext()) {
|
||||||
UncachedKeyRing ring = stream.next();
|
UncachedKeyRing ring = stream.next();
|
||||||
if (ring.isSecret()) {
|
if (ring.isSecret()) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public abstract class CustomActions {
|
|||||||
|
|
||||||
public static ViewAction tokenEncryptViewAddToken(long keyId) throws Exception {
|
public static ViewAction tokenEncryptViewAddToken(long keyId) throws Exception {
|
||||||
CanonicalizedPublicKeyRing ring =
|
CanonicalizedPublicKeyRing ring =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(getTargetContext()).getCanonicalizedPublicKeyRing(keyId);
|
KeyWritableRepository.create(getTargetContext()).getCanonicalizedPublicKeyRing(keyId);
|
||||||
final Object item = new KeyAdapter.KeyItem(ring);
|
final Object item = new KeyAdapter.KeyItem(ring);
|
||||||
|
|
||||||
return new ViewAction() {
|
return new ViewAction() {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class KeyRepository {
|
|||||||
OperationLog mLog;
|
OperationLog mLog;
|
||||||
int mIndent;
|
int mIndent;
|
||||||
|
|
||||||
public static KeyRepository createDatabaseInteractor(Context context) {
|
public static KeyRepository create(Context context) {
|
||||||
ContentResolver contentResolver = context.getContentResolver();
|
ContentResolver contentResolver = context.getContentResolver();
|
||||||
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
||||||
|
|
||||||
|
|||||||
@@ -83,9 +83,7 @@ import org.sufficientlysecure.keychain.util.Utf8Util;
|
|||||||
public class KeyWritableRepository extends KeyRepository {
|
public class KeyWritableRepository extends KeyRepository {
|
||||||
private static final int MAX_CACHED_KEY_SIZE = 1024 * 50;
|
private static final int MAX_CACHED_KEY_SIZE = 1024 * 50;
|
||||||
|
|
||||||
private final Context mContext;
|
public static KeyWritableRepository create(Context context) {
|
||||||
|
|
||||||
public static KeyWritableRepository createDatabaseReadWriteInteractor(Context context) {
|
|
||||||
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
||||||
|
|
||||||
return new KeyWritableRepository(context, localPublicKeyStorage);
|
return new KeyWritableRepository(context, localPublicKeyStorage);
|
||||||
@@ -99,8 +97,6 @@ public class KeyWritableRepository extends KeyRepository {
|
|||||||
private KeyWritableRepository(
|
private KeyWritableRepository(
|
||||||
Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) {
|
Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) {
|
||||||
super(context.getContentResolver(), localPublicKeyStorage, log, indent);
|
super(context.getContentResolver(), localPublicKeyStorage, log, indent);
|
||||||
|
|
||||||
mContext = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LongSparseArray<CanonicalizedPublicKey> getTrustedMasterKeys() {
|
private LongSparseArray<CanonicalizedPublicKey> getTrustedMasterKeys() {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class OpenPgpService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mKeyRepository = KeyRepository.createDatabaseInteractor(this);
|
mKeyRepository = KeyRepository.create(this);
|
||||||
mApiDao = new ApiDataAccessObject(this);
|
mApiDao = new ApiDataAccessObject(this);
|
||||||
mApiPermissionHelper = new ApiPermissionHelper(this, mApiDao);
|
mApiPermissionHelper = new ApiPermissionHelper(this, mApiDao);
|
||||||
mApiPendingIntentFactory = new ApiPendingIntentFactory(getBaseContext());
|
mApiPendingIntentFactory = new ApiPendingIntentFactory(getBaseContext());
|
||||||
@@ -491,7 +491,7 @@ public class OpenPgpService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// this will merge if the key already exists - no worries!
|
// this will merge if the key already exists - no worries!
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(this).savePublicKeyRing(uncachedKeyRing);
|
KeyWritableRepository.create(this).savePublicKeyRing(uncachedKeyRing);
|
||||||
newMasterKeyId = uncachedKeyRing.getMasterKeyId();
|
newMasterKeyId = uncachedKeyRing.getMasterKeyId();
|
||||||
} else {
|
} else {
|
||||||
newMasterKeyId = null;
|
newMasterKeyId = null;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class RequestKeyPermissionPresenter {
|
|||||||
ApiDataAccessObject apiDataAccessObject = new ApiDataAccessObject(context);
|
ApiDataAccessObject apiDataAccessObject = new ApiDataAccessObject(context);
|
||||||
ApiPermissionHelper apiPermissionHelper = new ApiPermissionHelper(context, apiDataAccessObject);
|
ApiPermissionHelper apiPermissionHelper = new ApiPermissionHelper(context, apiDataAccessObject);
|
||||||
KeyRepository keyRepository =
|
KeyRepository keyRepository =
|
||||||
KeyRepository.createDatabaseInteractor(context);
|
KeyRepository.create(context);
|
||||||
|
|
||||||
return new RequestKeyPermissionPresenter(context, apiDataAccessObject, apiPermissionHelper, packageManager,
|
return new RequestKeyPermissionPresenter(context, apiDataAccessObject, apiPermissionHelper, packageManager,
|
||||||
keyRepository);
|
keyRepository);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class KeychainService extends Service implements Progressable {
|
|||||||
// just for brevity
|
// just for brevity
|
||||||
KeychainService outerThis = KeychainService.this;
|
KeychainService outerThis = KeychainService.this;
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(outerThis);
|
KeyWritableRepository.create(outerThis);
|
||||||
if (inputParcel instanceof SignEncryptParcel) {
|
if (inputParcel instanceof SignEncryptParcel) {
|
||||||
op = new SignEncryptOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
op = new SignEncryptOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
|
||||||
} else if (inputParcel instanceof PgpDecryptVerifyInputParcel) {
|
} else if (inputParcel instanceof PgpDecryptVerifyInputParcel) {
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ public class KeyserverSyncAdapterService extends Service {
|
|||||||
CryptoInputParcel cryptoInputParcel) {
|
CryptoInputParcel cryptoInputParcel) {
|
||||||
Log.d(Constants.TAG, "Starting normal update");
|
Log.d(Constants.TAG, "Starting normal update");
|
||||||
ImportOperation importOp = new ImportOperation(context,
|
ImportOperation importOp = new ImportOperation(context,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(context), null);
|
KeyWritableRepository.create(context), null);
|
||||||
return importOp.execute(
|
return importOp.execute(
|
||||||
ImportKeyringParcel.createImportKeyringParcel(keyList,
|
ImportKeyringParcel.createImportKeyringParcel(keyList,
|
||||||
Preferences.getPreferences(context).getPreferredKeyserver()),
|
Preferences.getPreferences(context).getPreferredKeyserver()),
|
||||||
@@ -381,7 +381,7 @@ public class KeyserverSyncAdapterService extends Service {
|
|||||||
new OperationResult.OperationLog());
|
new OperationResult.OperationLog());
|
||||||
}
|
}
|
||||||
ImportKeyResult result =
|
ImportKeyResult result =
|
||||||
new ImportOperation(context, KeyWritableRepository.createDatabaseReadWriteInteractor(context), null, mCancelled)
|
new ImportOperation(context, KeyWritableRepository.create(context), null, mCancelled)
|
||||||
.execute(
|
.execute(
|
||||||
ImportKeyringParcel.createImportKeyringParcel(
|
ImportKeyringParcel.createImportKeyringParcel(
|
||||||
keyWrapper,
|
keyWrapper,
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ public class PassphraseCacheService extends Service {
|
|||||||
+ masterKeyId + ", subKeyId " + subKeyId);
|
+ masterKeyId + ", subKeyId " + subKeyId);
|
||||||
|
|
||||||
// get the type of key (from the database)
|
// get the type of key (from the database)
|
||||||
CachedPublicKeyRing keyRing = KeyRepository.createDatabaseInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
CachedPublicKeyRing keyRing = KeyRepository.create(this).getCachedPublicKeyRing(masterKeyId);
|
||||||
SecretKeyType keyType = keyRing.getSecretKeyType(subKeyId);
|
SecretKeyType keyType = keyRing.getSecretKeyType(subKeyId);
|
||||||
|
|
||||||
switch (keyType) {
|
switch (keyType) {
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class CertifyFingerprintFragment extends LoaderFragment implements
|
|||||||
private void certify(Uri dataUri) {
|
private void certify(Uri dataUri) {
|
||||||
long keyId = 0;
|
long keyId = 0;
|
||||||
try {
|
try {
|
||||||
keyId = KeyRepository.createDatabaseInteractor(getContext())
|
keyId = KeyRepository.create(getContext())
|
||||||
.getCachedPublicKeyRing(dataUri)
|
.getCachedPublicKeyRing(dataUri)
|
||||||
.extractOrGetMasterKeyId();
|
.extractOrGetMasterKeyId();
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class CertifyKeyFragment
|
|||||||
if (certifyKeyId != Constants.key.none) {
|
if (certifyKeyId != Constants.key.none) {
|
||||||
try {
|
try {
|
||||||
CachedPublicKeyRing key = (KeyRepository
|
CachedPublicKeyRing key = (KeyRepository
|
||||||
.createDatabaseInteractor(getContext()))
|
.create(getContext()))
|
||||||
.getCachedPublicKeyRing(certifyKeyId);
|
.getCachedPublicKeyRing(certifyKeyId);
|
||||||
if (key.canCertify()) {
|
if (key.canCertify()) {
|
||||||
mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
|
mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
CreateKeyActivity activity = (CreateKeyActivity) getActivity();
|
CreateKeyActivity activity = (CreateKeyActivity) getActivity();
|
||||||
|
|
||||||
SaveKeyringParcel.Builder builder;
|
SaveKeyringParcel.Builder builder;
|
||||||
CachedPublicKeyRing key = (KeyRepository.createDatabaseInteractor(getContext()))
|
CachedPublicKeyRing key = (KeyRepository.create(getContext()))
|
||||||
.getCachedPublicKeyRing(saveKeyResult.mMasterKeyId);
|
.getCachedPublicKeyRing(saveKeyResult.mMasterKeyId);
|
||||||
try {
|
try {
|
||||||
builder = SaveKeyringParcel.buildChangeKeyringParcel(key.getMasterKeyId(), key.getFingerprint());
|
builder = SaveKeyringParcel.buildChangeKeyringParcel(key.getMasterKeyId(), key.getFingerprint());
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
Intent viewKeyIntent = new Intent(getActivity(), ViewKeyActivity.class);
|
Intent viewKeyIntent = new Intent(getActivity(), ViewKeyActivity.class);
|
||||||
long masterKeyId = KeyRepository.createDatabaseInteractor(getContext()).getCachedPublicKeyRing(
|
long masterKeyId = KeyRepository.create(getContext()).getCachedPublicKeyRing(
|
||||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(keyId)
|
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(keyId)
|
||||||
).getMasterKeyId();
|
).getMasterKeyId();
|
||||||
viewKeyIntent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
viewKeyIntent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
if (mMasterKeyIds.length == 1 && mHasSecret) {
|
if (mMasterKeyIds.length == 1 && mHasSecret) {
|
||||||
// if mMasterKeyIds.length == 0 we let the DeleteOperation respond
|
// if mMasterKeyIds.length == 0 we let the DeleteOperation respond
|
||||||
try {
|
try {
|
||||||
HashMap<String, Object> data = KeyRepository.createDatabaseInteractor(this).getUnifiedData(
|
HashMap<String, Object> data = KeyRepository.create(this).getUnifiedData(
|
||||||
mMasterKeyIds[0], new String[]{
|
mMasterKeyIds[0], new String[]{
|
||||||
KeychainContract.KeyRings.NAME,
|
KeychainContract.KeyRings.NAME,
|
||||||
KeychainContract.KeyRings.IS_REVOKED
|
KeychainContract.KeyRings.IS_REVOKED
|
||||||
@@ -272,7 +272,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
long masterKeyId = masterKeyIds[0];
|
long masterKeyId = masterKeyIds[0];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HashMap<String, Object> data = KeyRepository.createDatabaseInteractor(getContext())
|
HashMap<String, Object> data = KeyRepository.create(getContext())
|
||||||
.getUnifiedData(
|
.getUnifiedData(
|
||||||
masterKeyId, new String[]{
|
masterKeyId, new String[]{
|
||||||
KeychainContract.KeyRings.NAME,
|
KeychainContract.KeyRings.NAME,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class EditIdentitiesFragment extends Fragment
|
|||||||
try {
|
try {
|
||||||
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||||
CachedPublicKeyRing keyRing =
|
CachedPublicKeyRing keyRing =
|
||||||
KeyRepository.createDatabaseInteractor(getContext()).getCachedPublicKeyRing(secretUri);
|
KeyRepository.create(getContext()).getCachedPublicKeyRing(secretUri);
|
||||||
long masterKeyId = keyRing.getMasterKeyId();
|
long masterKeyId = keyRing.getMasterKeyId();
|
||||||
|
|
||||||
// check if this is a master secret key we can work with
|
// check if this is a master secret key we can work with
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
|||||||
try {
|
try {
|
||||||
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||||
CachedPublicKeyRing keyRing =
|
CachedPublicKeyRing keyRing =
|
||||||
KeyRepository.createDatabaseInteractor(getContext()).getCachedPublicKeyRing(secretUri);
|
KeyRepository.create(getContext()).getCachedPublicKeyRing(secretUri);
|
||||||
long masterKeyId = keyRing.getMasterKeyId();
|
long masterKeyId = keyRing.getMasterKeyId();
|
||||||
|
|
||||||
// check if this is a master secret key we can work with
|
// check if this is a master secret key we can work with
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
mKeyRepository = KeyRepository.createDatabaseInteractor(getContext());
|
mKeyRepository = KeyRepository.create(getContext());
|
||||||
|
|
||||||
// preselect keys given, from state or arguments
|
// preselect keys given, from state or arguments
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ public class KeyListFragment extends RecyclerFragment<KeySectionedListAdapter>
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeyRepository keyRepository =
|
KeyRepository keyRepository =
|
||||||
KeyRepository.createDatabaseInteractor(getContext());
|
KeyRepository.create(getContext());
|
||||||
Cursor cursor = keyRepository.getContentResolver().query(
|
Cursor cursor = keyRepository.getContentResolver().query(
|
||||||
KeyRings.buildUnifiedKeyRingsUri(), new String[]{
|
KeyRings.buildUnifiedKeyRingsUri(), new String[]{
|
||||||
KeyRings.FINGERPRINT
|
KeyRings.FINGERPRINT
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
// handle empty passphrases by directly returning an empty crypto input parcel
|
// handle empty passphrases by directly returning an empty crypto input parcel
|
||||||
try {
|
try {
|
||||||
CachedPublicKeyRing pubRing =
|
CachedPublicKeyRing pubRing =
|
||||||
KeyRepository.createDatabaseInteractor(this).getCachedPublicKeyRing(requiredInput.getMasterKeyId());
|
KeyRepository.create(this).getCachedPublicKeyRing(requiredInput.getMasterKeyId());
|
||||||
// use empty passphrase for empty passphrase
|
// use empty passphrase for empty passphrase
|
||||||
if (pubRing.getSecretKeyType(requiredInput.getSubKeyId()) == SecretKeyType.PASSPHRASE_EMPTY) {
|
if (pubRing.getSecretKeyType(requiredInput.getSubKeyId()) == SecretKeyType.PASSPHRASE_EMPTY) {
|
||||||
// also return passphrase back to activity
|
// also return passphrase back to activity
|
||||||
@@ -234,7 +234,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
long subKeyId = mRequiredInput.getSubKeyId();
|
long subKeyId = mRequiredInput.getSubKeyId();
|
||||||
|
|
||||||
KeyRepository helper =
|
KeyRepository helper =
|
||||||
KeyRepository.createDatabaseInteractor(getContext());
|
KeyRepository.create(getContext());
|
||||||
CachedPublicKeyRing cachedPublicKeyRing = helper.getCachedPublicKeyRing(
|
CachedPublicKeyRing cachedPublicKeyRing = helper.getCachedPublicKeyRing(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||||
// yes the inner try/catch block is necessary, otherwise the final variable
|
// yes the inner try/catch block is necessary, otherwise the final variable
|
||||||
@@ -454,7 +454,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
|||||||
|
|
||||||
Long subKeyId = mRequiredInput.getSubKeyId();
|
Long subKeyId = mRequiredInput.getSubKeyId();
|
||||||
CanonicalizedSecretKeyRing secretKeyRing =
|
CanonicalizedSecretKeyRing secretKeyRing =
|
||||||
KeyRepository.createDatabaseInteractor(getContext()).getCanonicalizedSecretKeyRing(
|
KeyRepository.create(getContext()).getCanonicalizedSecretKeyRing(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||||
CanonicalizedSecretKey secretKeyToUnlock =
|
CanonicalizedSecretKey secretKeyToUnlock =
|
||||||
secretKeyRing.getSecretKey(subKeyId);
|
secretKeyRing.getSecretKey(subKeyId);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class QrCodeViewActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
KeyRepository keyRepository = KeyRepository.createDatabaseInteractor(this);
|
KeyRepository keyRepository = KeyRepository.create(this);
|
||||||
try {
|
try {
|
||||||
byte[] blob = keyRepository.getCachedPublicKeyRing(dataUri).getFingerprint();
|
byte[] blob = keyRepository.getCachedPublicKeyRing(dataUri).getFingerprint();
|
||||||
if (blob == null) {
|
if (blob == null) {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class SafeSlingerActivity extends BaseActivity
|
|||||||
// retrieve public key blob and start SafeSlinger
|
// retrieve public key blob and start SafeSlinger
|
||||||
Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(masterKeyId);
|
Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(masterKeyId);
|
||||||
try {
|
try {
|
||||||
byte[] keyBlob = KeyRepository.createDatabaseInteractor(this).getCachedPublicKeyRing(uri).getEncoded();
|
byte[] keyBlob = KeyRepository.create(this).getCachedPublicKeyRing(uri).getEncoded();
|
||||||
|
|
||||||
Intent slingerIntent = new Intent(this, ExchangeActivity.class);
|
Intent slingerIntent = new Intent(this, ExchangeActivity.class);
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeyRepository keyRepository =
|
KeyRepository keyRepository =
|
||||||
KeyRepository.createDatabaseInteractor(this);
|
KeyRepository.create(this);
|
||||||
CanonicalizedPublicKeyRing publicKeyRing;
|
CanonicalizedPublicKeyRing publicKeyRing;
|
||||||
try {
|
try {
|
||||||
publicKeyRing = keyRepository.getCanonicalizedPublicKeyRing(
|
publicKeyRing = keyRepository.getCanonicalizedPublicKeyRing(
|
||||||
@@ -237,7 +237,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity {
|
|||||||
mSecurityTokenHelper.setAdminPin(new Passphrase("12345678"));
|
mSecurityTokenHelper.setAdminPin(new Passphrase("12345678"));
|
||||||
|
|
||||||
KeyRepository keyRepository =
|
KeyRepository keyRepository =
|
||||||
KeyRepository.createDatabaseInteractor(this);
|
KeyRepository.create(this);
|
||||||
CanonicalizedSecretKeyRing secretKeyRing;
|
CanonicalizedSecretKeyRing secretKeyRing;
|
||||||
try {
|
try {
|
||||||
secretKeyRing = keyRepository.getCanonicalizedSecretKeyRing(
|
secretKeyRing = keyRepository.getCanonicalizedSecretKeyRing(
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
|
||||||
savedInstanceState) {
|
savedInstanceState) {
|
||||||
databaseReadWriteInteractor = KeyWritableRepository.createDatabaseReadWriteInteractor(getContext());
|
databaseReadWriteInteractor = KeyWritableRepository.create(getContext());
|
||||||
|
|
||||||
return inflater.inflate(R.layout.settings_keyserver_fragment, null);
|
return inflater.inflate(R.layout.settings_keyserver_fragment, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class ViewCertActivity extends BaseActivity
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
KeyRepository keyRepository =
|
KeyRepository keyRepository =
|
||||||
KeyRepository.createDatabaseInteractor(ViewCertActivity.this);
|
KeyRepository.create(ViewCertActivity.this);
|
||||||
long signerMasterKeyId = keyRepository.getCachedPublicKeyRing(
|
long signerMasterKeyId = keyRepository.getCachedPublicKeyRing(
|
||||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mCertifierKeyId)).getMasterKeyId();
|
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mCertifierKeyId)).getMasterKeyId();
|
||||||
viewIntent.setData(KeyRings.buildGenericKeyRingUri(signerMasterKeyId));
|
viewIntent.setData(KeyRings.buildGenericKeyRingUri(signerMasterKeyId));
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mKeyRepository = KeyRepository.createDatabaseInteractor(this);
|
mKeyRepository = KeyRepository.create(this);
|
||||||
|
|
||||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
|
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
private void startSafeSlinger(Uri dataUri) {
|
private void startSafeSlinger(Uri dataUri) {
|
||||||
long keyId = 0;
|
long keyId = 0;
|
||||||
try {
|
try {
|
||||||
keyId = KeyRepository.createDatabaseInteractor(getContext())
|
keyId = KeyRepository.create(getContext())
|
||||||
.getCachedPublicKeyRing(dataUri)
|
.getCachedPublicKeyRing(dataUri)
|
||||||
.extractOrGetMasterKeyId();
|
.extractOrGetMasterKeyId();
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
@@ -198,7 +198,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
KeyRepository keyRepository =
|
KeyRepository keyRepository =
|
||||||
KeyRepository.createDatabaseInteractor(getContext());
|
KeyRepository.create(getContext());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
long masterKeyId = keyRepository.getCachedPublicKeyRing(mDataUri).extractOrGetMasterKeyId();
|
long masterKeyId = keyRepository.getCachedPublicKeyRing(mDataUri).extractOrGetMasterKeyId();
|
||||||
@@ -436,7 +436,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
|||||||
private void uploadToKeyserver() {
|
private void uploadToKeyserver() {
|
||||||
long keyId;
|
long keyId;
|
||||||
try {
|
try {
|
||||||
keyId = KeyRepository.createDatabaseInteractor(getContext())
|
keyId = KeyRepository.create(getContext())
|
||||||
.getCachedPublicKeyRing(mDataUri)
|
.getCachedPublicKeyRing(mDataUri)
|
||||||
.extractOrGetMasterKeyId();
|
.extractOrGetMasterKeyId();
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
mListener = listener;
|
mListener = listener;
|
||||||
mNonInteractive = nonInteractive;
|
mNonInteractive = nonInteractive;
|
||||||
|
|
||||||
mKeyRepository = KeyRepository.createDatabaseInteractor(activity);
|
mKeyRepository = KeyRepository.create(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<ImportKeysListEntry> data) {
|
public void setData(List<ImportKeysListEntry> data) {
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
|
|
||||||
byte[] fingerprint;
|
byte[] fingerprint;
|
||||||
try {
|
try {
|
||||||
fingerprint = KeyRepository.createDatabaseInteractor(activity).getCachedPublicKeyRing(
|
fingerprint = KeyRepository.create(activity).getCachedPublicKeyRing(
|
||||||
mMasterKeyId).getFingerprint();
|
mMasterKeyId).getFingerprint();
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
throw new IllegalStateException("Key to verify linked id for must exist in db!");
|
throw new IllegalStateException("Key to verify linked id for must exist in db!");
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mKeyRepository = KeyRepository.createDatabaseInteractor(this);
|
mKeyRepository = KeyRepository.create(this);
|
||||||
mImportOpHelper = new CryptoOperationHelper<>(1, this, this, null);
|
mImportOpHelper = new CryptoOperationHelper<>(1, this, this, null);
|
||||||
|
|
||||||
setTitle(null);
|
setTitle(null);
|
||||||
@@ -656,7 +656,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
long keyId = KeyRepository.createDatabaseInteractor(this)
|
long keyId = KeyRepository.create(this)
|
||||||
.getCachedPublicKeyRing(dataUri)
|
.getCachedPublicKeyRing(dataUri)
|
||||||
.extractOrGetMasterKeyId();
|
.extractOrGetMasterKeyId();
|
||||||
long[] encryptionKeyIds = new long[]{keyId};
|
long[] encryptionKeyIds = new long[]{keyId};
|
||||||
@@ -680,7 +680,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
private void startSafeSlinger(Uri dataUri) {
|
private void startSafeSlinger(Uri dataUri) {
|
||||||
long keyId = 0;
|
long keyId = 0;
|
||||||
try {
|
try {
|
||||||
keyId = KeyRepository.createDatabaseInteractor(this)
|
keyId = KeyRepository.create(this)
|
||||||
.getCachedPublicKeyRing(dataUri)
|
.getCachedPublicKeyRing(dataUri)
|
||||||
.extractOrGetMasterKeyId();
|
.extractOrGetMasterKeyId();
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class LinkedIdWizard extends BaseActivity {
|
|||||||
try {
|
try {
|
||||||
Uri uri = getIntent().getData();
|
Uri uri = getIntent().getData();
|
||||||
uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(uri);
|
uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(uri);
|
||||||
CachedPublicKeyRing ring = KeyRepository.createDatabaseInteractor(this).getCachedPublicKeyRing(uri);
|
CachedPublicKeyRing ring = KeyRepository.create(this).getCachedPublicKeyRing(uri);
|
||||||
if (!ring.hasAnySecret()) {
|
if (!ring.hasAnySecret()) {
|
||||||
Log.e(Constants.TAG, "Linked Identities can only be added to secret keys!");
|
Log.e(Constants.TAG, "Linked Identities can only be added to secret keys!");
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public abstract class PublicKeyRetrievalLoader extends AsyncTaskLoader<KeyRetrie
|
|||||||
LocalKeyLookupLoader(Context context, List<byte[]> fingerprints) {
|
LocalKeyLookupLoader(Context context, List<byte[]> fingerprints) {
|
||||||
super(context, fingerprints);
|
super(context, fingerprints);
|
||||||
|
|
||||||
this.keyRepository = KeyRepository.createDatabaseInteractor(context);
|
this.keyRepository = KeyRepository.create(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
this.view = view;
|
this.view = view;
|
||||||
this.loaderManager = loaderManager;
|
this.loaderManager = loaderManager;
|
||||||
this.loaderId = loaderId;
|
this.loaderId = loaderId;
|
||||||
this.databaseInteractor = KeyRepository.createDatabaseInteractor(context);
|
this.databaseInteractor = KeyRepository.create(context);
|
||||||
|
|
||||||
secretKeyAdapter = new TransferKeyAdapter(context, LayoutInflater.from(context), this);
|
secretKeyAdapter = new TransferKeyAdapter(context, LayoutInflater.from(context), this);
|
||||||
view.setSecretKeyAdapter(secretKeyAdapter);
|
view.setSecretKeyAdapter(secretKeyAdapter);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class BackupOperationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@@ -151,7 +151,7 @@ public class BackupOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExportAllLocalStripped() throws Exception {
|
public void testExportAllLocalStripped() throws Exception {
|
||||||
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
|
BackupOperation op = new BackupOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
// make sure there is a local cert (so the later checks that there are none are meaningful)
|
// 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));
|
assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
|
||||||
@@ -250,7 +250,7 @@ public class BackupOperationTest {
|
|||||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||||
|
|
||||||
BackupOperation op = new BackupOperation(spyApplication,
|
BackupOperation op = new BackupOperation(spyApplication,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
BackupKeyringParcel parcel = BackupKeyringParcel.createBackupKeyringParcel(
|
BackupKeyringParcel parcel = BackupKeyringParcel.createBackupKeyringParcel(
|
||||||
new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri);
|
new long[] { mStaticRing1.getMasterKeyId() }, false, false, true, fakeOutputUri);
|
||||||
@@ -307,7 +307,7 @@ public class BackupOperationTest {
|
|||||||
|
|
||||||
{ // export encrypted
|
{ // export encrypted
|
||||||
BackupOperation op = new BackupOperation(spyApplication,
|
BackupOperation op = new BackupOperation(spyApplication,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
BackupKeyringParcel parcel = BackupKeyringParcel.createBackupKeyringParcel(
|
BackupKeyringParcel parcel = BackupKeyringParcel.createBackupKeyringParcel(
|
||||||
new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri);
|
new long[] { mStaticRing1.getMasterKeyId() }, false, true, true, fakeOutputUri);
|
||||||
@@ -325,7 +325,7 @@ public class BackupOperationTest {
|
|||||||
|
|
||||||
{
|
{
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
||||||
.setAllowSymmetricDecryption(true)
|
.setAllowSymmetricDecryption(true)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class BenchmarkOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testBenchmark() throws Exception {
|
public void testBenchmark() throws Exception {
|
||||||
BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.application,
|
BenchmarkOperation op = new BenchmarkOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
op.execute(BenchmarkInputParcel.newInstance(), null);
|
op.execute(BenchmarkInputParcel.newInstance(), null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class CertifyOperationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@@ -133,7 +133,7 @@ public class CertifyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSelfCertifyFlag() throws Exception {
|
public void testSelfCertifyFlag() throws Exception {
|
||||||
|
|
||||||
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing1.getMasterKeyId());
|
||||||
Assert.assertEquals("secret key must be marked self-certified in database",
|
Assert.assertEquals("secret key must be marked self-certified in database",
|
||||||
// TODO this should be more correctly be VERIFIED_SELF at some point!
|
// TODO this should be more correctly be VERIFIED_SELF at some point!
|
||||||
@@ -144,10 +144,10 @@ public class CertifyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCertifyId() throws Exception {
|
public void testCertifyId() throws Exception {
|
||||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||||
Certs.UNVERIFIED, ring.getVerified());
|
Certs.UNVERIFIED, ring.getVerified());
|
||||||
@@ -161,7 +161,7 @@ public class CertifyOperationTest {
|
|||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("new key must be verified now",
|
Assert.assertEquals("new key must be verified now",
|
||||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||||
@@ -172,10 +172,10 @@ public class CertifyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCertifyAttribute() throws Exception {
|
public void testCertifyAttribute() throws Exception {
|
||||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("public key must not be marked verified prior to certification",
|
Assert.assertEquals("public key must not be marked verified prior to certification",
|
||||||
Certs.UNVERIFIED, ring.getVerified());
|
Certs.UNVERIFIED, ring.getVerified());
|
||||||
@@ -189,7 +189,7 @@ public class CertifyOperationTest {
|
|||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
.getCanonicalizedPublicKeyRing(mStaticRing2.getMasterKeyId());
|
||||||
Assert.assertEquals("new key must be verified now",
|
Assert.assertEquals("new key must be verified now",
|
||||||
Certs.VERIFIED_SECRET, ring.getVerified());
|
Certs.VERIFIED_SECRET, ring.getVerified());
|
||||||
@@ -201,7 +201,7 @@ public class CertifyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCertifySelf() throws Exception {
|
public void testCertifySelf() throws Exception {
|
||||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
||||||
actions.addAction(CertifyAction.createForUserIds(mStaticRing1.getMasterKeyId(),
|
actions.addAction(CertifyAction.createForUserIds(mStaticRing1.getMasterKeyId(),
|
||||||
@@ -218,7 +218,7 @@ public class CertifyOperationTest {
|
|||||||
public void testCertifyNonexistent() throws Exception {
|
public void testCertifyNonexistent() throws Exception {
|
||||||
|
|
||||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class PromoteKeyOperationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@@ -106,7 +106,7 @@ public class PromoteKeyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testPromote() throws Exception {
|
public void testPromote() throws Exception {
|
||||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
PromoteKeyResult result = op.execute(
|
PromoteKeyResult result = op.execute(
|
||||||
PromoteKeyringParcel.createPromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null);
|
PromoteKeyringParcel.createPromoteKeyringParcel(mStaticRing.getMasterKeyId(), null, null), null);
|
||||||
@@ -114,7 +114,7 @@ public class PromoteKeyOperationTest {
|
|||||||
Assert.assertTrue("promotion must succeed", result.success());
|
Assert.assertTrue("promotion must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CachedPublicKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CachedPublicKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
|
.getCachedPublicKeyRing(mStaticRing.getMasterKeyId());
|
||||||
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
|
Assert.assertTrue("key must have a secret now", ring.hasAnySecret());
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public class PromoteKeyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testPromoteDivert() throws Exception {
|
public void testPromoteDivert() throws Exception {
|
||||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public class PromoteKeyOperationTest {
|
|||||||
Assert.assertTrue("promotion must succeed", result.success());
|
Assert.assertTrue("promotion must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedSecretKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedSecretKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||||
|
|
||||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||||
@@ -157,7 +157,7 @@ public class PromoteKeyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testPromoteDivertSpecific() throws Exception {
|
public void testPromoteDivertSpecific() throws Exception {
|
||||||
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
PromoteKeyOperation op = new PromoteKeyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
byte[] aid = Hex.decode("D2760001240102000000012345670000");
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ public class PromoteKeyOperationTest {
|
|||||||
Assert.assertTrue("promotion must succeed", result.success());
|
Assert.assertTrue("promotion must succeed", result.success());
|
||||||
|
|
||||||
{
|
{
|
||||||
CanonicalizedSecretKeyRing ring = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
CanonicalizedSecretKeyRing ring = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
.getCanonicalizedSecretKeyRing(mStaticRing.getMasterKeyId());
|
||||||
|
|
||||||
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
for (CanonicalizedSecretKey key : ring.secretKeyIterator()) {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class InputDataOperationTest {
|
|||||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||||
|
|
||||||
InputDataOperation op = new InputDataOperation(spyApplication,
|
InputDataOperation op = new InputDataOperation(spyApplication,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputDataParcel input = InputDataParcel.createInputDataParcel(fakeInputUri, null);
|
InputDataParcel input = InputDataParcel.createInputDataParcel(fakeInputUri, null);
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ public class InputDataOperationTest {
|
|||||||
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
when(spyApplication.getContentResolver()).thenReturn(mockResolver);
|
||||||
|
|
||||||
InputDataOperation op = new InputDataOperation(spyApplication,
|
InputDataOperation op = new InputDataOperation(spyApplication,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputDataParcel input = InputDataParcel.createInputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
|
InputDataParcel input = InputDataParcel.createInputDataParcel(FAKE_CONTENT_INPUT_URI_1, null);
|
||||||
return op.execute(input, CryptoInputParcel.createCryptoInputParcel());
|
return op.execute(input, CryptoInputParcel.createCryptoInputParcel());
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
|
|
||||||
// don't log verbosely here, we're not here to test imports
|
// don't log verbosely here, we're not here to test imports
|
||||||
ShadowLog.stream = oldShadowStream;
|
ShadowLog.stream = oldShadowStream;
|
||||||
@@ -173,7 +173,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
||||||
.setAllowSymmetricDecryption(true)
|
.setAllowSymmetricDecryption(true)
|
||||||
.build();
|
.build();
|
||||||
@@ -228,7 +228,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
||||||
.setAllowSymmetricDecryption(true)
|
.setAllowSymmetricDecryption(true)
|
||||||
.build();
|
.build();
|
||||||
@@ -251,7 +251,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
||||||
.setAllowSymmetricDecryption(true)
|
.setAllowSymmetricDecryption(true)
|
||||||
.build();
|
.build();
|
||||||
@@ -273,7 +273,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder().build();
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder().build();
|
||||||
DecryptVerifyResult result = op.execute(input,
|
DecryptVerifyResult result = op.execute(input,
|
||||||
CryptoInputParcel.createCryptoInputParcel(), data, out);
|
CryptoInputParcel.createCryptoInputParcel(), data, out);
|
||||||
@@ -299,7 +299,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -625,11 +625,11 @@ public class PgpEncryptDecryptTest {
|
|||||||
CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
databaseInteractor.saveSecretKeyRing(modified);
|
databaseInteractor.saveSecretKeyRing(modified);
|
||||||
|
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
||||||
.setInputBytes(ciphertext)
|
.setInputBytes(ciphertext)
|
||||||
.build();
|
.build();
|
||||||
@@ -650,11 +650,11 @@ public class PgpEncryptDecryptTest {
|
|||||||
CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
databaseInteractor.saveSecretKeyRing(modified);
|
databaseInteractor.saveSecretKeyRing(modified);
|
||||||
|
|
||||||
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
PgpDecryptVerifyOperation op = new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
PgpDecryptVerifyInputParcel input = PgpDecryptVerifyInputParcel.builder()
|
||||||
.setInputBytes(ciphertext)
|
.setInputBytes(ciphertext)
|
||||||
.build();
|
.build();
|
||||||
@@ -681,7 +681,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
databaseInteractor.saveSecretKeyRing(modified);
|
databaseInteractor.saveSecretKeyRing(modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +691,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -735,7 +735,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -830,7 +830,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||||
|
|
||||||
// delete first key from database
|
// delete first key from database
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
KeyWritableRepository.create(RuntimeEnvironment.application).getContentResolver().delete(
|
||||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -865,7 +865,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
ByteArrayInputStream in = new ByteArrayInputStream(plaintext.getBytes());
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
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
|
{ // decryption with passphrase cached should succeed for the other key if first is gone
|
||||||
|
|
||||||
// delete first key from database
|
// delete first key from database
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).getContentResolver().delete(
|
KeyWritableRepository.create(RuntimeEnvironment.application).getContentResolver().delete(
|
||||||
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
KeyRingData.buildPublicKeyRingUri(mStaticRing1.getMasterKeyId()), null, null
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -950,7 +950,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
|
ByteArrayInputStream in = new ByteArrayInputStream(plaindata);
|
||||||
|
|
||||||
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
PgpSignEncryptOperation op = new PgpSignEncryptOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null);
|
KeyWritableRepository.create(RuntimeEnvironment.application), null);
|
||||||
|
|
||||||
InputData data = new InputData(in, in.available());
|
InputData data = new InputData(in, in.available());
|
||||||
|
|
||||||
@@ -1068,7 +1068,7 @@ public class PgpEncryptDecryptTest {
|
|||||||
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
final Passphrase passphrase, final Long checkMasterKeyId, final Long checkSubKeyId) {
|
||||||
|
|
||||||
return new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
return new PgpDecryptVerifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null) {
|
KeyWritableRepository.create(RuntimeEnvironment.application), null) {
|
||||||
@Override
|
@Override
|
||||||
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId)
|
||||||
throws NoSecretKeyException {
|
throws NoSecretKeyException {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class EddsaTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
context = RuntimeEnvironment.application;
|
context = RuntimeEnvironment.application;
|
||||||
keyRepository = KeyWritableRepository.createDatabaseReadWriteInteractor(context);
|
keyRepository = KeyWritableRepository.create(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
|||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -44,7 +43,7 @@ import java.util.Iterator;
|
|||||||
public class KeyRepositorySaveTest {
|
public class KeyRepositorySaveTest {
|
||||||
|
|
||||||
KeyWritableRepository mDatabaseInteractor =
|
KeyWritableRepository mDatabaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpOnce() throws Exception {
|
public static void setUpOnce() throws Exception {
|
||||||
@@ -62,17 +61,17 @@ public class KeyRepositorySaveTest {
|
|||||||
SaveKeyringResult result;
|
SaveKeyringResult result;
|
||||||
|
|
||||||
// insert both keys, second should fail
|
// insert both keys, second should fail
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||||
Assert.assertFalse("second keyring import should fail", result.success());
|
Assert.assertFalse("second keyring import should fail", result.success());
|
||||||
|
|
||||||
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
|
new KeychainDatabase(RuntimeEnvironment.application).clearDatabase();
|
||||||
|
|
||||||
// and the other way around
|
// and the other way around
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(second);
|
result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(second);
|
||||||
Assert.assertTrue("first keyring import should succeed", result.success());
|
Assert.assertTrue("first keyring import should succeed", result.success());
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(first);
|
result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(first);
|
||||||
Assert.assertFalse("second keyring import should fail", result.success());
|
Assert.assertFalse("second keyring import should fail", result.success());
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -91,14 +90,14 @@ public class KeyRepositorySaveTest {
|
|||||||
SaveKeyringResult result;
|
SaveKeyringResult result;
|
||||||
|
|
||||||
// insert secret, this should fail because of missing self-cert
|
// insert secret, this should fail because of missing self-cert
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
result = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.saveSecretKeyRing(seckey);
|
.saveSecretKeyRing(seckey);
|
||||||
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
Assert.assertFalse("secret keyring import before pubring import should fail", result.success());
|
||||||
|
|
||||||
// insert pubkey, then seckey - both should succeed
|
// insert pubkey, then seckey - both should succeed
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
result = KeyWritableRepository.create(RuntimeEnvironment.application).savePublicKeyRing(pubkey);
|
||||||
Assert.assertTrue("public keyring import should succeed", result.success());
|
Assert.assertTrue("public keyring import should succeed", result.success());
|
||||||
result = KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application)
|
result = KeyWritableRepository.create(RuntimeEnvironment.application)
|
||||||
.saveSecretKeyRing(seckey);
|
.saveSecretKeyRing(seckey);
|
||||||
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
Assert.assertTrue("secret keyring import after pubring import should succeed", result.success());
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class KeychainExternalProviderTest {
|
|||||||
|
|
||||||
|
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application);
|
KeyWritableRepository.create(RuntimeEnvironment.application);
|
||||||
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
|
ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||||
ApiPermissionHelper apiPermissionHelper;
|
ApiPermissionHelper apiPermissionHelper;
|
||||||
ApiDataAccessObject apiDao;
|
ApiDataAccessObject apiDao;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class KeyringTestingHelper {
|
|||||||
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
|
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
|
||||||
|
|
||||||
KeyWritableRepository databaseInteractor =
|
KeyWritableRepository databaseInteractor =
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(context);
|
KeyWritableRepository.create(context);
|
||||||
|
|
||||||
byte[] data = TestDataUtil.readAllFully(blobFiles);
|
byte[] data = TestDataUtil.readAllFully(blobFiles);
|
||||||
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user