@Override public Passphrase getCachedPassphrase(long masterKeyId, long subKeyId) throws NoSecretKeyException { try { return PassphraseCacheService.getCachedPassphrase(mContext, masterKeyId, subKeyId); } catch (PassphraseCacheService.KeyNotFoundException e) { throw new PassphraseCacheInterface.NoSecretKeyException(); } }
/** handles the UI bits of the signing process on the UI thread */ private void initiateSigning() { PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, mPubKeyId); if (pubring != null) { // if we have already signed this key, dont bother doing it again boolean alreadySigned = false; @SuppressWarnings("unchecked") Iterator<PGPSignature> itr = pubring.getPublicKey(mPubKeyId).getSignatures(); while (itr.hasNext()) { PGPSignature sig = itr.next(); if (sig.getKeyID() == mMasterKeyId) { alreadySigned = true; break; } } if (!alreadySigned) { /* * get the user's passphrase for this key (if required) */ String passphrase = PassphraseCacheService.getCachedPassphrase(this, mMasterKeyId); if (passphrase == null) { showPassphraseDialog(mMasterKeyId); // bail out; need to wait until the user has entered the passphrase before trying again return; } else { startSigning(); } } else { Toast.makeText(this, R.string.key_has_already_been_signed, Toast.LENGTH_SHORT).show(); setResult(RESULT_CANCELED); finish(); } } }