Class KeyRingInfo


  • public class KeyRingInfo
    extends java.lang.Object
    Utility class to quickly extract certain information from a PGPPublicKeyRing/PGPSecretKeyRing.
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyRingInfo​(org.bouncycastle.openpgp.PGPKeyRing keys)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PublicKeyAlgorithm getAlgorithm()
      Return the algorithm of the primary key.
      java.util.Date getCreationDate()
      Return the creation date of the primary key.
      java.util.List<java.lang.String> getEmailAddresses()
      Return a list of all user-ids of the primary key that appear to be email-addresses.
      java.util.Date getExpirationDate()
      Return the date of expiration of the primary key or null if the key has no expiration date.
      OpenPgpV4Fingerprint getFingerprint()
      Return the OpenPgpV4Fingerprint of this key ring.
      long getKeyId()
      Return the key id of the primary key of this key ring.
      java.util.Date getLastModified()
      Return the date on which the key ring was last modified.
      org.bouncycastle.openpgp.PGPPublicKey getPublicKey()
      Return the first PGPPublicKey of this key ring.
      java.util.List<org.bouncycastle.openpgp.PGPPublicKey> getPublicKeys()
      Return all PGPPublicKeys of this key ring.
      java.util.Date getRevocationDate()
      Return the date on which the primary key was revoked, or null if it has not yet been revoked.
      org.bouncycastle.openpgp.PGPSecretKey getSecretKey()
      Return the primary PGPSecretKey of this key ring or null if the key ring is not a PGPSecretKeyRing.
      java.util.List<org.bouncycastle.openpgp.PGPSecretKey> getSecretKeys()
      Return all secret keys of the key ring.
      java.util.List<java.lang.String> getUserIds()
      Return a list of all user-ids of the primary key.
      boolean isFullyDecrypted()
      Return true when every secret key on the key ring is not encrypted.
      boolean isSecretKey()
      Return true if the key ring is a PGPSecretKeyRing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeyRingInfo

        public KeyRingInfo​(org.bouncycastle.openpgp.PGPKeyRing keys)
    • Method Detail

      • getPublicKey

        public org.bouncycastle.openpgp.PGPPublicKey getPublicKey()
        Return the first PGPPublicKey of this key ring.
        Returns:
        public key
      • getPublicKeys

        public java.util.List<org.bouncycastle.openpgp.PGPPublicKey> getPublicKeys()
        Return all PGPPublicKeys of this key ring. The first key in the list being the primary key. Note that the list is unmodifiable.
        Returns:
        list of public keys
      • getSecretKey

        public org.bouncycastle.openpgp.PGPSecretKey getSecretKey()
        Return the primary PGPSecretKey of this key ring or null if the key ring is not a PGPSecretKeyRing.
        Returns:
        primary secret key or null if the key ring is public
      • getSecretKeys

        public java.util.List<org.bouncycastle.openpgp.PGPSecretKey> getSecretKeys()
        Return all secret keys of the key ring. If the key ring is a PGPPublicKeyRing, then return an empty list. Note that the list is unmodifiable.
        Returns:
        list of secret keys
      • getKeyId

        public long getKeyId()
        Return the key id of the primary key of this key ring.
        Returns:
        key id
      • getUserIds

        public java.util.List<java.lang.String> getUserIds()
        Return a list of all user-ids of the primary key.
        Returns:
        list of user-ids
      • getEmailAddresses

        public java.util.List<java.lang.String> getEmailAddresses()
        Return a list of all user-ids of the primary key that appear to be email-addresses.
        Returns:
        email addresses
      • getAlgorithm

        public PublicKeyAlgorithm getAlgorithm()
        Return the algorithm of the primary key.
        Returns:
        public key algorithm
      • getCreationDate

        public java.util.Date getCreationDate()
        Return the creation date of the primary key.
        Returns:
        creation date
      • getLastModified

        public java.util.Date getLastModified()
        Return the date on which the key ring was last modified. This date corresponds to the date of the last signature that was made on this key ring by the primary key.
        Returns:
        last modification date.
      • getRevocationDate

        public java.util.Date getRevocationDate()
        Return the date on which the primary key was revoked, or null if it has not yet been revoked.
        Returns:
        revocation date or null
      • getExpirationDate

        public java.util.Date getExpirationDate()
        Return the date of expiration of the primary key or null if the key has no expiration date.
        Returns:
        expiration date
      • isSecretKey

        public boolean isSecretKey()
        Return true if the key ring is a PGPSecretKeyRing. If it is a PGPPublicKeyRing return false and if it is neither, throw an AssertionError.
        Returns:
        true if the key ring is a secret key ring.
      • isFullyDecrypted

        public boolean isFullyDecrypted()
        Return true when every secret key on the key ring is not encrypted. If there is at least one encrypted secret key on the ring, return false. If the ring is a PGPPublicKeyRing, return true.
        Returns:
        true if all secret keys are unencrypted.