added proxy support to OperationHelper
This commit is contained in:
@@ -41,7 +41,6 @@ public class CertifyActionsParcel implements Parcelable {
|
||||
public ArrayList<CertifyAction> mCertifyActions = new ArrayList<>();
|
||||
|
||||
public String keyServerUri;
|
||||
public ParcelableProxy parcelableProxy;
|
||||
|
||||
public CertifyActionsParcel(long masterKeyId) {
|
||||
mMasterKeyId = masterKeyId;
|
||||
@@ -53,7 +52,6 @@ public class CertifyActionsParcel implements Parcelable {
|
||||
// just like parcelables, this is meant for ad-hoc IPC only and is NOT portable!
|
||||
mLevel = CertifyLevel.values()[source.readInt()];
|
||||
keyServerUri = source.readString();
|
||||
parcelableProxy = source.readParcelable(ParcelableProxy.class.getClassLoader());
|
||||
|
||||
mCertifyActions = (ArrayList<CertifyAction>) source.readSerializable();
|
||||
}
|
||||
@@ -67,7 +65,6 @@ public class CertifyActionsParcel implements Parcelable {
|
||||
destination.writeLong(mMasterKeyId);
|
||||
destination.writeInt(mLevel.ordinal());
|
||||
destination.writeString(keyServerUri);
|
||||
destination.writeParcelable(parcelableProxy, flags);
|
||||
|
||||
destination.writeSerializable(mCertifyActions);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Map;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,8 @@ public class CryptoInputParcel implements Parcelable {
|
||||
|
||||
final Date mSignatureTime;
|
||||
final Passphrase mPassphrase;
|
||||
// used to supply an explicit proxy to operations that require it
|
||||
private ParcelableProxy mParcelableProxy;
|
||||
|
||||
// this map contains both decrypted session keys and signed hashes to be
|
||||
// used in the crypto operation described by this parcel.
|
||||
@@ -43,26 +46,37 @@ public class CryptoInputParcel implements Parcelable {
|
||||
public CryptoInputParcel() {
|
||||
mSignatureTime = new Date();
|
||||
mPassphrase = null;
|
||||
mParcelableProxy = null;
|
||||
}
|
||||
|
||||
public CryptoInputParcel(Date signatureTime, Passphrase passphrase) {
|
||||
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
||||
mPassphrase = passphrase;
|
||||
mParcelableProxy = null;
|
||||
}
|
||||
|
||||
public CryptoInputParcel(Passphrase passphrase) {
|
||||
mSignatureTime = new Date();
|
||||
mPassphrase = passphrase;
|
||||
mParcelableProxy = null;
|
||||
}
|
||||
|
||||
public CryptoInputParcel(Date signatureTime) {
|
||||
mSignatureTime = signatureTime == null ? new Date() : signatureTime;
|
||||
mPassphrase = null;
|
||||
mParcelableProxy = null;
|
||||
}
|
||||
|
||||
public CryptoInputParcel(ParcelableProxy parcelableProxy) {
|
||||
mSignatureTime = new Date(); // just for compatibility with parcel-ing
|
||||
mPassphrase = null;
|
||||
mParcelableProxy = parcelableProxy;
|
||||
}
|
||||
|
||||
protected CryptoInputParcel(Parcel source) {
|
||||
mSignatureTime = new Date(source.readLong());
|
||||
mPassphrase = source.readParcelable(getClass().getClassLoader());
|
||||
mParcelableProxy = source.readParcelable(getClass().getClassLoader());
|
||||
|
||||
{
|
||||
int count = source.readInt();
|
||||
@@ -85,6 +99,7 @@ public class CryptoInputParcel implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(mSignatureTime.getTime());
|
||||
dest.writeParcelable(mPassphrase, 0);
|
||||
dest.writeParcelable(mParcelableProxy, 0);
|
||||
|
||||
dest.writeInt(mCryptoData.size());
|
||||
for (HashMap.Entry<ByteBuffer, byte[]> entry : mCryptoData.entrySet()) {
|
||||
@@ -93,6 +108,10 @@ public class CryptoInputParcel implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
public void addParcelableProxy(ParcelableProxy parcelableProxy) {
|
||||
mParcelableProxy = parcelableProxy;
|
||||
}
|
||||
|
||||
public void addCryptoData(byte[] hash, byte[] signedHash) {
|
||||
mCryptoData.put(ByteBuffer.wrap(hash), signedHash);
|
||||
}
|
||||
@@ -101,6 +120,10 @@ public class CryptoInputParcel implements Parcelable {
|
||||
mCryptoData.putAll(cachedSessionKeys);
|
||||
}
|
||||
|
||||
public ParcelableProxy getParcelableProxy() {
|
||||
return mParcelableProxy;
|
||||
}
|
||||
|
||||
public Map<ByteBuffer, byte[]> getCryptoData() {
|
||||
return mCryptoData;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Date;
|
||||
public class RequiredInputParcel implements Parcelable {
|
||||
|
||||
public enum RequiredInputType {
|
||||
PASSPHRASE, PASSPHRASE_SYMMETRIC, NFC_SIGN, NFC_DECRYPT, NFC_MOVE_KEY_TO_CARD
|
||||
PASSPHRASE, PASSPHRASE_SYMMETRIC, NFC_SIGN, NFC_DECRYPT, NFC_MOVE_KEY_TO_CARD, ENABLE_ORBOT
|
||||
}
|
||||
|
||||
public Date mSignatureTime;
|
||||
@@ -77,6 +77,10 @@ public class RequiredInputParcel implements Parcelable {
|
||||
return mSubKeyId;
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createOrbotRequiredOperation() {
|
||||
return new RequiredInputParcel(RequiredInputType.ENABLE_ORBOT, null, null, null, 0L, 0L);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createNfcSignOperation(
|
||||
long masterKeyId, long subKeyId,
|
||||
byte[] inputHash, int signAlgo, Date signatureTime) {
|
||||
|
||||
Reference in New Issue
Block a user