Class KeyRingInfo


  • public class KeyRingInfo
    extends java.lang.Object
    Utility class to quickly extract certain information from a PGPPublicKeyRing/PGPSecretKeyRing.
    • 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
      • getPublicKey

        public org.bouncycastle.openpgp.PGPPublicKey getPublicKey​(OpenPgpV4Fingerprint fingerprint)
      • getPublicKey

        public org.bouncycastle.openpgp.PGPPublicKey getPublicKey​(long keyId)
      • getPublicKey

        public static org.bouncycastle.openpgp.PGPPublicKey getPublicKey​(org.bouncycastle.openpgp.PGPKeyRing keyRing,
                                                                         long keyId)
      • 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
      • getSecretKey

        public org.bouncycastle.openpgp.PGPSecretKey getSecretKey​(OpenPgpV4Fingerprint fingerprint)
      • getSecretKey

        public org.bouncycastle.openpgp.PGPSecretKey getSecretKey​(long keyId)
      • 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
      • getPrimaryUserId

        public java.lang.String getPrimaryUserId()
                                          throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • 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
      • getValidUserIds

        public java.util.List<java.lang.String> getValidUserIds()
      • isUserIdValid

        public boolean isUserIdValid​(java.lang.String userId)
      • isUserIdValid

        public boolean isUserIdValid​(long keyId,
                                     java.lang.String userId)
      • 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.
      • getSelfSignaturesOnKey

        public java.util.List<org.bouncycastle.openpgp.PGPSignature> getSelfSignaturesOnKey​(long subkeyId)
      • getLatestValidSelfSignatureOnKey

        public org.bouncycastle.openpgp.PGPSignature getLatestValidSelfSignatureOnKey()
                                                                               throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getLatestValidSelfSignatureOnKey

        public org.bouncycastle.openpgp.PGPSignature getLatestValidSelfSignatureOnKey​(OpenPgpV4Fingerprint fingerprint)
                                                                               throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getLatestValidSelfSignatureOnKey

        public org.bouncycastle.openpgp.PGPSignature getLatestValidSelfSignatureOnKey​(long subkeyId)
                                                                               throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getLatestValidSignatureOnUserId

        public org.bouncycastle.openpgp.PGPSignature getLatestValidSignatureOnUserId​(java.lang.String userId)
                                                                              throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getBindingSignaturesOnKey

        public java.util.List<org.bouncycastle.openpgp.PGPSignature> getBindingSignaturesOnKey​(OpenPgpV4Fingerprint fingerprint)
      • getBindingSignaturesOnKey

        public java.util.List<org.bouncycastle.openpgp.PGPSignature> getBindingSignaturesOnKey​(long subkeyId)
      • getLatestValidBindingSignatureOnKey

        public org.bouncycastle.openpgp.PGPSignature getLatestValidBindingSignatureOnKey​(long subKeyID)
                                                                                  throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getLatestValidSelfOrBindingSignatureOnKey

        public org.bouncycastle.openpgp.PGPSignature getLatestValidSelfOrBindingSignatureOnKey​(OpenPgpV4Fingerprint fingerprint)
                                                                                        throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getLatestValidSelfOrBindingSignatureOnKey

        public org.bouncycastle.openpgp.PGPSignature getLatestValidSelfOrBindingSignatureOnKey​(long subKeyId)
                                                                                        throws org.bouncycastle.openpgp.PGPException
        Throws:
        org.bouncycastle.openpgp.PGPException