From 87c03ecb0d53d3061e08206ff485a09776419ed9 Mon Sep 17 00:00:00 2001 From: Adithya Abraham Philip Date: Fri, 12 Jun 2015 23:06:35 +0530 Subject: [PATCH] added keyserver/proxy support to certify operation --- .../keychain/operations/CertifyOperation.java | 5 ++++- .../keychain/service/CertifyActionsParcel.java | 6 ++++++ .../sufficientlysecure/keychain/ui/CertifyKeyFragment.java | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java index 9f8ba8d69..eacb73818 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java @@ -46,6 +46,7 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel; import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.NfcSignOperationsBuilder; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.ParcelableProxy; import org.sufficientlysecure.keychain.util.Passphrase; import java.net.Proxy; @@ -189,6 +190,7 @@ public class CertifyOperation extends BaseOperation { HkpKeyserver keyServer = null; ImportExportOperation importExportOperation = null; + ParcelableProxy parcelableProxy = parcel.parcelableProxy; if (parcel.keyServerUri != null) { keyServer = new HkpKeyserver(parcel.keyServerUri); importExportOperation = new ImportExportOperation(mContext, mProviderHelper, mProgressable); @@ -210,7 +212,8 @@ public class CertifyOperation extends BaseOperation { SaveKeyringResult result = mProviderHelper.savePublicKeyRing(certifiedKey); if (importExportOperation != null) { - ExportResult uploadResult = importExportOperation.uploadKeyRingToServer(keyServer, certifiedKey, proxy); + ExportResult uploadResult = importExportOperation.uploadKeyRingToServer(keyServer, certifiedKey, + parcelableProxy.getProxy()); log.add(uploadResult, 2); if (uploadResult.success()) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/CertifyActionsParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/CertifyActionsParcel.java index a11f81658..05d5546f6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/CertifyActionsParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/CertifyActionsParcel.java @@ -29,6 +29,7 @@ import java.util.Map; import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; +import org.sufficientlysecure.keychain.util.ParcelableProxy; /** @@ -44,6 +45,7 @@ public class CertifyActionsParcel implements Parcelable { public ArrayList mCertifyActions = new ArrayList<>(); public String keyServerUri; + public ParcelableProxy parcelableProxy; public CertifyActionsParcel(long masterKeyId) { mMasterKeyId = masterKeyId; @@ -54,6 +56,8 @@ public class CertifyActionsParcel implements Parcelable { mMasterKeyId = source.readLong(); // 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) source.readSerializable(); } @@ -66,6 +70,8 @@ public class CertifyActionsParcel implements Parcelable { public void writeToParcel(Parcel destination, int flags) { destination.writeLong(mMasterKeyId); destination.writeInt(mLevel.ordinal()); + destination.writeString(keyServerUri); + destination.writeParcelable(parcelableProxy, flags); destination.writeSerializable(mCertifyActions); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java index d50843ef1..17e4f78f2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java @@ -26,6 +26,7 @@ import android.database.MatrixCursor; import android.graphics.PorterDuff; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.os.Parcel; @@ -340,6 +341,11 @@ public class CertifyKeyFragment CertifyActionsParcel actionsParcel = new CertifyActionsParcel(selectedKeyId); actionsParcel.mCertifyActions.addAll(certifyActions); + if (mUploadKeyCheckbox.isChecked()) { + actionsParcel.keyServerUri = Preferences.getPreferences(getActivity()).getPreferredKeyserver(); + actionsParcel.parcelableProxy = mProxyPrefs.parcelableProxy; + } + // cached for next cryptoOperation loop cacheActionsParcel(actionsParcel);