Package org.pgpainless.key.parsing

# Class KeyRingReader

java.lang.Object
org.pgpainless.key.parsing.KeyRingReader

public class KeyRingReader extends Object

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`MAX_ITERATIONS`
`static final Charset`
`UTF8`

## Constructor Summary

Constructors
Constructor
Description
`KeyRingReader()`

## Method Summary

Modifier and Type
Method
Description
`org.bouncycastle.openpgp.PGPKeyRing`
`keyRing(byte[] bytes)`
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given byte array.
`org.bouncycastle.openpgp.PGPKeyRing`
`keyRing(InputStream inputStream)`
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given `InputStream`.
`org.bouncycastle.openpgp.PGPKeyRing`
`keyRing(String asciiArmored)`
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given ASCII armored string.
`PGPKeyRingCollection`
`keyRingCollection(byte[] bytes, boolean isSilent)`
`PGPKeyRingCollection`
`keyRingCollection(InputStream inputStream, boolean isSilent)`
`PGPKeyRingCollection`
`keyRingCollection(String asciiArmored, boolean isSilent)`
`org.bouncycastle.openpgp.PGPPublicKeyRing`
`publicKeyRing(byte[] bytes)`
`org.bouncycastle.openpgp.PGPPublicKeyRing`
`publicKeyRing(InputStream inputStream)`
`org.bouncycastle.openpgp.PGPPublicKeyRing`
`publicKeyRing(String asciiArmored)`
`org.bouncycastle.openpgp.PGPPublicKeyRingCollection`
`publicKeyRingCollection(byte[] bytes)`
`org.bouncycastle.openpgp.PGPPublicKeyRingCollection`
`publicKeyRingCollection(InputStream inputStream)`
`org.bouncycastle.openpgp.PGPPublicKeyRingCollection`
`publicKeyRingCollection(String asciiArmored)`
`static org.bouncycastle.openpgp.PGPKeyRing`
`readKeyRing(InputStream inputStream)`
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given `InputStream`.
`static org.bouncycastle.openpgp.PGPKeyRing`
`readKeyRing(InputStream inputStream, int maxIterations)`
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given `InputStream`.
`static PGPKeyRingCollection`
`readKeyRingCollection(InputStream inputStream, boolean isSilent)`
`static org.bouncycastle.openpgp.PGPPublicKeyRing`
`readPublicKeyRing(InputStream inputStream)`
`static org.bouncycastle.openpgp.PGPPublicKeyRing`
`readPublicKeyRing(InputStream inputStream, int maxIterations)`
Read a public key ring from the provided `InputStream`.
`static org.bouncycastle.openpgp.PGPPublicKeyRingCollection`
`readPublicKeyRingCollection(InputStream inputStream)`
`static org.bouncycastle.openpgp.PGPPublicKeyRingCollection`
`readPublicKeyRingCollection(InputStream inputStream, int maxIterations)`
Read a public key ring collection from the provided `InputStream`.
`static org.bouncycastle.openpgp.PGPSecretKeyRing`
`readSecretKeyRing(InputStream inputStream)`
`static org.bouncycastle.openpgp.PGPSecretKeyRing`
`readSecretKeyRing(InputStream inputStream, int maxIterations)`
Read a secret key ring from the provided `InputStream`.
`static org.bouncycastle.openpgp.PGPSecretKeyRingCollection`
`readSecretKeyRingCollection(InputStream inputStream)`
`static org.bouncycastle.openpgp.PGPSecretKeyRingCollection`
`readSecretKeyRingCollection(InputStream inputStream, int maxIterations)`
Read a secret key ring collection from the provided `InputStream`.
`org.bouncycastle.openpgp.PGPSecretKeyRing`
`secretKeyRing(byte[] bytes)`
`org.bouncycastle.openpgp.PGPSecretKeyRing`
`secretKeyRing(InputStream inputStream)`
`org.bouncycastle.openpgp.PGPSecretKeyRing`
`secretKeyRing(String asciiArmored)`
`org.bouncycastle.openpgp.PGPSecretKeyRingCollection`
`secretKeyRingCollection(byte[] bytes)`
`org.bouncycastle.openpgp.PGPSecretKeyRingCollection`
`secretKeyRingCollection(InputStream inputStream)`
`org.bouncycastle.openpgp.PGPSecretKeyRingCollection`
`secretKeyRingCollection(String asciiArmored)`

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

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

## Field Details

### MAX_ITERATIONS

public static final int MAX_ITERATIONS

See Also:
  - Constant Field Values

### UTF8

public static final Charset UTF8

## Constructor Details

### KeyRingReader

public KeyRingReader()

## Method Details

### keyRing

@Nullable public org.bouncycastle.openpgp.PGPKeyRing keyRing(@Nonnull InputStream inputStream) throws IOException
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given `InputStream`.

Parameters:
  `inputStream` - inputStream containing the OpenPGP key or certificate
Returns:
  key ring
Throws:
  `IOException` - in case of an IO error

### keyRing

@Nullable public org.bouncycastle.openpgp.PGPKeyRing keyRing(@Nonnull byte[] bytes) throws IOException
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given byte array.

Parameters:
  `bytes` - byte array containing the OpenPGP key or certificate
Returns:
  key ring
Throws:
  `IOException` - in case of an IO error

### keyRing

@Nullable public org.bouncycastle.openpgp.PGPKeyRing keyRing(@Nonnull String asciiArmored) throws IOException
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given ASCII armored string.

Parameters:
  `asciiArmored` - ASCII armored OpenPGP key or certificate
Returns:
  key ring
Throws:
  `IOException` - in case of an IO error

### publicKeyRing

@Nullable public org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### publicKeyRing

@Nullable public org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing(@Nonnull byte[] bytes) throws IOException

Throws:
  `IOException`

### publicKeyRing

@Nullable public org.bouncycastle.openpgp.PGPPublicKeyRing publicKeyRing(@Nonnull String asciiArmored) throws IOException

Throws:
  `IOException`

### publicKeyRingCollection

@Nonnull public org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### publicKeyRingCollection

@Nonnull public org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull byte[] bytes) throws IOException

Throws:
  `IOException`

### publicKeyRingCollection

@Nonnull public org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeyRingCollection(@Nonnull String asciiArmored) throws IOException

Throws:
  `IOException`

### secretKeyRing

@Nullable public org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### secretKeyRing

@Nullable public org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing(@Nonnull byte[] bytes) throws IOException

Throws:
  `IOException`

### secretKeyRing

@Nullable public org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing(@Nonnull String asciiArmored) throws IOException

Throws:
  `IOException`

### secretKeyRingCollection

@Nonnull public org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### secretKeyRingCollection

@Nonnull public org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull byte[] bytes) throws IOException

Throws:
  `IOException`

### secretKeyRingCollection

@Nonnull public org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeyRingCollection(@Nonnull String asciiArmored) throws IOException

Throws:
  `IOException`

### keyRingCollection

@Nonnull public PGPKeyRingCollection keyRingCollection(@Nonnull InputStream inputStream, boolean isSilent) throws IOException, org.bouncycastle.openpgp.PGPException

Throws:
  `IOException`
  `org.bouncycastle.openpgp.PGPException`

### keyRingCollection

@Nonnull public PGPKeyRingCollection keyRingCollection(@Nonnull byte[] bytes, boolean isSilent) throws IOException, org.bouncycastle.openpgp.PGPException

Throws:
  `IOException`
  `org.bouncycastle.openpgp.PGPException`

### keyRingCollection

@Nonnull public PGPKeyRingCollection keyRingCollection(@Nonnull String asciiArmored, boolean isSilent) throws IOException, org.bouncycastle.openpgp.PGPException

Throws:
  `IOException`
  `org.bouncycastle.openpgp.PGPException`

### readKeyRing

@Nullable public static org.bouncycastle.openpgp.PGPKeyRing readKeyRing(@Nonnull InputStream inputStream) throws IOException
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given `InputStream`. This method will attempt to read at most `MAX_ITERATIONS` objects from the stream before aborting. The first `PGPPublicKeyRing` or `PGPSecretKeyRing` will be returned.

Parameters:
  `inputStream` - inputStream containing the OpenPGP key or certificate
Returns:
  key ring
Throws:
  `IOException` - in case of an IO error

### readKeyRing

@Nullable public static org.bouncycastle.openpgp.PGPKeyRing readKeyRing(@Nonnull InputStream inputStream, int maxIterations) throws IOException
Read a `PGPKeyRing` (either `PGPSecretKeyRing` or `PGPPublicKeyRing`) from the given `InputStream`. This method will attempt to read at most

    maxIterations

objects from the stream before aborting. The first `PGPPublicKeyRing` or `PGPSecretKeyRing` will be returned.

Parameters:
  `inputStream` - inputStream containing the OpenPGP key or certificate
  `maxIterations` - maximum number of objects that are read before the method will abort
Returns:
  key ring
Throws:
  `IOException` - in case of an IO error

### readPublicKeyRing

@Nullable public static org.bouncycastle.openpgp.PGPPublicKeyRing readPublicKeyRing(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### readPublicKeyRing

@Nullable public static org.bouncycastle.openpgp.PGPPublicKeyRing readPublicKeyRing(@Nonnull InputStream inputStream, int maxIterations) throws IOException
Read a public key ring from the provided `InputStream`. If more than maxIterations PGP packets are encountered before a `PGPPublicKeyRing` is read, an `IOException` is thrown.

Parameters:
  `inputStream` - input stream
  `maxIterations` - max iterations before abort
Returns:
  public key ring
Throws:
  `IOException` - in case of an IO error or exceeding of max iterations

### readPublicKeyRingCollection

@Nonnull public static org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### readPublicKeyRingCollection

@Nonnull public static org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream, int maxIterations) throws IOException
Read a public key ring collection from the provided `InputStream`. If more than maxIterations PGP packets are encountered before the stream is exhausted, an `IOException` is thrown. If the stream contain secret key packets, their public key parts are extracted and returned.

Parameters:
  `inputStream` - input stream
  `maxIterations` - max iterations before abort
Returns:
  public key ring collection
Throws:
  `IOException` - in case of an IO error or exceeding of max iterations

### readSecretKeyRing

@Nullable public static org.bouncycastle.openpgp.PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### readSecretKeyRing

@Nullable public static org.bouncycastle.openpgp.PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream, int maxIterations) throws IOException
Read a secret key ring from the provided `InputStream`. If more than maxIterations PGP packets are encountered before a `PGPSecretKeyRing` is read, an `IOException` is thrown.

Parameters:
  `inputStream` - input stream
  `maxIterations` - max iterations before abort
Returns:
  public key ring
Throws:
  `IOException` - in case of an IO error or exceeding of max iterations

### readSecretKeyRingCollection

@Nonnull public static org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream) throws IOException

Throws:
  `IOException`

### readSecretKeyRingCollection

@Nonnull public static org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream, int maxIterations) throws IOException
Read a secret key ring collection from the provided `InputStream`. If more than maxIterations PGP packets are encountered before the stream is exhausted, an `IOException` is thrown.

Parameters:
  `inputStream` - input stream
  `maxIterations` - max iterations before abort
Returns:
  secret key ring collection
Throws:
  `IOException` - in case of an IO error or exceeding of max iterations

### readKeyRingCollection

@Nonnull public static PGPKeyRingCollection readKeyRingCollection(@Nonnull InputStream inputStream, boolean isSilent) throws IOException, org.bouncycastle.openpgp.PGPException

Throws:
  `IOException`
  `org.bouncycastle.openpgp.PGPException`