ditch CachedPublicKeyRing, and some cleanup
This commit is contained in:
@@ -61,15 +61,11 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
return getRing().getPublicKey().getFingerprint();
|
||||
}
|
||||
|
||||
public byte[] getRawPrimaryUserId() throws PgpKeyNotFoundException {
|
||||
public byte[] getRawPrimaryUserId() {
|
||||
return getPublicKey().getRawPrimaryUserId();
|
||||
}
|
||||
|
||||
public String getPrimaryUserId() throws PgpKeyNotFoundException {
|
||||
return getPublicKey().getPrimaryUserId();
|
||||
}
|
||||
|
||||
public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
|
||||
public String getPrimaryUserIdWithFallback() {
|
||||
return getPublicKey().getPrimaryUserIdWithFallback();
|
||||
}
|
||||
|
||||
@@ -107,10 +103,6 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
return creationDate.after(now) || (expirationDate != null && expirationDate.before(now));
|
||||
}
|
||||
|
||||
public boolean canCertify() throws PgpKeyNotFoundException {
|
||||
return getRing().getPublicKey().isEncryptionKey();
|
||||
}
|
||||
|
||||
public Set<Long> getEncryptIds() {
|
||||
HashSet<Long> result = new HashSet<>();
|
||||
for (CanonicalizedPublicKey key : publicKeyIterator()) {
|
||||
@@ -130,15 +122,6 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
throw new PgpKeyNotFoundException("No valid encryption key found!");
|
||||
}
|
||||
|
||||
public boolean hasEncrypt() throws PgpKeyNotFoundException {
|
||||
try {
|
||||
getEncryptId();
|
||||
return true;
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public long getSigningId() throws PgpKeyNotFoundException {
|
||||
for(CanonicalizedPublicKey key : publicKeyIterator()) {
|
||||
if (key.canSign() && key.isValid()) {
|
||||
|
||||
@@ -100,7 +100,7 @@ public class CanonicalizedPublicKeyRing extends CanonicalizedKeyRing {
|
||||
* - the user id that matches the userIdToKeep parameter, or the primary user id if none matches
|
||||
* each with their most recent binding certificates
|
||||
*/
|
||||
public CanonicalizedPublicKeyRing minimize(@Nullable String userIdToKeep) throws IOException, PgpKeyNotFoundException {
|
||||
public CanonicalizedPublicKeyRing minimize(@Nullable String userIdToKeep) throws IOException {
|
||||
CanonicalizedPublicKey masterKey = getPublicKey();
|
||||
PGPPublicKey masterPubKey = masterKey.getPublicKey();
|
||||
boolean userIdStrippedOk = false;
|
||||
|
||||
@@ -326,7 +326,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
|
||||
spGen.setSignatureCreationTime(false, creationTimestamp);
|
||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||
return signatureGenerator;
|
||||
} catch (PgpKeyNotFoundException | PGPException e) {
|
||||
} catch (PGPException e) {
|
||||
// TODO: simply throw PGPException!
|
||||
throw new PgpGeneralException("Error initializing signature!", e);
|
||||
}
|
||||
|
||||
@@ -17,17 +17,12 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* An abstract KeyRing.
|
||||
* <p/>
|
||||
@@ -37,28 +32,17 @@ import java.util.regex.Pattern;
|
||||
* here.
|
||||
*
|
||||
* @see CanonicalizedKeyRing
|
||||
* @see org.sufficientlysecure.keychain.provider.CachedPublicKeyRing
|
||||
*/
|
||||
public abstract class KeyRing {
|
||||
|
||||
abstract public long getMasterKeyId() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public String getPrimaryUserId() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException;
|
||||
|
||||
public UserId getSplitPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
|
||||
return splitUserId(getPrimaryUserIdWithFallback());
|
||||
}
|
||||
|
||||
abstract public boolean isRevoked() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public boolean canCertify() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public long getEncryptId() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public boolean hasEncrypt() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public VerificationStatus getVerified() throws PgpKeyNotFoundException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,11 +119,7 @@ public class OpenPgpSignatureResultBuilder {
|
||||
|
||||
// from RING
|
||||
setKeyId(signingRing.getMasterKeyId());
|
||||
try {
|
||||
setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Timber.d("No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
|
||||
}
|
||||
setPrimaryUserId(signingRing.getPrimaryUserIdWithFallback());
|
||||
setSignatureKeyCertified(signingRing.getVerified() == VerificationStatus.VERIFIED_SECRET);
|
||||
|
||||
List<String> allUserIds = signingRing.getUnorderedUserIds();
|
||||
|
||||
Reference in New Issue
Block a user