Package org.pgpainless.key.info
Class KeyRingInfo
- java.lang.Object
-
- org.pgpainless.key.info.KeyRingInfo
-
public class KeyRingInfo extends java.lang.ObjectUtility class to quickly extract certain information from aPGPPublicKeyRing/PGPSecretKeyRing.
-
-
Constructor Summary
Constructors Constructor Description KeyRingInfo(org.bouncycastle.openpgp.PGPKeyRing keys)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PublicKeyAlgorithmgetAlgorithm()Return the algorithm of the primary key.java.util.List<org.bouncycastle.openpgp.PGPSignature>getBindingSignaturesOnKey(long subkeyId)java.util.List<org.bouncycastle.openpgp.PGPSignature>getBindingSignaturesOnKey(OpenPgpV4Fingerprint fingerprint)java.util.DategetCreationDate()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.DategetExpirationDate()Return the date of expiration of the primary key or null if the key has no expiration date.java.util.DategetExpirationDate(OpenPgpV4Fingerprint fingerprint)OpenPgpV4FingerprintgetFingerprint()Return theOpenPgpV4Fingerprintof this key ring.longgetKeyId()Return the key id of the primary key of this key ring.java.util.DategetLastModified()Return the date on which the key ring was last modified.org.bouncycastle.openpgp.PGPSignaturegetLatestValidBindingSignatureOnKey(long subKeyID)org.bouncycastle.openpgp.PGPSignaturegetLatestValidSelfOrBindingSignatureOnKey(long subKeyId)org.bouncycastle.openpgp.PGPSignaturegetLatestValidSelfOrBindingSignatureOnKey(OpenPgpV4Fingerprint fingerprint)org.bouncycastle.openpgp.PGPSignaturegetLatestValidSelfSignatureOnKey()org.bouncycastle.openpgp.PGPSignaturegetLatestValidSelfSignatureOnKey(long subkeyId)org.bouncycastle.openpgp.PGPSignaturegetLatestValidSelfSignatureOnKey(OpenPgpV4Fingerprint fingerprint)org.bouncycastle.openpgp.PGPSignaturegetLatestValidSignatureOnUserId(java.lang.String userId)java.lang.StringgetPrimaryUserId()org.bouncycastle.openpgp.PGPPublicKeygetPublicKey()Return the firstPGPPublicKeyof this key ring.org.bouncycastle.openpgp.PGPPublicKeygetPublicKey(long keyId)static org.bouncycastle.openpgp.PGPPublicKeygetPublicKey(org.bouncycastle.openpgp.PGPKeyRing keyRing, long keyId)org.bouncycastle.openpgp.PGPPublicKeygetPublicKey(OpenPgpV4Fingerprint fingerprint)java.util.List<org.bouncycastle.openpgp.PGPPublicKey>getPublicKeys()Return allPGPPublicKeysof this key ring.java.util.DategetRevocationDate()Return the date on which the primary key was revoked, or null if it has not yet been revoked.org.bouncycastle.openpgp.PGPSecretKeygetSecretKey()Return the primaryPGPSecretKeyof this key ring or null if the key ring is not aPGPSecretKeyRing.org.bouncycastle.openpgp.PGPSecretKeygetSecretKey(long keyId)org.bouncycastle.openpgp.PGPSecretKeygetSecretKey(OpenPgpV4Fingerprint fingerprint)java.util.List<org.bouncycastle.openpgp.PGPSecretKey>getSecretKeys()Return all secret keys of the key ring.java.util.List<org.bouncycastle.openpgp.PGPSignature>getSelfSignaturesOnKey(long subkeyId)java.util.List<java.lang.String>getUserIds()Return a list of all user-ids of the primary key.java.util.List<java.lang.String>getValidUserIds()booleanisFullyDecrypted()Return true when every secret key on the key ring is not encrypted.booleanisSecretKey()Return true if the key ring is aPGPSecretKeyRing.booleanisUserIdValid(long keyId, java.lang.String userId)booleanisUserIdValid(java.lang.String userId)
-
-
-
Method Detail
-
getPublicKey
public org.bouncycastle.openpgp.PGPPublicKey getPublicKey()
Return the firstPGPPublicKeyof 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 allPGPPublicKeysof 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 primaryPGPSecretKeyof this key ring or null if the key ring is not aPGPSecretKeyRing.- 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 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 theOpenPgpV4Fingerprintof this key ring.- Returns:
- fingerprint
-
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
-
getExpirationDate
public java.util.Date getExpirationDate(OpenPgpV4Fingerprint fingerprint)
-
isSecretKey
public boolean isSecretKey()
Return true if the key ring is aPGPSecretKeyRing. If it is aPGPPublicKeyRingreturn 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.
-
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
-
-