Package org.pgpainless.key.info
Class KeyRingInfo
- java.lang.Object
-
- org.pgpainless.key.info.KeyRingInfo
-
public class KeyRingInfo extends java.lang.Object
Utility class to quickly extract certain information from aPGPPublicKeyRing
/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 theOpenPgpV4Fingerprint
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 firstPGPPublicKey
of this key ring.java.util.List<org.bouncycastle.openpgp.PGPPublicKey>
getPublicKeys()
Return allPGPPublicKeys
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 primaryPGPSecretKey
of this key ring or null if the key ring is not aPGPSecretKeyRing
.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 aPGPSecretKeyRing
.
-
-
-
Method Detail
-
getPublicKey
public org.bouncycastle.openpgp.PGPPublicKey getPublicKey()
Return the firstPGPPublicKey
of this key ring.- Returns:
- public key
-
getPublicKeys
public java.util.List<org.bouncycastle.openpgp.PGPPublicKey> getPublicKeys()
Return allPGPPublicKeys
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 primaryPGPSecretKey
of this key ring or null if the key ring is not aPGPSecretKeyRing
.- 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 aPGPPublicKeyRing
, 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
-
getFingerprint
public OpenPgpV4Fingerprint getFingerprint()
Return theOpenPgpV4Fingerprint
of this key ring.- Returns:
- fingerprint
-
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 aPGPSecretKeyRing
. If it is aPGPPublicKeyRing
return false and if it is neither, throw anAssertionError
.- 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 aPGPPublicKeyRing
, return true.- Returns:
- true if all secret keys are unencrypted.
-
-