Example usage for org.bouncycastle.bcpg SignatureSubpacketTags EXPIRE_TIME

List of usage examples for org.bouncycastle.bcpg SignatureSubpacketTags EXPIRE_TIME

Introduction

In this page you can find the example usage for org.bouncycastle.bcpg SignatureSubpacketTags EXPIRE_TIME.

Prototype

int EXPIRE_TIME

To view the source code for org.bouncycastle.bcpg SignatureSubpacketTags EXPIRE_TIME.

Click Source Link

Usage

From source file:com.google.e2e.bcdriver.KeyChecker.java

License:Apache License

private static final boolean isSignatureCurrent(PGPSignature sig, StringBuilder errors) {

    long ts = getSignatureTimestamp(sig, errors);
    if (ts < 0) {
        return false;
    }// ww  w  .j  ava  2  s .  com
    // Timestamp should not be in the future.
    if (ts > (System.currentTimeMillis() + ACCEPTABLE_DELTA_MSEC)) {
        errors.append(niceSig(sig) + " in the future? (" + new Date(ts) + ")\n");
        return false;
    }
    if (ts < 0) {
        errors.append(niceSig(sig) + " is negative? (" + ts + ")\n");
        return false;
    }

    // Check if the signature or key has expired.
    PGPSignatureSubpacketVector svec = sig.getHashedSubPackets();
    if (svec != null) {
        SignatureExpirationTime tspack = (SignatureExpirationTime) svec
                .getSubpacket(SignatureSubpacketTags.EXPIRE_TIME);
        if (tspack != null) {
            long expDelta = tspack.getTime() * 1000L;
            if (!acceptableInterval(sig, ts, expDelta, errors)) {
                return false;
            }
        }
        // If there's a key-expiration subpacket, also check that.
        KeyExpirationTime ket = (KeyExpirationTime) svec.getSubpacket(SignatureSubpacketTags.KEY_EXPIRE_TIME);
        if (ket != null) {
            long expDelta = ket.getTime() * 1000L;
            if (!acceptableInterval(sig, ts, expDelta, errors)) {
                return false;
            }
        }
    }

    return true;
}