Package org.pgpainless

# Class PGPainless

java.lang.Object
org.pgpainless.PGPainless

public final class PGPainless extends Object

## Method Summary

Modifier and Type
Method
Description
`static String`
`asciiArmor(org.bouncycastle.openpgp.PGPKeyRing key)`
Wrap a key or certificate in ASCII armor.
`static void`
`asciiArmor(org.bouncycastle.openpgp.PGPKeyRing key, OutputStream outputStream)`
Wrap a key of certificate in ASCII armor and write the result into the given `OutputStream`.
`static String`
`asciiArmor(org.bouncycastle.openpgp.PGPSignature signature)`
Wrap the detached signature in ASCII armor.
`static KeyRingBuilder`
`buildKeyRing()`
Build a custom OpenPGP key ring.
`static CertifyCertificate`
`certify()`
Create different kinds of signatures on other keys.
`static DecryptionBuilder`
`decryptAndOrVerify()`
Create a `DecryptionStream`, which can be used to decrypt and/or verify data using OpenPGP.
`static EncryptionBuilder`
`encryptAndOrSign()`
Create an `EncryptionStream`, which can be used to encrypt and/or sign data using OpenPGP.
`static org.bouncycastle.openpgp.PGPPublicKeyRing`
`extractCertificate(org.bouncycastle.openpgp.PGPSecretKeyRing secretKey)`
Extract a public key certificate from a secret key.
`static KeyRingTemplates`
`generateKeyRing()`
Generate a fresh OpenPGP key ring from predefined templates.
`static Policy`
`getPolicy()`
Access, and make changes to PGPainless policy on acceptable/default algorithms etc.
`static KeyRingInfo`
`inspectKeyRing(org.bouncycastle.openpgp.PGPKeyRing keyRing)`
Quickly access information about a `PGPPublicKeyRing` / `PGPSecretKeyRing`.
`static KeyRingInfo`
`inspectKeyRing(org.bouncycastle.openpgp.PGPKeyRing keyRing, Date referenceTime)`
Quickly access information about a `PGPPublicKeyRing` / `PGPSecretKeyRing`.
`static org.bouncycastle.openpgp.PGPPublicKeyRing`
`mergeCertificate(org.bouncycastle.openpgp.PGPPublicKeyRing originalCopy, org.bouncycastle.openpgp.PGPPublicKeyRing updatedCopy)`
Merge two copies of the same certificate (e.g.
`static SecretKeyRingEditorInterface`
`modifyKeyRing(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)`
Make changes to a secret key.
`static SecretKeyRingEditorInterface`
`modifyKeyRing(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys, Date referenceTime)`
Make changes to a secret key at the given reference time.
`static KeyRingReader`
`readKeyRing()`
Read an existing OpenPGP key ring.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### generateKeyRing

@Nonnull public static KeyRingTemplates generateKeyRing()
Generate a fresh OpenPGP key ring from predefined templates.

Returns:
  templates

### buildKeyRing

@Nonnull public static KeyRingBuilder buildKeyRing()
Build a custom OpenPGP key ring.

Returns:
  builder

### readKeyRing

@Nonnull public static KeyRingReader readKeyRing()
Read an existing OpenPGP key ring.

Returns:
  builder

### extractCertificate

@Nonnull 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

@Nonnull public static org.bouncycastle.openpgp.PGPPublicKeyRing mergeCertificate(@Nonnull org.bouncycastle.openpgp.PGPPublicKeyRing originalCopy, @Nonnull org.bouncycastle.openpgp.PGPPublicKeyRing updatedCopy) throws org.bouncycastle.openpgp.PGPException
Merge 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 cert
  `updatedCopy` - updated, newer copy of the cert
Returns:
  merged certificate
Throws:
  `org.bouncycastle.openpgp.PGPException` - in case of an error

### asciiArmor

@Nonnull public static String asciiArmor(@Nonnull org.bouncycastle.openpgp.PGPKeyRing key) throws IOException
Wrap a key or certificate in ASCII armor.

Parameters:
  `key` - key or certificate
Returns:
  ascii armored string
Throws:
  `IOException` - in case of an error in the `ArmoredOutputStream`

### asciiArmor

@Nonnull public static String asciiArmor(@Nonnull org.bouncycastle.openpgp.PGPSignature signature) throws IOException
Wrap the detached signature in ASCII armor.

Parameters:
  `signature` - detached signature
Returns:
  ascii armored string
Throws:
  `IOException` - in case of an error in the `ArmoredOutputStream`

### asciiArmor

public static void asciiArmor(@Nonnull org.bouncycastle.openpgp.PGPKeyRing key, @Nonnull OutputStream outputStream) throws IOException
Wrap a key of certificate in ASCII armor and write the result into the given `OutputStream`.

Parameters:
  `key` - key or certificate
  `outputStream` - output stream
Throws:
  `IOException` - in case of an error ion the `ArmoredOutputStream`

### encryptAndOrSign

@Nonnull public static EncryptionBuilder encryptAndOrSign()
Create an `EncryptionStream`, which can be used to encrypt and/or sign data using OpenPGP.

Returns:
  builder

### decryptAndOrVerify

@Nonnull public static DecryptionBuilder decryptAndOrVerify()
Create a `DecryptionStream`, which can be used to decrypt and/or verify data using OpenPGP.

Returns:
  builder

### modifyKeyRing

@Nonnull public static SecretKeyRingEditorInterface modifyKeyRing(@Nonnull org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Make changes to a secret key. This method can be used to change key expiration dates and passphrases, or add/revoke subkeys.

After making the desired changes in the builder, the modified key ring can be extracted using `SecretKeyRingEditorInterface.done()`.

Parameters:
  `secretKeys` - secret key ring
Returns:
  builder

### modifyKeyRing

@Nonnull public static SecretKeyRingEditorInterface modifyKeyRing(@Nonnull org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys, @Nonnull Date referenceTime)
Make changes to a secret key at the given reference time. This method can be used to change key expiration dates and passphrases, or add/revoke user-ids and subkeys.

After making the desired changes in the builder, the modified key can be extracted using `SecretKeyRingEditorInterface.done()`.

Parameters:
  `secretKeys` - secret key ring
  `referenceTime` - reference time used as signature creation date
Returns:
  builder

### inspectKeyRing

@Nonnull public static KeyRingInfo inspectKeyRing(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keyRing)
Quickly access information about a `PGPPublicKeyRing` / `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) use `inspectKeyRing(PGPKeyRing, Date)` instead.

Parameters:
  `keyRing` - key ring
Returns:
  access object

### inspectKeyRing

@Nonnull public static KeyRingInfo inspectKeyRing(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keyRing, @Nonnull Date referenceTime)
Quickly access information about a `PGPPublicKeyRing` / `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 ring
  `referenceTime` - date of inspection
Returns:
  access object

### getPolicy

@Nonnull public static Policy getPolicy()
Access, and make changes to PGPainless policy on acceptable/default algorithms etc.

Returns:
  policy

### certify

@Nonnull public static CertifyCertificate certify()
Create different kinds of signatures on other keys.

Returns:
  builder