rename ProviderHelper -> DatabaseInteractor
This commit is contained in:
@@ -47,7 +47,7 @@ import org.bouncycastle.openpgp.operator.jcajce.SessionKeySecretKeyDecryptorBuil
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
@@ -127,7 +127,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
* passphrase in the process.
|
||||
*
|
||||
* This method can potentially take a LONG time (i.e. seconds), so it should only
|
||||
* ever be called by {@link ProviderHelper} for the purpose of caching its output
|
||||
* ever be called by {@link DatabaseInteractor} for the purpose of caching its output
|
||||
* in the database.
|
||||
*/
|
||||
public SecretKeyType getSecretKeyTypeSuperExpensive() {
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
*/
|
||||
public class OpenPgpSignatureResultBuilder {
|
||||
// injected
|
||||
private final ProviderHelper mProviderHelper;
|
||||
private final DatabaseInteractor mDatabaseInteractor;
|
||||
|
||||
// OpenPgpSignatureResult
|
||||
private String mPrimaryUserId;
|
||||
@@ -57,8 +57,8 @@ public class OpenPgpSignatureResultBuilder {
|
||||
private String mSenderAddress;
|
||||
private Date mSignatureTimestamp;
|
||||
|
||||
public OpenPgpSignatureResultBuilder(ProviderHelper providerHelper) {
|
||||
this.mProviderHelper = providerHelper;
|
||||
public OpenPgpSignatureResultBuilder(DatabaseInteractor databaseInteractor) {
|
||||
this.mDatabaseInteractor = databaseInteractor;
|
||||
}
|
||||
|
||||
public void setPrimaryUserId(String userId) {
|
||||
@@ -127,7 +127,7 @@ public class OpenPgpSignatureResultBuilder {
|
||||
|
||||
try {
|
||||
ArrayList<String> allUserIds = signingRing.getUnorderedUserIds();
|
||||
ArrayList<String> confirmedUserIds = mProviderHelper.getConfirmedUserIds(signingRing.getMasterKeyId());
|
||||
ArrayList<String> confirmedUserIds = mDatabaseInteractor.getConfirmedUserIds(signingRing.getMasterKeyId());
|
||||
setUserIds(allUserIds, confirmedUserIds);
|
||||
|
||||
if (mSenderAddress != null) {
|
||||
|
||||
@@ -72,7 +72,7 @@ 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.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -87,8 +87,8 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
|
||||
public static final int PROGRESS_STRIDE_MILLISECONDS = 200;
|
||||
|
||||
public PgpDecryptVerifyOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
|
||||
super(context, providerHelper, progressable);
|
||||
public PgpDecryptVerifyOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
/** Decrypts and/or verifies data based on parameters of PgpDecryptVerifyInputParcel. */
|
||||
@@ -355,7 +355,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
plainFact = fact;
|
||||
}
|
||||
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mProviderHelper, input.getSenderAddress());
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mDatabaseInteractor, input.getSenderAddress());
|
||||
if (signatureChecker.initializeOnePassSignature(dataChunk, log, indent +1)) {
|
||||
dataChunk = plainFact.nextObject();
|
||||
}
|
||||
@@ -594,7 +594,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
CachedPublicKeyRing cachedPublicKeyRing;
|
||||
try {
|
||||
// get actual keyring object based on master key id
|
||||
cachedPublicKeyRing = mProviderHelper.getCachedPublicKeyRing(
|
||||
cachedPublicKeyRing = mDatabaseInteractor.getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId)
|
||||
);
|
||||
long masterKeyId = cachedPublicKeyRing.getMasterKeyId();
|
||||
@@ -622,7 +622,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
}
|
||||
|
||||
// get actual subkey which has been used for this encryption packet
|
||||
CanonicalizedSecretKeyRing canonicalizedSecretKeyRing = mProviderHelper
|
||||
CanonicalizedSecretKeyRing canonicalizedSecretKeyRing = mDatabaseInteractor
|
||||
.getCanonicalizedSecretKeyRing(masterKeyId);
|
||||
CanonicalizedSecretKey candidateDecryptionKey = canonicalizedSecretKeyRing.getSecretKey(subKeyId);
|
||||
|
||||
@@ -668,7 +668,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
encryptedDataAsymmetric = encData;
|
||||
decryptionKey = candidateDecryptionKey;
|
||||
|
||||
} catch (PgpKeyNotFoundException | ProviderHelper.NotFoundException e) {
|
||||
} catch (PgpKeyNotFoundException | DatabaseInteractor.NotFoundException e) {
|
||||
// continue with the next packet in the while loop
|
||||
log.add(LogType.MSG_DC_ASKIP_NO_KEY, indent + 1);
|
||||
continue;
|
||||
@@ -879,7 +879,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
updateProgress(R.string.progress_processing_signature, 60, 100);
|
||||
JcaSkipMarkerPGPObjectFactory pgpFact = new JcaSkipMarkerPGPObjectFactory(aIn);
|
||||
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mProviderHelper, input.getSenderAddress());
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mDatabaseInteractor, input.getSenderAddress());
|
||||
|
||||
Object o = pgpFact.nextObject();
|
||||
if (!signatureChecker.initializeSignature(o, log, indent+1)) {
|
||||
@@ -934,7 +934,7 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
o = pgpFact.nextObject();
|
||||
}
|
||||
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mProviderHelper, input.getSenderAddress());
|
||||
PgpSignatureChecker signatureChecker = new PgpSignatureChecker(mDatabaseInteractor, input.getSenderAddress());
|
||||
|
||||
if ( ! signatureChecker.initializeSignature(o, log, indent+1)) {
|
||||
log.add(LogType.MSG_DC_ERROR_INVALID_DATA, 0);
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
@@ -98,12 +98,12 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
}
|
||||
}
|
||||
|
||||
public PgpSignEncryptOperation(Context context, ProviderHelper providerHelper, Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, providerHelper, progressable, cancelled);
|
||||
public PgpSignEncryptOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable, AtomicBoolean cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
}
|
||||
|
||||
public PgpSignEncryptOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
|
||||
super(context, providerHelper, progressable);
|
||||
public PgpSignEncryptOperation(Context context, DatabaseInteractor databaseInteractor, Progressable progressable) {
|
||||
super(context, databaseInteractor, progressable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -223,7 +223,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
long signingSubKeyId = data.getSignatureSubKeyId();
|
||||
|
||||
CanonicalizedSecretKeyRing signingKeyRing =
|
||||
mProviderHelper.getCanonicalizedSecretKeyRing(signingMasterKeyId);
|
||||
mDatabaseInteractor.getCanonicalizedSecretKeyRing(signingMasterKeyId);
|
||||
signingKey = signingKeyRing.getSecretKey(data.getSignatureSubKeyId());
|
||||
|
||||
if (input.getAllowedKeyIds() != null) {
|
||||
@@ -248,7 +248,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
}
|
||||
|
||||
switch (mProviderHelper.getCachedPublicKeyRing(signingMasterKeyId).getSecretKeyType(signingSubKeyId)) {
|
||||
switch (mDatabaseInteractor.getCachedPublicKeyRing(signingMasterKeyId).getSecretKeyType(signingSubKeyId)) {
|
||||
case DIVERT_TO_CARD:
|
||||
case PASSPHRASE_EMPTY: {
|
||||
if (!signingKey.unlock(new Passphrase())) {
|
||||
@@ -292,7 +292,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
|
||||
}
|
||||
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
log.add(LogType.MSG_PSE_ERROR_SIGN_KEY, indent);
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
} catch (PgpGeneralException e) {
|
||||
@@ -337,7 +337,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
// Asymmetric encryption
|
||||
for (long id : data.getEncryptionMasterKeyIds()) {
|
||||
try {
|
||||
CanonicalizedPublicKeyRing keyRing = mProviderHelper.getCanonicalizedPublicKeyRing(
|
||||
CanonicalizedPublicKeyRing keyRing = mDatabaseInteractor.getCanonicalizedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingUri(id));
|
||||
Set<Long> encryptSubKeyIds = keyRing.getEncryptIds();
|
||||
for (Long subKeyId : encryptSubKeyIds) {
|
||||
@@ -356,7 +356,7 @@ public class PgpSignEncryptOperation extends BaseOperation<PgpSignEncryptInputPa
|
||||
log.add(LogType.MSG_PSE_ERROR_REVOKED_OR_EXPIRED, indent);
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
}
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
log.add(LogType.MSG_PSE_KEY_UNKNOWN, indent + 1,
|
||||
KeyFormattingUtils.convertKeyIdToHex(id));
|
||||
return new PgpSignEncryptResult(PgpSignEncryptResult.RESULT_ERROR, log);
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.provider.DatabaseInteractor;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
|
||||
@@ -55,12 +55,12 @@ class PgpSignatureChecker {
|
||||
PGPOnePassSignature onePassSignature;
|
||||
PGPSignature signature;
|
||||
|
||||
ProviderHelper mProviderHelper;
|
||||
DatabaseInteractor mDatabaseInteractor;
|
||||
|
||||
PgpSignatureChecker(ProviderHelper providerHelper, String senderAddress) {
|
||||
mProviderHelper = providerHelper;
|
||||
PgpSignatureChecker(DatabaseInteractor databaseInteractor, String senderAddress) {
|
||||
mDatabaseInteractor = databaseInteractor;
|
||||
|
||||
signatureResultBuilder = new OpenPgpSignatureResultBuilder(providerHelper);
|
||||
signatureResultBuilder = new OpenPgpSignatureResultBuilder(databaseInteractor);
|
||||
signatureResultBuilder.setSenderAddress(senderAddress);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class PgpSignatureChecker {
|
||||
for (int i = 0; i < sigList.size(); ++i) {
|
||||
try {
|
||||
long sigKeyId = sigList.get(i).getKeyID();
|
||||
CanonicalizedPublicKeyRing signingRing = mProviderHelper.getCanonicalizedPublicKeyRing(
|
||||
CanonicalizedPublicKeyRing signingRing = mDatabaseInteractor.getCanonicalizedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(sigKeyId)
|
||||
);
|
||||
CanonicalizedPublicKey keyCandidate = signingRing.getPublicKey(sigKeyId);
|
||||
@@ -161,7 +161,7 @@ class PgpSignatureChecker {
|
||||
signingKey = keyCandidate;
|
||||
onePassSignature = sigList.get(i);
|
||||
return;
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found, trying next signature...");
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ class PgpSignatureChecker {
|
||||
for (int i = 0; i < sigList.size(); ++i) {
|
||||
try {
|
||||
long sigKeyId = sigList.get(i).getKeyID();
|
||||
CanonicalizedPublicKeyRing signingRing = mProviderHelper.getCanonicalizedPublicKeyRing(
|
||||
CanonicalizedPublicKeyRing signingRing = mDatabaseInteractor.getCanonicalizedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(sigKeyId)
|
||||
);
|
||||
CanonicalizedPublicKey keyCandidate = signingRing.getPublicKey(sigKeyId);
|
||||
@@ -184,7 +184,7 @@ class PgpSignatureChecker {
|
||||
signingKey = keyCandidate;
|
||||
signature = sigList.get(i);
|
||||
return;
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
} catch (DatabaseInteractor.NotFoundException e) {
|
||||
Log.d(Constants.TAG, "key not found, trying next signature...");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user