Example usage for org.bouncycastle.openpgp PGPPublicKey getValidDays

List of usage examples for org.bouncycastle.openpgp PGPPublicKey getValidDays

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPPublicKey getValidDays.

Prototype

public int getValidDays() 

Source Link

Usage

From source file:com.github.chrbayer84.keybits.GnuPGP.java

License:Open Source License

public String showPublicKey(PGPPublicKey public_key) throws Exception {
    String ret = Long.toHexString(public_key.getKeyID()) + "\n";
    ret = ret + "   created     : " + public_key.getCreationTime() + "\n";
    ret = ret + "   valid (days): " + public_key.getValidDays() + "\n";
    ret = ret + "   users       : ";

    Iterator<String> user_iterator = public_key.getUserIDs();
    int n = 0;//ww w  .java2  s.co  m
    if (user_iterator.hasNext())
        n = 2;

    while (user_iterator.hasNext())
        ret = ret + user_iterator.next() + ", ";

    ret = ret.substring(0, ret.length() - n) + "\n";

    return ret;
}

From source file:org.mule.module.pgp.KeyBasedEncryptionStrategy.java

License:Open Source License

private void checkKeyExpirity(PGPPublicKey publicKey) {
    if (this.isCheckKeyExpirity() && publicKey.getValidDays() != 0) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(publicKey.getCreationTime());
        calendar.add(Calendar.DATE, publicKey.getValidDays());

        if (!calendar.getTime().after(Calendar.getInstance().getTime())) {
            throw new InvalidPublicKeyException(PGPMessages.pgpPublicKeyExpired());
        }/*w w  w .jav a  2s  .  co m*/
    }
}