Example usage for org.bouncycastle.openpgp PGPSignature getVersion

List of usage examples for org.bouncycastle.openpgp PGPSignature getVersion

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPSignature getVersion.

Prototype

public int getVersion() 

Source Link

Document

Return the OpenPGP version number for this signature.

Usage

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

License:Apache License

private static final long getSignatureTimestamp(PGPSignature sig, StringBuilder errors) {
    long ts = sig.getCreationTime().getTime();
    // Work-around bouncycastle not indicating lack of timestamp as a
    // hashed subpacket.
    if (sig.getVersion() == 4) {
        // Make sure we actually have a timestamp packet in
        // the hashed section.
        PGPSignatureSubpacketVector svec = sig.getHashedSubPackets();
        if (svec == null) {
            errors.append(niceSig(sig) + " is missing a creation timestamp.\n");
            return -1L;
        }/*from  ww  w . j av  a 2  s . co  m*/
        SignatureCreationTime tspack = (SignatureCreationTime) svec
                .getSubpacket(SignatureSubpacketTags.CREATION_TIME);
        if (tspack == null) {
            errors.append(niceSig(sig) + " is missing a creation timestamp.\n");
            return -1L;
        }
        ts = tspack.getTime().getTime();
    }
    return ts;
}