diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-26 02:17:26 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-10-26 02:17:26 +0200 |
commit | 4631f45ed760fbc7706852bb5dcf26b969da86b8 (patch) | |
tree | 0adc207e2e4e7614dd7294d2477ed6e7616f42fe /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java | |
parent | be3e6ae6eff504ebb82883419248f16e2208dcff (diff) | |
parent | d6b9fc27b72683cbb5dfe548f863df789fbb5345 (diff) | |
download | open-keychain-4631f45ed760fbc7706852bb5dcf26b969da86b8.tar.gz open-keychain-4631f45ed760fbc7706852bb5dcf26b969da86b8.tar.bz2 open-keychain-4631f45ed760fbc7706852bb5dcf26b969da86b8.zip |
Merge branch 'development' of github.com:open-keychain/open-keychain into development
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java | 32 |
1 files changed, 27 insertions, 5 deletions
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 2eb4c955c..9af6713ba 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/CertifyOperation.java @@ -2,6 +2,9 @@ package org.sufficientlysecure.keychain.operations; import android.content.Context; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.keyimport.HkpKeyserver; +import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing; @@ -17,6 +20,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.LogTyp import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.util.Log; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; @@ -36,7 +40,7 @@ public class CertifyOperation extends BaseOperation { super(context, providerHelper, progressable, cancelled); } - public CertifyResult certify(CertifyActionsParcel parcel) { + public CertifyResult certify(CertifyActionsParcel parcel, String keyServerUri) { OperationLog log = new OperationLog(); log.add(LogType.MSG_CRT, 0); @@ -72,7 +76,7 @@ public class CertifyOperation extends BaseOperation { log.add(LogType.MSG_CRT_CERTIFYING, 1); - int certifyOk = 0, certifyError = 0; + int certifyOk = 0, certifyError = 0, uploadOk = 0, uploadError = 0; // Work through all requested certifications for (CertifyAction action : parcel.mCertifyActions) { @@ -118,13 +122,20 @@ public class CertifyOperation extends BaseOperation { return new CertifyResult(CertifyResult.RESULT_CANCELLED, log); } + HkpKeyserver keyServer = null; + ImportExportOperation importExportOperation = null; + if (keyServerUri != null) { + keyServer = new HkpKeyserver(keyServerUri); + importExportOperation = new ImportExportOperation(mContext, mProviderHelper, mProgressable); + } + // Write all certified keys into the database for (UncachedKeyRing certifiedKey : certifiedKeys) { // Check if we were cancelled if (checkCancelled()) { log.add(LogType.MSG_OPERATION_CANCELLED, 0); - return new CertifyResult(CertifyResult.RESULT_CANCELLED, log, certifyOk, certifyError); + return new CertifyResult(CertifyResult.RESULT_CANCELLED, log, certifyOk, certifyError, uploadOk, uploadError); } log.add(LogType.MSG_CRT_SAVE, 2, @@ -133,6 +144,17 @@ public class CertifyOperation extends BaseOperation { mProviderHelper.clearLog(); SaveKeyringResult result = mProviderHelper.savePublicKeyRing(certifiedKey); + if (importExportOperation != null) { + // TODO use subresult, get rid of try/catch! + try { + importExportOperation.uploadKeyRingToServer(keyServer, certifiedKey); + uploadOk += 1; + } catch (AddKeyException e) { + Log.e(Constants.TAG, "error uploading key", e); + uploadError += 1; + } + } + if (result.success()) { certifyOk += 1; } else { @@ -145,11 +167,11 @@ public class CertifyOperation extends BaseOperation { if (certifyOk == 0) { log.add(LogType.MSG_CRT_ERROR_NOTHING, 0); - return new CertifyResult(CertifyResult.RESULT_ERROR, log, certifyOk, certifyError); + return new CertifyResult(CertifyResult.RESULT_ERROR, log, certifyOk, certifyError, uploadOk, uploadError); } log.add(LogType.MSG_CRT_SUCCESS, 0); - return new CertifyResult(CertifyResult.RESULT_OK, log, certifyOk, certifyError); + return new CertifyResult(CertifyResult.RESULT_OK, log, certifyOk, certifyError, uploadOk, uploadError); } |