split up and mark unsafe expiry-related methods
This commit is contained in:
@@ -294,8 +294,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
mKeyId = key.getKeyId();
|
||||
mKeyIdHex = KeyFormattingUtils.convertKeyIdToHex(mKeyId);
|
||||
|
||||
mRevoked = key.isRevoked();
|
||||
mExpired = key.isExpired();
|
||||
mRevoked = key.isMaybeRevoked();
|
||||
mExpired = key.isMaybeExpired();
|
||||
mFingerprintHex = KeyFormattingUtils.convertFingerprintToHex(key.getFingerprint());
|
||||
mBitStrength = key.getBitStrength();
|
||||
mCurveOid = key.getCurveOid();
|
||||
|
||||
@@ -104,8 +104,8 @@ public class OpenPgpSignatureResultBuilder {
|
||||
setUserIds(signingRing.getUnorderedUserIds());
|
||||
|
||||
// either master key is expired/revoked or this specific subkey is expired/revoked
|
||||
setKeyExpired(signingRing.isExpired() || signingKey.isExpired());
|
||||
setKeyRevoked(signingRing.isRevoked() || signingKey.isRevoked());
|
||||
setKeyExpired(signingRing.isExpired() || signingKey.isMaybeExpired());
|
||||
setKeyRevoked(signingRing.isRevoked() || signingKey.isMaybeRevoked());
|
||||
}
|
||||
|
||||
public OpenPgpSignatureResult build() {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class UncachedPublicKey {
|
||||
}
|
||||
|
||||
/** The revocation signature is NOT checked here, so this may be false! */
|
||||
public boolean isRevoked() {
|
||||
public boolean isMaybeRevoked() {
|
||||
return mPublicKey.getSignaturesOfType(isMasterKey()
|
||||
? PGPSignature.KEY_REVOCATION
|
||||
: PGPSignature.SUBKEY_REVOCATION).hasNext();
|
||||
@@ -60,7 +60,8 @@ public class UncachedPublicKey {
|
||||
return mPublicKey.getCreationTime();
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
/** The revocation signature is NOT checked here, so this may be false! */
|
||||
public boolean isMaybeExpired() {
|
||||
Date creationDate = mPublicKey.getCreationTime();
|
||||
Date expiryDate = mPublicKey.getValidSeconds() > 0
|
||||
? new Date(creationDate.getTime() + mPublicKey.getValidSeconds() * 1000) : null;
|
||||
@@ -340,4 +341,24 @@ public class UncachedPublicKey {
|
||||
return mCacheUsage;
|
||||
}
|
||||
|
||||
// this method relies on UNSAFE assumptions about the keyring, and should ONLY be used for
|
||||
// TEST CASES!!
|
||||
Date getUnsafeExpiryTimeForTesting () {
|
||||
long valid = mPublicKey.getValidSeconds();
|
||||
|
||||
if (valid > Integer.MAX_VALUE) {
|
||||
Log.e(Constants.TAG, "error, expiry time too large");
|
||||
return null;
|
||||
}
|
||||
if (valid == 0) {
|
||||
// no expiry
|
||||
return null;
|
||||
}
|
||||
Date creationDate = getCreationTime();
|
||||
Calendar calendar = GregorianCalendar.getInstance();
|
||||
calendar.setTime(creationDate);
|
||||
calendar.add(Calendar.SECOND, (int) valid);
|
||||
|
||||
return calendar.getTime();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user