use Enum for verification status of certificates
This commit is contained in:
@@ -8,7 +8,7 @@ import org.sufficientlysecure.keychain.CertsModel;
|
||||
@AutoValue
|
||||
public abstract class Certification implements CertsModel {
|
||||
public static final CertsModel.Factory<Certification> FACTORY =
|
||||
new CertsModel.Factory<>(AutoValue_Certification::new);
|
||||
new CertsModel.Factory<>(AutoValue_Certification::new, CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER);
|
||||
|
||||
public static final SelectVerifyingCertDetailsMapper<CertDetails> CERT_DETAILS_MAPPER =
|
||||
new SelectVerifyingCertDetailsMapper<>(AutoValue_Certification_CertDetails::new);
|
||||
|
||||
@@ -7,10 +7,10 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import com.squareup.sqldelight.ColumnAdapter;
|
||||
import org.sufficientlysecure.keychain.model.AutocryptPeer.GossipOrigin;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
|
||||
|
||||
|
||||
public final class CustomColumnAdapters {
|
||||
|
||||
private CustomColumnAdapters() { }
|
||||
@@ -64,4 +64,30 @@ public final class CustomColumnAdapters {
|
||||
return (long) value.getNum();
|
||||
}
|
||||
};
|
||||
|
||||
public static final ColumnAdapter<VerificationStatus,Long> VERIFICATON_STATUS_ADAPTER = new ColumnAdapter<VerificationStatus, Long>() {
|
||||
@NonNull
|
||||
@Override
|
||||
public VerificationStatus decode(Long databaseValue) {
|
||||
if (databaseValue == null) {
|
||||
return VerificationStatus.UNVERIFIED;
|
||||
}
|
||||
switch (databaseValue.intValue()) {
|
||||
case 0: return VerificationStatus.UNVERIFIED;
|
||||
case 1: return VerificationStatus.VERIFIED_SECRET;
|
||||
case 2: return VerificationStatus.VERIFIED_SELF;
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long encode(@NonNull VerificationStatus value) {
|
||||
switch (value) {
|
||||
case UNVERIFIED: return 0L;
|
||||
case VERIFIED_SECRET: return 1L;
|
||||
case VERIFIED_SELF: return 2L;
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.squareup.sqldelight.RowMapper;
|
||||
import org.sufficientlysecure.keychain.KeysModel;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
|
||||
|
||||
@@ -15,8 +16,9 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
public abstract class SubKey implements KeysModel {
|
||||
public static final Factory<SubKey> FACTORY =
|
||||
new Factory<>(AutoValue_SubKey::new, CustomColumnAdapters.SECRET_KEY_TYPE_ADAPTER);
|
||||
public static final UnifiedKeyViewMapper<UnifiedKeyInfo> UNIFIED_KEY_INFO_MAPPER =
|
||||
FACTORY.selectUnifiedKeyInfoByMasterKeyIdMapper(AutoValue_SubKey_UnifiedKeyInfo::new);
|
||||
public static final UnifiedKeyViewMapper<UnifiedKeyInfo, Certification> UNIFIED_KEY_INFO_MAPPER =
|
||||
FACTORY.selectAllUnifiedKeyInfoMapper(
|
||||
AutoValue_SubKey_UnifiedKeyInfo::new, Certification.FACTORY);
|
||||
public static Mapper<SubKey> SUBKEY_MAPPER = new Mapper<>(FACTORY);
|
||||
public static RowMapper<SecretKeyType> SKT_MAPPER = FACTORY.selectSecretKeyTypeMapper();
|
||||
|
||||
@@ -38,8 +40,8 @@ public abstract class SubKey implements KeysModel {
|
||||
}
|
||||
|
||||
public boolean is_verified() {
|
||||
Integer verified = verified();
|
||||
return verified != null && verified == 1;
|
||||
VerificationStatus verified = verified();
|
||||
return verified != null && verified == VerificationStatus.VERIFIED_SECRET;
|
||||
}
|
||||
|
||||
public boolean has_duplicate() {
|
||||
|
||||
@@ -3,30 +3,29 @@ package org.sufficientlysecure.keychain.model;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import org.sufficientlysecure.keychain.UserPacketsModel;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
|
||||
|
||||
@AutoValue
|
||||
public abstract class UserPacket implements UserPacketsModel {
|
||||
public static final Factory<UserPacket> FACTORY = new Factory<>(AutoValue_UserPacket::new);
|
||||
public static final SelectUserIdsByMasterKeyIdMapper<UserId> USER_ID_MAPPER =
|
||||
FACTORY.selectUserIdsByMasterKeyIdMapper(AutoValue_UserPacket_UserId::new);
|
||||
public static final SelectUserAttributesByTypeAndMasterKeyIdMapper<UserAttribute> USER_ATTRIBUTE_MAPPER =
|
||||
FACTORY.selectUserAttributesByTypeAndMasterKeyIdMapper(AutoValue_UserPacket_UserAttribute::new);
|
||||
public static final SelectUserIdsByMasterKeyIdMapper<UserId, Certification> USER_ID_MAPPER =
|
||||
FACTORY.selectUserIdsByMasterKeyIdMapper(AutoValue_UserPacket_UserId::new, Certification.FACTORY);
|
||||
public static final SelectUserAttributesByTypeAndMasterKeyIdMapper<UserAttribute, Certification> USER_ATTRIBUTE_MAPPER =
|
||||
FACTORY.selectUserAttributesByTypeAndMasterKeyIdMapper(AutoValue_UserPacket_UserAttribute::new, Certification.FACTORY);
|
||||
|
||||
@AutoValue
|
||||
public static abstract class UserId implements SelectUserIdsByMasterKeyIdModel {
|
||||
public boolean isVerified() {
|
||||
Integer verified = verified();
|
||||
return verified != null && verified == Certs.VERIFIED_SECRET;
|
||||
return verified() == VerificationStatus.VERIFIED_SECRET;
|
||||
}
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public static abstract class UserAttribute implements SelectUserAttributesByTypeAndMasterKeyIdModel {
|
||||
public boolean isVerified() {
|
||||
Integer verified = verified();
|
||||
return verified != null && verified == Certs.VERIFIED_SECRET;
|
||||
return verified() == VerificationStatus.VERIFIED_SECRET;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,6 +20,8 @@ package org.sufficientlysecure.keychain.provider;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import org.sufficientlysecure.keychain.model.CustomColumnAdapters;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
@@ -238,12 +240,12 @@ public class CachedPublicKeyRing extends KeyRing {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVerified() throws PgpKeyNotFoundException {
|
||||
public VerificationStatus getVerified() throws PgpKeyNotFoundException {
|
||||
try {
|
||||
Object data = mKeyRepository.getGenericData(mUri,
|
||||
KeychainContract.KeyRings.VERIFIED,
|
||||
KeyRepository.FIELD_TYPE_INTEGER);
|
||||
return ((Long) data).intValue();
|
||||
return CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode((Long) data);
|
||||
} catch(KeyWritableRepository.NotFoundException e) {
|
||||
throw new PgpKeyNotFoundException(e);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import android.net.Uri;
|
||||
|
||||
import com.squareup.sqldelight.SqlDelightQuery;
|
||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||
import org.sufficientlysecure.keychain.model.Certification;
|
||||
import org.sufficientlysecure.keychain.model.CustomColumnAdapters;
|
||||
import org.sufficientlysecure.keychain.model.KeyRingPublic;
|
||||
import org.sufficientlysecure.keychain.model.SubKey;
|
||||
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
||||
@@ -38,12 +40,12 @@ import org.sufficientlysecure.keychain.model.UserPacket;
|
||||
import org.sufficientlysecure.keychain.model.UserPacket.UserId;
|
||||
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.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
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.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import timber.log.Timber;
|
||||
|
||||
@@ -197,10 +199,11 @@ public class KeyRepository extends AbstractDao {
|
||||
try {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
long masterKeyId = cursor.getLong(0);
|
||||
int verified = cursor.getInt(1);
|
||||
long verified = cursor.getLong(1);
|
||||
|
||||
byte[] publicKeyData = loadPublicKeyRingData(masterKeyId);
|
||||
return new CanonicalizedPublicKeyRing(publicKeyData, verified);
|
||||
VerificationStatus verificationStatus = CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(verified);
|
||||
return new CanonicalizedPublicKeyRing(publicKeyData, verificationStatus);
|
||||
} else {
|
||||
throw new NotFoundException("Key not found!");
|
||||
}
|
||||
@@ -221,14 +224,16 @@ public class KeyRepository extends AbstractDao {
|
||||
try {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
long masterKeyId = cursor.getLong(0);
|
||||
int verified = cursor.getInt(1);
|
||||
long verified = cursor.getLong(1);
|
||||
int hasAnySecret = cursor.getInt(2);
|
||||
if (hasAnySecret == 0) {
|
||||
throw new NotFoundException("No secret key available or unknown public key!");
|
||||
}
|
||||
|
||||
VerificationStatus verificationStatus = CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(verified);
|
||||
|
||||
byte[] secretKeyData = loadSecretKeyRingData(masterKeyId);
|
||||
return new CanonicalizedSecretKeyRing(secretKeyData, verified);
|
||||
return new CanonicalizedSecretKeyRing(secretKeyData, verificationStatus);
|
||||
} else {
|
||||
throw new NotFoundException("Key not found!");
|
||||
}
|
||||
@@ -286,8 +291,8 @@ public class KeyRepository extends AbstractDao {
|
||||
|
||||
public List<String> getConfirmedUserIds(long masterKeyId) {
|
||||
ArrayList<String> userIds = new ArrayList<>();
|
||||
SqlDelightQuery query =
|
||||
UserPacket.FACTORY.selectUserIdsByMasterKeyIdAndVerification(masterKeyId, Certs.VERIFIED_SECRET);
|
||||
SqlDelightQuery query = UserPacket.FACTORY.selectUserIdsByMasterKeyIdAndVerification(
|
||||
Certification.FACTORY, masterKeyId, VerificationStatus.VERIFIED_SECRET);
|
||||
for (UserId userId : mapAllRows(query, UserPacket.USER_ID_MAPPER::map)) {
|
||||
userIds.add(userId.user_id());
|
||||
}
|
||||
|
||||
@@ -39,11 +39,13 @@ import android.support.v4.util.LongSparseArray;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.KeyRingsPublicModel.DeleteByMasterKeyId;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.model.CustomColumnAdapters;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.operations.results.UpdateTrustResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||
@@ -134,10 +136,11 @@ public class KeyWritableRepository extends KeyRepository {
|
||||
while (cursor.moveToNext()) {
|
||||
try {
|
||||
long masterKeyId = cursor.getLong(0);
|
||||
int verified = cursor.getInt(2);
|
||||
long verified = cursor.getLong(2);
|
||||
byte[] blob = loadPublicKeyRingData(masterKeyId);
|
||||
VerificationStatus verificationStatus = CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(verified);
|
||||
if (blob != null) {
|
||||
result.put(masterKeyId, new CanonicalizedPublicKeyRing(blob, verified).getPublicKey());
|
||||
result.put(masterKeyId, new CanonicalizedPublicKeyRing(blob, verificationStatus).getPublicKey());
|
||||
}
|
||||
} catch (NotFoundException e) {
|
||||
throw new IllegalStateException("Error reading secret key data, this should not happen!", e);
|
||||
@@ -499,7 +502,7 @@ public class KeyWritableRepository extends KeyRepository {
|
||||
|
||||
if (item.selfRevocation != null) {
|
||||
operations.add(buildCertOperations(masterKeyId, userIdRank, item.selfRevocation,
|
||||
Certs.VERIFIED_SELF));
|
||||
VerificationStatus.VERIFIED_SELF));
|
||||
// don't bother with trusted certs if the uid is revoked, anyways
|
||||
continue;
|
||||
}
|
||||
@@ -509,7 +512,7 @@ public class KeyWritableRepository extends KeyRepository {
|
||||
}
|
||||
|
||||
operations.add(buildCertOperations(masterKeyId, userIdRank, item.selfCert,
|
||||
selfCertsAreTrusted ? Certs.VERIFIED_SECRET : Certs.VERIFIED_SELF));
|
||||
selfCertsAreTrusted ? VerificationStatus.VERIFIED_SECRET : VerificationStatus.VERIFIED_SELF));
|
||||
|
||||
// iterate over signatures
|
||||
for (int i = 0; i < item.trustedCerts.size(); i++) {
|
||||
@@ -521,7 +524,7 @@ public class KeyWritableRepository extends KeyRepository {
|
||||
}
|
||||
// otherwise, build database operation
|
||||
operations.add(buildCertOperations(
|
||||
masterKeyId, userIdRank, sig, Certs.VERIFIED_SECRET));
|
||||
masterKeyId, userIdRank, sig, VerificationStatus.VERIFIED_SECRET));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1064,7 +1067,7 @@ public class KeyWritableRepository extends KeyRepository {
|
||||
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
|
||||
*/
|
||||
private ContentProviderOperation
|
||||
buildCertOperations(long masterKeyId, int rank, WrappedSignature cert, int verified)
|
||||
buildCertOperations(long masterKeyId, int rank, WrappedSignature cert, VerificationStatus verificationStatus)
|
||||
throws IOException {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Certs.MASTER_KEY_ID, masterKeyId);
|
||||
@@ -1072,7 +1075,7 @@ public class KeyWritableRepository extends KeyRepository {
|
||||
values.put(Certs.KEY_ID_CERTIFIER, cert.getKeyId());
|
||||
values.put(Certs.TYPE, cert.getSignatureType());
|
||||
values.put(Certs.CREATION, cert.getCreationTime().getTime() / 1000);
|
||||
values.put(Certs.VERIFIED, verified);
|
||||
values.put(Certs.VERIFIED, CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.encode(verificationStatus));
|
||||
values.put(Certs.DATA, cert.getEncoded());
|
||||
|
||||
Uri uri = Certs.buildCertsUri(masterKeyId);
|
||||
|
||||
@@ -179,7 +179,6 @@ public class KeychainContract {
|
||||
}
|
||||
|
||||
public static class Certs implements CertsColumns, BaseColumns {
|
||||
public static final int UNVERIFIED = 0;
|
||||
public static final int VERIFIED_SECRET = 1;
|
||||
public static final int VERIFIED_SELF = 2;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
|
||||
import org.sufficientlysecure.keychain.model.UserPacket.UserId;
|
||||
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity.ViewKeyAdvViewModel;
|
||||
@@ -155,7 +156,7 @@ public class ViewKeyAdvUserIdsFragment extends Fragment {
|
||||
private void showUserIdInfo(final int position) {
|
||||
|
||||
final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position);
|
||||
final boolean isVerified = mUserIdsAdapter.getIsVerified(position) == Certs.VERIFIED_SECRET;
|
||||
final boolean isVerified = mUserIdsAdapter.getVerificationStatus(position) == VerificationStatus.VERIFIED_SECRET;
|
||||
|
||||
DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(() -> {
|
||||
UserIdInfoDialogFragment dialogFragment =
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysResultList
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||
@@ -94,7 +95,8 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
keyRing = mKeyRepository.getCachedPublicKeyRing(keyId);
|
||||
}
|
||||
keyState.mAlreadyPresent = true;
|
||||
keyState.mVerified = keyRing.getVerified() > 0;
|
||||
VerificationStatus verified = keyRing.getVerified();
|
||||
keyState.mVerified = verified != null && verified != VerificationStatus.UNVERIFIED;
|
||||
} catch (KeyRepository.NotFoundException | PgpKeyNotFoundException ignored) {
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import android.widget.ViewAnimator;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.model.UserPacket.UserId;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
|
||||
@@ -163,12 +163,12 @@ public class UserIdsAdapter extends BaseAdapter {
|
||||
vAddress.setTypeface(null, Typeface.NORMAL);
|
||||
}
|
||||
|
||||
int isVerified = getIsVerified(position);
|
||||
VerificationStatus isVerified = getVerificationStatus(position);
|
||||
switch (isVerified) {
|
||||
case Certs.VERIFIED_SECRET:
|
||||
case VERIFIED_SECRET:
|
||||
KeyFormattingUtils.setStatusImage(context, vVerified, null, State.VERIFIED, KeyFormattingUtils.DEFAULT_COLOR);
|
||||
break;
|
||||
case Certs.VERIFIED_SELF:
|
||||
case VERIFIED_SELF:
|
||||
KeyFormattingUtils.setStatusImage(context, vVerified, null, State.UNVERIFIED, KeyFormattingUtils.DEFAULT_COLOR);
|
||||
break;
|
||||
default:
|
||||
@@ -216,7 +216,7 @@ public class UserIdsAdapter extends BaseAdapter {
|
||||
return data.get(position).is_revoked();
|
||||
}
|
||||
|
||||
public int getIsVerified(int position) {
|
||||
public VerificationStatus getVerificationStatus(int position) {
|
||||
return data.get(position).verified();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user