Package org.pgpainless
Class PGPainless
- java.lang.Object
-
- org.pgpainless.PGPainless
-
public final class PGPainless extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringasciiArmor(org.bouncycastle.openpgp.PGPKeyRing key)Wrap a key or certificate in ASCII armor.static KeyRingBuilderbuildKeyRing()Build a custom OpenPGP key ring.static CertifyCertificatecertify()Create different kinds of signatures on other keys.static DecryptionBuilderdecryptAndOrVerify()Create aDecryptionStream, which can be used to decrypt and/or verify data using OpenPGP.static EncryptionBuilderencryptAndOrSign()Create anEncryptionStream, which can be used to encrypt and/or sign data using OpenPGP.static org.bouncycastle.openpgp.PGPPublicKeyRingextractCertificate(org.bouncycastle.openpgp.PGPSecretKeyRing secretKey)Extract a public key certificate from a secret key.static KeyRingTemplatesgenerateKeyRing()Generate a fresh OpenPGP key ring from predefined templates.static PolicygetPolicy()Access, and make changes to PGPainless policy on acceptable/default algorithms etc.static KeyRingInfoinspectKeyRing(org.bouncycastle.openpgp.PGPKeyRing keyRing)Quickly access information about aPGPPublicKeyRing/PGPSecretKeyRing.static KeyRingInfoinspectKeyRing(org.bouncycastle.openpgp.PGPKeyRing keyRing, java.util.Date inspectionDate)Quickly access information about aPGPPublicKeyRing/PGPSecretKeyRing.static org.bouncycastle.openpgp.PGPPublicKeyRingmergeCertificate(org.bouncycastle.openpgp.PGPPublicKeyRing originalCopy, org.bouncycastle.openpgp.PGPPublicKeyRing updatedCopy)Merge two copies of the same certificate (e.g. an old copy, and one retrieved from a key server) together.static SecretKeyRingEditorInterfacemodifyKeyRing(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)Make changes to a key ring.static KeyRingReaderreadKeyRing()Read an existing OpenPGP key ring.
-
-
-
Method Detail
-
generateKeyRing
public static KeyRingTemplates generateKeyRing()
Generate a fresh OpenPGP key ring from predefined templates.- Returns:
- templates
-
buildKeyRing
public static KeyRingBuilder buildKeyRing()
Build a custom OpenPGP key ring.- Returns:
- builder
-
readKeyRing
public static KeyRingReader readKeyRing()
Read an existing OpenPGP key ring.- Returns:
- builder
-
extractCertificate
public static org.bouncycastle.openpgp.PGPPublicKeyRing extractCertificate(@Nonnull org.bouncycastle.openpgp.PGPSecretKeyRing secretKey)Extract a public key certificate from a secret key.- Parameters:
secretKey- secret key- Returns:
- public key certificate
-
mergeCertificate
public static org.bouncycastle.openpgp.PGPPublicKeyRing mergeCertificate(@Nonnull org.bouncycastle.openpgp.PGPPublicKeyRing originalCopy, @Nonnull org.bouncycastle.openpgp.PGPPublicKeyRing updatedCopy) throws org.bouncycastle.openpgp.PGPExceptionMerge two copies of the same certificate (e.g. an old copy, and one retrieved from a key server) together.- Parameters:
originalCopy- local, older copy of the certupdatedCopy- updated, newer copy of the cert- Returns:
- merged certificate
- Throws:
org.bouncycastle.openpgp.PGPException- in case of an error
-
asciiArmor
public static java.lang.String asciiArmor(@Nonnull org.bouncycastle.openpgp.PGPKeyRing key) throws java.io.IOExceptionWrap a key or certificate in ASCII armor.- Parameters:
key- key or certificate- Returns:
- ascii armored string
- Throws:
java.io.IOException- in case of an error in theArmoredOutputStream
-
encryptAndOrSign
public static EncryptionBuilder encryptAndOrSign()
Create anEncryptionStream, which can be used to encrypt and/or sign data using OpenPGP.- Returns:
- builder
-
decryptAndOrVerify
public static DecryptionBuilder decryptAndOrVerify()
Create aDecryptionStream, which can be used to decrypt and/or verify data using OpenPGP.- Returns:
- builder
-
modifyKeyRing
public static SecretKeyRingEditorInterface modifyKeyRing(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Make changes to a key ring. This method can be used to change key expiration dates and passphrases, or add/remove/revoke subkeys. After making the desired changes in the builder, the modified key ring can be extracted usingSecretKeyRingEditorInterface.done().- Parameters:
secretKeys- secret key ring- Returns:
- builder
-
inspectKeyRing
public static KeyRingInfo inspectKeyRing(org.bouncycastle.openpgp.PGPKeyRing keyRing)
Quickly access information about aPGPPublicKeyRing/PGPSecretKeyRing. This method can be used to determine expiration dates, key flags and other information about a key. To evaluate a key at a given date (e.g. to determine if the key was allowed to create a certain signature) useinspectKeyRing(PGPKeyRing, Date)instead.- Parameters:
keyRing- key ring- Returns:
- access object
-
inspectKeyRing
public static KeyRingInfo inspectKeyRing(org.bouncycastle.openpgp.PGPKeyRing keyRing, java.util.Date inspectionDate)
Quickly access information about aPGPPublicKeyRing/PGPSecretKeyRing. This method can be used to determine expiration dates, key flags and other information about a key at a specific time.- Parameters:
keyRing- key ringinspectionDate- date of inspection- Returns:
- access object
-
getPolicy
public static Policy getPolicy()
Access, and make changes to PGPainless policy on acceptable/default algorithms etc.- Returns:
- policy
-
certify
public static CertifyCertificate certify()
Create different kinds of signatures on other keys.- Returns:
- builder
-
-