Package org.pgpainless.decryption_verification

# Class OpenPgpMessageInputStream

java.lang.Object
java.io.InputStream
org.pgpainless.decryption_verification.DecryptionStream
org.pgpainless.decryption_verification.OpenPgpMessageInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class OpenPgpMessageInputStream extends DecryptionStream

## Field Summary

Fields
Modifier and Type
Field
Description
`protected InputStream`
`nestedInputStream`
`protected final ConsumerOptions`
`options`
`protected TeeBCPGInputStream`
`packetInputStream`
`protected final PDA`
`syntaxVerifier`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`OpenPgpMessageInputStream(InputStream inputStream, ConsumerOptions options, MessageMetadata.Layer metadata, Policy policy)`
`protected`
`OpenPgpMessageInputStream(org.pgpainless.decryption_verification.OpenPgpMessageInputStream.Type type, InputStream inputStream, ConsumerOptions options, MessageMetadata.Layer metadata, Policy policy)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`static OpenPgpMessageInputStream`
`create(InputStream inputStream, ConsumerOptions options)`
Create an `OpenPgpMessageInputStream` suitable for decryption and verification of OpenPGP messages and signatures.
`protected static OpenPgpMessageInputStream`
`create(InputStream inputStream, ConsumerOptions options, MessageMetadata.Layer metadata, Policy policy)`
`static OpenPgpMessageInputStream`
`create(InputStream inputStream, ConsumerOptions options, Policy policy)`
Create an `OpenPgpMessageInputStream` suitable for decryption and verification of OpenPGP messages and signatures.
`MessageMetadata`
`getMetadata()`
Return `metadata` about the decrypted / verified message.
`int`
`read()`
`int`
`read(byte[] b, int off, int len)`

### Methods inherited from class org.pgpainless.decryption_verification.DecryptionStream

`getResult`

### Methods inherited from class java.io.InputStream

`available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo`

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

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

## Field Details

### options

protected final ConsumerOptions options

### syntaxVerifier

protected final PDA syntaxVerifier

### packetInputStream

protected TeeBCPGInputStream packetInputStream

### nestedInputStream

protected InputStream nestedInputStream

## Constructor Details

### OpenPgpMessageInputStream

protected OpenPgpMessageInputStream(@Nonnull InputStream inputStream, @Nonnull ConsumerOptions options, @Nonnull MessageMetadata.Layer metadata, @Nonnull Policy policy) throws org.bouncycastle.openpgp.PGPException, IOException

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

### OpenPgpMessageInputStream

protected OpenPgpMessageInputStream(@Nonnull org.pgpainless.decryption_verification.OpenPgpMessageInputStream.Type type, @Nonnull InputStream inputStream, @Nonnull ConsumerOptions options, @Nonnull MessageMetadata.Layer metadata, @Nonnull Policy policy) throws org.bouncycastle.openpgp.PGPException, IOException

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

## Method Details

### create

public static OpenPgpMessageInputStream create(@Nonnull InputStream inputStream, @Nonnull ConsumerOptions options) throws IOException, org.bouncycastle.openpgp.PGPException
Create an `OpenPgpMessageInputStream` suitable for decryption and verification of OpenPGP messages and signatures. This constructor will use the global PGPainless `Policy`.

Parameters:
  `inputStream` - underlying input stream
  `options` - options for consuming the stream
Returns:
  input stream that consumes OpenPGP messages
Throws:
  `IOException` - in case of an IO error
  `org.bouncycastle.openpgp.PGPException` - in case of an OpenPGP error

### create

public static OpenPgpMessageInputStream create(@Nonnull InputStream inputStream, @Nonnull ConsumerOptions options, @Nonnull Policy policy) throws org.bouncycastle.openpgp.PGPException, IOException
Create an `OpenPgpMessageInputStream` suitable for decryption and verification of OpenPGP messages and signatures. This factory method takes a custom `Policy` instead of using the global policy object.

Parameters:
  `inputStream` - underlying input stream containing the OpenPGP message
  `options` - options for consuming the message
  `policy` - policy for acceptable algorithms etc.
Returns:
  input stream that consumes OpenPGP messages
Throws:
  `org.bouncycastle.openpgp.PGPException` - in case of an OpenPGP error
  `IOException` - in case of an IO error

### create

protected static OpenPgpMessageInputStream create(@Nonnull InputStream inputStream, @Nonnull ConsumerOptions options, @Nonnull MessageMetadata.Layer metadata, @Nonnull Policy policy) throws IOException, org.bouncycastle.openpgp.PGPException

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

### read

public int read() throws IOException

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

### read

public int read(@Nonnull byte[] b, int off, int len) throws IOException

Overrides:
  `read` in class `InputStream`
Throws:
  `IOException`

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `InputStream`
Throws:
  `IOException`

### getMetadata

public MessageMetadata getMetadata()
Description copied from class: `DecryptionStream`
Return `metadata` about the decrypted / verified message. The `DecryptionStream` MUST be closed via `InputStream.close()` before the metadata object can be accessed.

Specified by:
  `getMetadata` in class `DecryptionStream`
Returns:
  message metadata