extract DatabaseReadWriteInteractor
This commit is contained in:
@@ -34,8 +34,8 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.experimental.SentenceConfirm;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.base.LoaderFragment;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -213,7 +213,7 @@ public class CertifyFingerprintFragment extends LoaderFragment implements
|
||||
private void certify(Uri dataUri) {
|
||||
long keyId = 0;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(getActivity())
|
||||
keyId = new DatabaseReadWriteInteractor(getActivity())
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
@@ -68,7 +68,7 @@ public class CertifyKeyFragment
|
||||
.getLongExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none);
|
||||
if (certifyKeyId != Constants.key.none) {
|
||||
try {
|
||||
CachedPublicKeyRing key = (new DatabaseInteractor(getActivity()))
|
||||
CachedPublicKeyRing key = (new DatabaseReadWriteInteractor(getActivity()))
|
||||
.getCachedPublicKeyRing(certifyKeyId);
|
||||
if (key.canCertify()) {
|
||||
mCertifyKeySpinner.setPreSelectedKeyId(certifyKeyId);
|
||||
|
||||
@@ -29,8 +29,8 @@ import android.support.v4.app.TaskStackBuilder;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.securitytoken.KeyFormat;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -180,7 +180,7 @@ public class CreateKeyActivity extends BaseSecurityTokenActivity {
|
||||
if (containsKeys(mScannedFingerprints)) {
|
||||
try {
|
||||
long masterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(mScannedFingerprints);
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(masterKeyId);
|
||||
ring.getMasterKeyId();
|
||||
|
||||
Intent intent = new Intent(this, ViewKeyActivity.class);
|
||||
|
||||
@@ -43,8 +43,8 @@ import org.sufficientlysecure.keychain.operations.results.UploadResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
@@ -411,7 +411,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
CreateKeyActivity activity = (CreateKeyActivity) getActivity();
|
||||
|
||||
final SaveKeyringParcel changeKeyringParcel;
|
||||
CachedPublicKeyRing key = (new DatabaseInteractor(activity))
|
||||
CachedPublicKeyRing key = (new DatabaseReadWriteInteractor(activity))
|
||||
.getCachedPublicKeyRing(saveKeyResult.mMasterKeyId);
|
||||
try {
|
||||
changeKeyringParcel = new SaveKeyringParcel(key.getMasterKeyId(), key.getFingerprint());
|
||||
|
||||
@@ -45,9 +45,9 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -192,7 +192,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
try {
|
||||
|
||||
Intent viewKeyIntent = new Intent(getActivity(), ViewKeyActivity.class);
|
||||
long masterKeyId = new DatabaseInteractor(getActivity()).getCachedPublicKeyRing(
|
||||
long masterKeyId = new DatabaseReadWriteInteractor(getActivity()).getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(keyId)
|
||||
).getMasterKeyId();
|
||||
viewKeyIntent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableHkpKeyserver;
|
||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.RevokeResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.DeleteKeyringParcel;
|
||||
@@ -89,7 +90,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
if (mMasterKeyIds.length == 1 && mHasSecret) {
|
||||
// if mMasterKeyIds.length == 0 we let the DeleteOperation respond
|
||||
try {
|
||||
HashMap<String, Object> data = new DatabaseInteractor(this).getUnifiedData(
|
||||
HashMap<String, Object> data = new DatabaseReadWriteInteractor(this).getUnifiedData(
|
||||
mMasterKeyIds[0], new String[]{
|
||||
KeychainContract.KeyRings.NAME,
|
||||
KeychainContract.KeyRings.IS_REVOKED
|
||||
@@ -112,7 +113,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
} else {
|
||||
showRevokeDeleteDialog(name);
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG,
|
||||
"Secret key to delete not found at DeleteKeyDialogActivity for "
|
||||
+ mMasterKeyIds[0], e);
|
||||
@@ -269,7 +270,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
long masterKeyId = masterKeyIds[0];
|
||||
|
||||
try {
|
||||
HashMap<String, Object> data = new DatabaseInteractor(activity).getUnifiedData(
|
||||
HashMap<String, Object> data = new DatabaseReadWriteInteractor(activity).getUnifiedData(
|
||||
masterKeyId, new String[]{
|
||||
KeychainContract.KeyRings.NAME,
|
||||
KeychainContract.KeyRings.HAS_ANY_SECRET
|
||||
@@ -293,7 +294,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
} else {
|
||||
mMainMessage.setText(getString(R.string.public_key_deletetion_confirmation, name));
|
||||
}
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
dismiss();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ import org.sufficientlysecure.keychain.operations.results.UploadResult;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.UploadKeyringParcel;
|
||||
@@ -170,7 +170,7 @@ public class EditIdentitiesFragment extends Fragment
|
||||
try {
|
||||
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||
CachedPublicKeyRing keyRing =
|
||||
new DatabaseInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
new DatabaseReadWriteInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
long masterKeyId = keyRing.getMasterKeyId();
|
||||
|
||||
// check if this is a master secret key we can work with
|
||||
|
||||
@@ -48,9 +48,9 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
@@ -203,7 +203,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
try {
|
||||
Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
|
||||
CachedPublicKeyRing keyRing =
|
||||
new DatabaseInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
new DatabaseReadWriteInteractor(getActivity()).getCachedPublicKeyRing(secretUri);
|
||||
long masterKeyId = keyRing.getMasterKeyId();
|
||||
|
||||
// check if this is a master secret key we can work with
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
@@ -114,7 +115,7 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mDatabaseInteractor = new DatabaseInteractor(getActivity());
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(getActivity());
|
||||
|
||||
// preselect keys given, from state or arguments
|
||||
if (savedInstanceState == null) {
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.sufficientlysecure.keychain.operations.results.BenchmarkResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.ConsolidateResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||
@@ -486,7 +487,7 @@ public class KeyListFragment extends RecyclerFragment<KeySectionedListAdapter>
|
||||
return;
|
||||
}
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(activity);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(activity);
|
||||
Cursor cursor = databaseInteractor.getContentResolver().query(
|
||||
KeyRings.buildUnifiedKeyRingsUri(), new String[]{
|
||||
KeyRings.FINGERPRINT
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
@@ -112,7 +113,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
// handle empty passphrases by directly returning an empty crypto input parcel
|
||||
try {
|
||||
CachedPublicKeyRing pubRing =
|
||||
new DatabaseInteractor(this).getCachedPublicKeyRing(requiredInput.getMasterKeyId());
|
||||
new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(requiredInput.getMasterKeyId());
|
||||
// use empty passphrase for empty passphrase
|
||||
if (pubRing.getSecretKeyType(requiredInput.getSubKeyId()) == SecretKeyType.PASSPHRASE_EMPTY) {
|
||||
// also return passphrase back to activity
|
||||
@@ -231,7 +232,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
try {
|
||||
long subKeyId = mRequiredInput.getSubKeyId();
|
||||
|
||||
DatabaseInteractor helper = new DatabaseInteractor(activity);
|
||||
DatabaseInteractor helper = new DatabaseReadWriteInteractor(activity);
|
||||
CachedPublicKeyRing cachedPublicKeyRing = helper.getCachedPublicKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||
// yes the inner try/catch block is necessary, otherwise the final variable
|
||||
@@ -266,7 +267,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
throw new AssertionError("Unhandled SecretKeyType (should not happen)");
|
||||
}
|
||||
|
||||
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
alert.setTitle(R.string.title_key_not_found);
|
||||
alert.setMessage(getString(R.string.key_not_found, mRequiredInput.getSubKeyId()));
|
||||
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@@ -457,7 +458,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
|
||||
Long subKeyId = mRequiredInput.getSubKeyId();
|
||||
CanonicalizedSecretKeyRing secretKeyRing =
|
||||
new DatabaseInteractor(getActivity()).getCanonicalizedSecretKeyRing(
|
||||
new DatabaseReadWriteInteractor(getActivity()).getCanonicalizedSecretKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||
CanonicalizedSecretKey secretKeyToUnlock =
|
||||
secretKeyRing.getSecretKey(subKeyId);
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.widget.ImageView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||
@@ -74,7 +75,7 @@ public class QrCodeViewActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
try {
|
||||
byte[] blob = (byte[]) databaseInteractor.getGenericData(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
|
||||
@@ -102,7 +103,7 @@ public class QrCodeViewActivity extends BaseActivity {
|
||||
mQrCode.setImageBitmap(scaled);
|
||||
}
|
||||
});
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "key not found!", e);
|
||||
Notify.create(this, R.string.error_key_not_found, Style.ERROR).show();
|
||||
ActivityCompat.finishAfterTransition(QrCodeViewActivity.this);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
@@ -105,7 +106,7 @@ public class SafeSlingerActivity extends BaseActivity
|
||||
// retrieve public key blob and start SafeSlinger
|
||||
Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(masterKeyId);
|
||||
try {
|
||||
byte[] keyBlob = (byte[]) new DatabaseInteractor(this).getGenericData(
|
||||
byte[] keyBlob = (byte[]) new DatabaseReadWriteInteractor(this).getGenericData(
|
||||
uri, KeychainContract.KeyRingData.KEY_RING_DATA, DatabaseInteractor.FIELD_TYPE_BLOB);
|
||||
|
||||
Intent slingerIntent = new Intent(this, ExchangeActivity.class);
|
||||
@@ -114,7 +115,7 @@ public class SafeSlingerActivity extends BaseActivity
|
||||
slingerIntent.putExtra(ExchangeConfig.extra.USER_DATA, keyBlob);
|
||||
slingerIntent.putExtra(ExchangeConfig.extra.HOST_NAME, Constants.SAFESLINGER_SERVER);
|
||||
startActivityForResult(slingerIntent, REQUEST_CODE_SAFE_SLINGER);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "personal key not found", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.securitytoken.KeyType;
|
||||
@@ -193,12 +194,12 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity {
|
||||
throw new IOException(getString(R.string.error_wrong_security_token));
|
||||
}
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
CanonicalizedPublicKeyRing publicKeyRing;
|
||||
try {
|
||||
publicKeyRing = databaseInteractor.getCanonicalizedPublicKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mRequiredInput.getMasterKeyId()));
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new IOException("Couldn't find subkey for key to token operation.");
|
||||
}
|
||||
|
||||
@@ -232,13 +233,13 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenActivity {
|
||||
mSecurityTokenHelper.setPin(new Passphrase("123456"));
|
||||
mSecurityTokenHelper.setAdminPin(new Passphrase("12345678"));
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
CanonicalizedSecretKeyRing secretKeyRing;
|
||||
try {
|
||||
secretKeyRing = databaseInteractor.getCanonicalizedSecretKeyRing(
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mRequiredInput.getMasterKeyId())
|
||||
);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
throw new IOException("Couldn't find subkey for key to token operation.");
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
@@ -184,7 +185,7 @@ public class ViewCertActivity extends BaseActivity
|
||||
Intent viewIntent = new Intent(ViewCertActivity.this, ViewKeyActivity.class);
|
||||
|
||||
try {
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(ViewCertActivity.this);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(ViewCertActivity.this);
|
||||
long signerMasterKeyId = databaseInteractor.getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mCertifierKeyId)).getMasterKeyId();
|
||||
viewIntent.setData(KeyRings.buildGenericKeyRingUri(signerMasterKeyId));
|
||||
|
||||
@@ -72,6 +72,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
@@ -185,7 +186,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mDatabaseInteractor = new DatabaseInteractor(this);
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
mImportOpHelper = new CryptoOperationHelper<>(1, this, this, null);
|
||||
|
||||
setTitle(null);
|
||||
@@ -400,7 +401,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
case R.id.menu_key_view_refresh: {
|
||||
try {
|
||||
updateFromKeyserver(mDataUri, mDatabaseInteractor);
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Notify.create(this, R.string.error_key_not_found, Notify.Style.ERROR).show();
|
||||
}
|
||||
return true;
|
||||
@@ -741,7 +742,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
return;
|
||||
}
|
||||
try {
|
||||
long keyId = new DatabaseInteractor(this)
|
||||
long keyId = new DatabaseReadWriteInteractor(this)
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
long[] encryptionKeyIds = new long[]{keyId};
|
||||
@@ -765,7 +766,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
private void startSafeSlinger(Uri dataUri) {
|
||||
long keyId = 0;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(this)
|
||||
keyId = new DatabaseReadWriteInteractor(this)
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
@@ -1119,7 +1120,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
|
||||
|
||||
private void updateFromKeyserver(Uri dataUri, DatabaseInteractor databaseInteractor)
|
||||
throws DatabaseInteractor.NotFoundException {
|
||||
throws DatabaseReadWriteInteractor.NotFoundException {
|
||||
|
||||
mIsRefreshing = true;
|
||||
mRefreshItem.setEnabled(false);
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.astuetz.PagerSlidingTabStrip;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||
@@ -88,7 +89,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
||||
}
|
||||
});
|
||||
|
||||
mDatabaseInteractor = new DatabaseInteractor(this);
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(this);
|
||||
|
||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||
mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tab_layout);
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
@@ -93,7 +94,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
View root = super.onCreateView(inflater, superContainer, savedInstanceState);
|
||||
View view = inflater.inflate(R.layout.view_key_adv_share_fragment, getContainer());
|
||||
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(ViewKeyAdvShareFragment.this.getActivity());
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(ViewKeyAdvShareFragment.this.getActivity());
|
||||
mNfcHelper = new NfcHelper(getActivity(), databaseInteractor);
|
||||
|
||||
mFingerprintView = (TextView) view.findViewById(R.id.view_key_fingerprint);
|
||||
@@ -200,7 +201,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
private void startSafeSlinger(Uri dataUri) {
|
||||
long keyId = 0;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(getActivity())
|
||||
keyId = new DatabaseReadWriteInteractor(getActivity())
|
||||
.getCachedPublicKeyRing(dataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
@@ -216,7 +217,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
if (activity == null || mFingerprint == null) {
|
||||
return;
|
||||
}
|
||||
DatabaseInteractor databaseInteractor = new DatabaseInteractor(activity);
|
||||
DatabaseInteractor databaseInteractor = new DatabaseReadWriteInteractor(activity);
|
||||
|
||||
try {
|
||||
String content = databaseInteractor.getKeyRingAsArmoredString(
|
||||
@@ -273,7 +274,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
} catch (PgpGeneralException | IOException e) {
|
||||
Log.e(Constants.TAG, "error processing key!", e);
|
||||
Notify.create(activity, R.string.error_key_processing, Notify.Style.ERROR).show();
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException e) {
|
||||
Log.e(Constants.TAG, "key not found!", e);
|
||||
Notify.create(activity, R.string.error_key_not_found, Notify.Style.ERROR).show();
|
||||
}
|
||||
@@ -457,7 +458,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
private void uploadToKeyserver() {
|
||||
long keyId;
|
||||
try {
|
||||
keyId = new DatabaseInteractor(getActivity())
|
||||
keyId = new DatabaseReadWriteInteractor(getActivity())
|
||||
.getCachedPublicKeyRing(mDataUri)
|
||||
.extractOrGetMasterKeyId();
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
@@ -74,7 +75,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
mListener = listener;
|
||||
mNonInteractive = nonInteractive;
|
||||
|
||||
mDatabaseInteractor = new DatabaseInteractor(activity);
|
||||
mDatabaseInteractor = new DatabaseReadWriteInteractor(activity);
|
||||
}
|
||||
|
||||
public void setData(List<ImportKeysListEntry> data) {
|
||||
@@ -95,7 +96,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
}
|
||||
keyState.mAlreadyPresent = true;
|
||||
keyState.mVerified = keyRing.getVerified() > 0;
|
||||
} catch (DatabaseInteractor.NotFoundException | PgpKeyNotFoundException ignored) {
|
||||
} catch (DatabaseReadWriteInteractor.NotFoundException | PgpKeyNotFoundException ignored) {
|
||||
}
|
||||
|
||||
mKeyStates[i] = keyState;
|
||||
|
||||
@@ -37,8 +37,8 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -105,7 +105,7 @@ public abstract class BaseSecurityTokenActivity extends BaseActivity
|
||||
final long subKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(mSecurityTokenFingerprints);
|
||||
|
||||
try {
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(this).getCachedPublicKeyRing(
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
|
||||
long masterKeyId = ring.getMasterKeyId();
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseReadWriteInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class LinkedIdWizard extends BaseActivity {
|
||||
try {
|
||||
Uri uri = getIntent().getData();
|
||||
uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(uri);
|
||||
CachedPublicKeyRing ring = new DatabaseInteractor(this).getCachedPublicKeyRing(uri);
|
||||
CachedPublicKeyRing ring = new DatabaseReadWriteInteractor(this).getCachedPublicKeyRing(uri);
|
||||
if (!ring.hasAnySecret()) {
|
||||
Log.e(Constants.TAG, "Linked Identities can only be added to secret keys!");
|
||||
finish();
|
||||
|
||||
Reference in New Issue
Block a user