Replace many PgpGeneralExceptions with PgpKeyNotFoundException

This commit is contained in:
Dominik Schürmann 2014-10-09 01:37:44 +02:00
parent b3f56c927b
commit 45b02008fb
20 changed files with 126 additions and 70 deletions

View File

@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
import org.spongycastle.openpgp.PGPKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.util.IterableIterator;
import java.io.IOException;
@ -56,11 +57,11 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
return getRing().getPublicKey().getFingerprint();
}
public String getPrimaryUserId() throws PgpGeneralException {
public String getPrimaryUserId() throws PgpKeyNotFoundException {
return getPublicKey().getPrimaryUserId();
}
public String getPrimaryUserIdWithFallback() throws PgpGeneralException {
public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
return getPublicKey().getPrimaryUserIdWithFallback();
}
@ -87,24 +88,24 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
return creationDate.after(now) || (expiryDate != null && expiryDate.before(now));
}
public boolean canCertify() throws PgpGeneralException {
public boolean canCertify() throws PgpKeyNotFoundException {
return getRing().getPublicKey().isEncryptionKey();
}
public long getEncryptId() throws PgpGeneralException {
public long getEncryptId() throws PgpKeyNotFoundException {
for(CanonicalizedPublicKey key : publicKeyIterator()) {
if (key.canEncrypt() && key.isValid()) {
return key.getKeyId();
}
}
throw new PgpGeneralException("No valid encryption key found!");
throw new PgpKeyNotFoundException("No valid encryption key found!");
}
public boolean hasEncrypt() throws PgpGeneralException {
public boolean hasEncrypt() throws PgpKeyNotFoundException {
try {
getEncryptId();
return true;
} catch(PgpGeneralException e) {
} catch(PgpKeyNotFoundException e) {
return false;
}
}

View File

@ -21,7 +21,7 @@ package org.sufficientlysecure.keychain.pgp;
import org.spongycastle.openpgp.PGPObjectFactory;
import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.util.IterableIterator;
import java.io.IOException;
@ -61,16 +61,16 @@ public class CanonicalizedPublicKeyRing extends CanonicalizedKeyRing {
}
/** Getter that returns the subkey that should be used for signing. */
CanonicalizedPublicKey getEncryptionSubKey() throws PgpGeneralException {
CanonicalizedPublicKey getEncryptionSubKey() throws PgpKeyNotFoundException {
PGPPublicKey key = getRing().getPublicKey(getEncryptId());
if(key != null) {
CanonicalizedPublicKey cKey = new CanonicalizedPublicKey(this, key);
if(!cKey.canEncrypt()) {
throw new PgpGeneralException("key error");
throw new PgpKeyNotFoundException("key error");
}
return cKey;
}
throw new PgpGeneralException("no encryption key available");
throw new PgpKeyNotFoundException("no encryption key available");
}
public IterableIterator<CanonicalizedPublicKey> publicKeyIterator() {

View File

@ -41,6 +41,7 @@ import org.spongycastle.openpgp.operator.jcajce.NfcSyncPGPContentSignerBuilder;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log;
@ -254,9 +255,11 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
spGen.setSignatureCreationTime(false, nfcCreationTimestamp);
signatureGenerator.setHashedSubpackets(spGen.generate());
return signatureGenerator;
} catch (PGPException e) {
} catch (PgpKeyNotFoundException e) {
// TODO: simply throw PGPException!
throw new PgpGeneralException("Error initializing signature!", e);
} catch (PGPException e) {
throw new PgpGeneralException("Error initializing signature!", e);
}
}

View File

@ -20,7 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
import android.text.TextUtils;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -38,25 +38,25 @@ import java.util.regex.Pattern;
*/
public abstract class KeyRing {
abstract public long getMasterKeyId() throws PgpGeneralException;
abstract public long getMasterKeyId() throws PgpKeyNotFoundException;
abstract public String getPrimaryUserId() throws PgpGeneralException;
abstract public String getPrimaryUserId() throws PgpKeyNotFoundException;
abstract public String getPrimaryUserIdWithFallback() throws PgpGeneralException;
abstract public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException;
public String[] getSplitPrimaryUserIdWithFallback() throws PgpGeneralException {
public String[] getSplitPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
return splitUserId(getPrimaryUserIdWithFallback());
}
abstract public boolean isRevoked() throws PgpGeneralException;
abstract public boolean isRevoked() throws PgpKeyNotFoundException;
abstract public boolean canCertify() throws PgpGeneralException;
abstract public boolean canCertify() throws PgpKeyNotFoundException;
abstract public long getEncryptId() throws PgpGeneralException;
abstract public long getEncryptId() throws PgpKeyNotFoundException;
abstract public boolean hasEncrypt() throws PgpGeneralException;
abstract public boolean hasEncrypt() throws PgpKeyNotFoundException;
abstract public int getVerified() throws PgpGeneralException;
abstract public int getVerified() throws PgpKeyNotFoundException;
private static final Pattern USER_ID_PATTERN = Pattern.compile("^(.*?)(?: \\((.*)\\))?(?: <(.*)>)?$");

View File

@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList;
@ -96,7 +97,7 @@ public class OpenPgpSignatureResultBuilder {
setKeyId(signingRing.getMasterKeyId());
try {
setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.d(Constants.TAG, "No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
}
setSignatureKeyCertified(signingRing.getVerified() > 0);

View File

@ -35,6 +35,7 @@ import org.spongycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
@ -392,7 +393,7 @@ public class PgpSignEncrypt {
cPk.addMethod(key.getPubKeyEncryptionGenerator());
log.add(LogType.MSG_SE_KEY_OK, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(id));
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
log.add(LogType.MSG_SE_KEY_WARN, indent + 1,
KeyFormattingUtils.convertKeyIdToHex(id));
} catch (ProviderHelper.NotFoundException e) {

View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
* Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.pgp.exception;
public class PgpKeyNotFoundException extends Exception {
static final long serialVersionUID = 0xf812773342L;
public PgpKeyNotFoundException(String message) {
super(message);
}
public PgpKeyNotFoundException(String message, Throwable cause) {
super(message, cause);
}
public PgpKeyNotFoundException(Throwable cause) {
super(cause);
}
}

View File

@ -24,7 +24,7 @@ import android.net.Uri;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
@ -57,13 +57,13 @@ public class CachedPublicKeyRing extends KeyRing {
}
@Override
public long getMasterKeyId() throws PgpGeneralException {
public long getMasterKeyId() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.MASTER_KEY_ID, ProviderHelper.FIELD_TYPE_INTEGER);
return (Long) data;
} catch (ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
@ -71,7 +71,7 @@ public class CachedPublicKeyRing extends KeyRing {
* Find the master key id related to a given query. The id will either be extracted from the
* query, which should work for all specific /key_rings/ queries, or will be queried if it can't.
*/
public long extractOrGetMasterKeyId() throws PgpGeneralException {
public long extractOrGetMasterKeyId() throws PgpKeyNotFoundException {
// try extracting from the uri first
String firstSegment = mUri.getPathSegments().get(1);
if (!firstSegment.equals("find")) try {
@ -83,70 +83,70 @@ public class CachedPublicKeyRing extends KeyRing {
return getMasterKeyId();
}
public byte[] getFingerprint() throws PgpGeneralException {
public byte[] getFingerprint() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
return (byte[]) data;
} catch (ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
@Override
public String getPrimaryUserId() throws PgpGeneralException {
public String getPrimaryUserId() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.USER_ID,
ProviderHelper.FIELD_TYPE_STRING);
return (String) data;
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
public String getPrimaryUserIdWithFallback() throws PgpGeneralException {
public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
return getPrimaryUserId();
}
@Override
public boolean isRevoked() throws PgpGeneralException {
public boolean isRevoked() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.IS_REVOKED,
ProviderHelper.FIELD_TYPE_INTEGER);
return (Long) data > 0;
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
@Override
public boolean canCertify() throws PgpGeneralException {
public boolean canCertify() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.HAS_CERTIFY,
ProviderHelper.FIELD_TYPE_NULL);
return !((Boolean) data);
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
@Override
public long getEncryptId() throws PgpGeneralException {
public long getEncryptId() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeyRings.HAS_ENCRYPT,
ProviderHelper.FIELD_TYPE_INTEGER);
return (Long) data;
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
@Override
public boolean hasEncrypt() throws PgpGeneralException {
public boolean hasEncrypt() throws PgpKeyNotFoundException {
return getEncryptId() != 0;
}
@ -156,41 +156,41 @@ public class CachedPublicKeyRing extends KeyRing {
* revoked, or expired), hence only works on keyrings where a secret key is available!
*
*/
public long getSecretSignId() throws PgpGeneralException {
public long getSecretSignId() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeyRings.HAS_SIGN,
ProviderHelper.FIELD_TYPE_INTEGER);
return (Long) data;
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
@Override
public int getVerified() throws PgpGeneralException {
public int getVerified() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.VERIFIED,
ProviderHelper.FIELD_TYPE_INTEGER);
return (Integer) data;
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
public boolean hasAnySecret() throws PgpGeneralException {
public boolean hasAnySecret() throws PgpKeyNotFoundException {
try {
Object data = mProviderHelper.getGenericData(mUri,
KeychainContract.KeyRings.HAS_ANY_SECRET,
ProviderHelper.FIELD_TYPE_INTEGER);
return (Long) data > 0;
} catch(ProviderHelper.NotFoundException e) {
throw new PgpGeneralException(e);
throw new PgpKeyNotFoundException(e);
}
}
private Cursor getSubkeys() throws PgpGeneralException {
private Cursor getSubkeys() throws PgpKeyNotFoundException {
Uri keysUri = KeychainContract.Keys.buildKeysUri(extractOrGetMasterKeyId());
return mProviderHelper.getContentResolver().query(keysUri, null, null, null, null);
}

View File

@ -31,6 +31,7 @@ import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.spongycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.ui.NfcActivity;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
@ -272,9 +273,16 @@ public class OpenPgpService extends RemoteService {
InputData inputData = new InputData(is, inputLength);
// Find the appropriate subkey to sign with
long sigSubKeyId;
try {
CachedPublicKeyRing signingRing =
new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
final long sigSubKeyId = signingRing.getSecretSignId();
sigSubKeyId = signingRing.getSecretSignId();
} catch (PgpKeyNotFoundException e) {
// secret key that is set for this account is deleted?
// show account config again!
return getCreateAccountIntent(data, getAccountName(data));
}
// get passphrase from cache, if key has "no" passphrase, this returns an empty String
String passphrase;
@ -285,8 +293,7 @@ public class OpenPgpService extends RemoteService {
passphrase = PassphraseCacheService.getCachedPassphrase(getContext(),
accSettings.getKeyId(), sigSubKeyId);
} catch (PassphraseCacheService.KeyNotFoundException e) {
// secret key that is set for this account is deleted?
// show account config again!
// should happen earlier, but return again here if it happens
return getCreateAccountIntent(data, getAccountName(data));
}
}

View File

@ -30,6 +30,7 @@ import android.os.RemoteException;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpCertifyOperation;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.service.results.CertifyResult;
import org.sufficientlysecure.keychain.util.FileHelper;
@ -719,7 +720,7 @@ public class KeychainIntentService extends IntentService implements Progressable
builder.setNfcState(nfcHash, nfcTimestamp);
}
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
// encrypt-only
// TODO Just silently drop the requested signature? Shouldn't we throw here?
}

View File

@ -39,11 +39,11 @@ import android.support.v4.util.LongSparseArray;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.util.Preferences;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.util.Log;
import java.util.Date;
@ -239,9 +239,9 @@ public class PassphraseCacheService extends Service {
case PASSPHRASE_EMPTY:
return "";
case UNAVAILABLE:
throw new NotFoundException("secret key for this subkey is not available");
throw new ProviderHelper.NotFoundException("secret key for this subkey is not available");
case GNU_DUMMY:
throw new NotFoundException("secret key for stripped subkey is not available");
throw new ProviderHelper.NotFoundException("secret key for stripped subkey is not available");
}
// get cached passphrase

View File

@ -40,6 +40,7 @@ import android.widget.ListView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
@ -226,10 +227,10 @@ public class EditKeyFragment extends LoaderFragment implements
mSaveKeyringParcel = new SaveKeyringParcel(masterKeyId, keyRing.getFingerprint());
mPrimaryUserId = keyRing.getPrimaryUserIdWithFallback();
} catch (NotFoundException e) {
} catch (PgpKeyNotFoundException e) {
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
return;
} catch (PgpGeneralException e) {
} catch (NotFoundException e) {
finishWithError(LogType.MSG_EK_ERROR_NOT_FOUND);
return;
}

View File

@ -29,6 +29,7 @@ import com.tokenautocomplete.TokenCompleteTextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
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;
@ -139,7 +140,7 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
setSignatureKeyId(keyring.getMasterKeyId());
mSign.setSelectedKeyId(mEncryptInterface.getSignatureKey());
}
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
}
@ -151,7 +152,7 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(preselectedId));
mEncryptKeyView.addObject(mEncryptKeyView.new EncryptionKey(ring));
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
}

View File

@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
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.UserIds;
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
@ -115,7 +116,7 @@ public class MultiCertifyKeyFragment extends LoaderFragment
if (key.canCertify()) {
mCertifyKeySpinner.setSelectedKeyId(certifyKeyId);
}
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "certify certify check failed", e);
}
}

View File

@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
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;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
@ -151,7 +152,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
// the catch clause doesn't return.
try {
userId = mSecretRing.getPrimaryUserIdWithFallback();
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
userId = null;
}
@ -312,7 +313,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
PassphraseCacheService.addCachedPassphrase(getActivity(),
mSecretRing.getMasterKeyId(), mSubKeyId, passphrase,
mSecretRing.getPrimaryUserIdWithFallback());
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "adding of a passphrase failed", e);
}

View File

@ -38,6 +38,7 @@ import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
@ -185,7 +186,7 @@ public class ViewCertActivity extends ActionBarActivity
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mCertifierKeyId)).getMasterKeyId();
viewIntent.setData(KeyRings.buildGenericKeyRingUri(signerMasterKeyId));
startActivity(viewIntent);
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
// TODO notify user of this, maybe offer download?
Log.e(Constants.TAG, "key not found!", e);
}

View File

@ -36,6 +36,7 @@ import android.widget.ListView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.KeychainContract;
@ -308,7 +309,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements
}
// used instead of startActivity set actionbar based on callingPackage
startActivityForResult(intent, 0);
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
}

View File

@ -48,6 +48,7 @@ import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
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;
@ -145,7 +146,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
// the catch clause doesn't return.
try {
userId = mSecretRing.getPrimaryUserIdWithFallback();
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
userId = null;
}
@ -308,7 +309,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
PassphraseCacheService.addCachedPassphrase(getActivity(),
mSecretRing.getMasterKeyId(), mSubKeyId, passphrase,
mSecretRing.getPrimaryUserIdWithFallback());
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "adding of a passphrase failed", e);
}

View File

@ -42,6 +42,7 @@ import com.tokenautocomplete.TokenCompleteTextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.ContactHelper;
import org.sufficientlysecure.keychain.pgp.KeyRing;
@ -198,7 +199,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
}
public EncryptionKey(CachedPublicKeyRing ring) throws PgpGeneralException {
public EncryptionKey(CachedPublicKeyRing ring) throws PgpKeyNotFoundException {
this(ring.getPrimaryUserId(), ring.extractOrGetMasterKeyId(),
KeyFormattingUtils.convertFingerprintToHex(ring.getFingerprint()));
}

View File

@ -30,6 +30,7 @@ import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
@ -57,7 +58,7 @@ public class ExportHelper {
DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger,
new long[]{ masterKeyId });
deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog");
} catch (PgpGeneralException e) {
} catch (PgpKeyNotFoundException e) {
Log.e(Constants.TAG, "key not found!", e);
}
}