use Enum for verification status of certificates
This commit is contained in:
@@ -43,9 +43,9 @@ import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
*/
|
||||
public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
|
||||
private final int mVerified;
|
||||
private final VerificationStatus mVerified;
|
||||
|
||||
CanonicalizedKeyRing(int verified) {
|
||||
CanonicalizedKeyRing(VerificationStatus verified) {
|
||||
mVerified = verified;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
return getRing().getPublicKey().getKeyID();
|
||||
}
|
||||
|
||||
public int getVerified() {
|
||||
public VerificationStatus getVerified() {
|
||||
return mVerified;
|
||||
}
|
||||
|
||||
@@ -194,4 +194,8 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum VerificationStatus {
|
||||
UNVERIFIED, VERIFIED_SELF, VERIFIED_SECRET
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ public class CanonicalizedPublicKeyRing extends CanonicalizedKeyRing {
|
||||
|
||||
private PGPPublicKeyRing mRing;
|
||||
|
||||
CanonicalizedPublicKeyRing(PGPPublicKeyRing ring, int verified) {
|
||||
CanonicalizedPublicKeyRing(PGPPublicKeyRing ring, VerificationStatus verified) {
|
||||
super(verified);
|
||||
mRing = ring;
|
||||
}
|
||||
|
||||
public CanonicalizedPublicKeyRing(byte[] blob, int verified) {
|
||||
public CanonicalizedPublicKeyRing(byte[] blob, VerificationStatus verified) {
|
||||
super(verified);
|
||||
if(mRing == null) {
|
||||
// get first object in block
|
||||
|
||||
@@ -35,12 +35,12 @@ public class CanonicalizedSecretKeyRing extends CanonicalizedKeyRing {
|
||||
|
||||
private PGPSecretKeyRing mRing;
|
||||
|
||||
CanonicalizedSecretKeyRing(PGPSecretKeyRing ring, int verified) {
|
||||
CanonicalizedSecretKeyRing(PGPSecretKeyRing ring, VerificationStatus verified) {
|
||||
super(verified);
|
||||
mRing = ring;
|
||||
}
|
||||
|
||||
public CanonicalizedSecretKeyRing(byte[] blob, int verified)
|
||||
public CanonicalizedSecretKeyRing(byte[] blob, VerificationStatus verified)
|
||||
{
|
||||
super(verified);
|
||||
JcaPGPObjectFactory factory = new JcaPGPObjectFactory(blob);
|
||||
|
||||
@@ -21,6 +21,7 @@ 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;
|
||||
@@ -58,7 +59,7 @@ public abstract class KeyRing {
|
||||
|
||||
abstract public boolean hasEncrypt() throws PgpKeyNotFoundException;
|
||||
|
||||
abstract public int getVerified() throws PgpKeyNotFoundException;
|
||||
abstract public VerificationStatus getVerified() throws PgpKeyNotFoundException;
|
||||
|
||||
/**
|
||||
* Splits userId string into naming part, email part, and comment part
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult.SenderStatusResult;
|
||||
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 org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||
import timber.log.Timber;
|
||||
@@ -123,7 +124,7 @@ public class OpenPgpSignatureResultBuilder {
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Timber.d("No primary user id in keyring with master key id " + signingRing.getMasterKeyId());
|
||||
}
|
||||
setSignatureKeyCertified(signingRing.getVerified() > 0);
|
||||
setSignatureKeyCertified(signingRing.getVerified() != VerificationStatus.UNVERIFIED);
|
||||
|
||||
List<String> allUserIds = signingRing.getUnorderedUserIds();
|
||||
List<String> confirmedUserIds = mKeyRepository.getConfirmedUserIds(signingRing.getMasterKeyId());
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
@@ -1115,8 +1116,8 @@ public class UncachedKeyRing {
|
||||
log.add(LogType.MSG_KC_SUCCESS, indent);
|
||||
}
|
||||
|
||||
return isSecret() ? new CanonicalizedSecretKeyRing((PGPSecretKeyRing) ring, 1)
|
||||
: new CanonicalizedPublicKeyRing((PGPPublicKeyRing) ring, 0);
|
||||
return isSecret() ? new CanonicalizedSecretKeyRing((PGPSecretKeyRing) ring, VerificationStatus.VERIFIED_SECRET)
|
||||
: new CanonicalizedPublicKeyRing((PGPPublicKeyRing) ring, VerificationStatus.UNVERIFIED);
|
||||
}
|
||||
|
||||
/** This operation merges information from a different keyring, returning a combined
|
||||
|
||||
Reference in New Issue
Block a user