Package org.pgpainless.decryption_verification

# Class OpenPgpMetadata

java.lang.Object
org.pgpainless.decryption_verification.OpenPgpMetadata

public class OpenPgpMetadata extends Object
Legacy class containing metadata about an OpenPGP message. It is advised to use `MessageMetadata` instead. TODO: Remove in 1.6.X

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`OpenPgpMetadata.Builder`

## Constructor Summary

Constructors
Constructor
Description
`OpenPgpMetadata(Set<Long> recipientKeyIds, SubkeyIdentifier decryptionKey, SessionKey sessionKey, CompressionAlgorithm algorithm, List<SignatureVerification> verifiedInbandSignatures, List<SignatureVerification.Failure> invalidInbandSignatures, List<SignatureVerification> verifiedDetachedSignatures, List<SignatureVerification.Failure> invalidDetachedSignatures, String fileName, Date modificationDate, StreamEncoding fileEncoding, boolean cleartextSigned)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`containsVerifiedSignatureFrom(org.bouncycastle.openpgp.PGPPublicKeyRing certificate)`
Return true, if the message contains at least one verified signature made by a key in the given certificate.
`boolean`
`containsVerifiedSignatureFrom(OpenPgpFingerprint fingerprint)`
Return true, if the message contains at least one valid signature made by the key with the given fingerprint, false otherwise.
`static OpenPgpMetadata.Builder`
`getBuilder()`
`CompressionAlgorithm`
`getCompressionAlgorithm()`
Return the `CompressionAlgorithm` that was used to compress the message.
`SubkeyIdentifier`
`getDecryptionKey()`
Return the `SubkeyIdentifier` of the key that was used to decrypt the message.
`StreamEncoding`
`getFileEncoding()`
Return the encoding format of the encrypted / signed file.
`String`
`getFileName()`
Return the name of the encrypted / signed file.
`List<SignatureVerification.Failure>`
`getInvalidDetachedSignatures()`
`List<SignatureVerification.Failure>`
`getInvalidInbandSignatures()`
`Date`
`getModificationDate()`
Return the modification date of the encrypted / signed file.
`Set<Long>`
`getRecipientKeyIds()`
Return a set of key-ids the messages was encrypted for.
`SessionKey`
`getSessionKey()`
`Set<org.bouncycastle.openpgp.PGPSignature>`
`getSignatures()`
Return a set of all signatures on the message.
`SymmetricKeyAlgorithm`
`getSymmetricKeyAlgorithm()`
Return the algorithm that was used to symmetrically encrypt the message.
`List<SignatureVerification>`
`getVerifiedDetachedSignatures()`
`List<SignatureVerification>`
`getVerifiedInbandSignatures()`
`Map<SubkeyIdentifier,org.bouncycastle.openpgp.PGPSignature>`
`getVerifiedSignatures()`
Return a map of all verified signatures on the message.
`boolean`
`isCleartextSigned()`
Return true if the message was signed using the cleartext signature framework.
`boolean`
`isEncrypted()`
Return true, if the message was encrypted.
`boolean`
`isForYourEyesOnly()`
Return true, if the encrypted data is intended for your eyes only.
`boolean`
`isSigned()`
Return true if the message contained at least one signature.
`boolean`
`isVerified()`
Return true, if the message is signed and at least one signature on the message was verified successfully.

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

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

## Constructor Details

### OpenPgpMetadata

public OpenPgpMetadata(Set<Long> recipientKeyIds, SubkeyIdentifier decryptionKey, SessionKey sessionKey, CompressionAlgorithm algorithm, List<SignatureVerification> verifiedInbandSignatures, List<SignatureVerification.Failure> invalidInbandSignatures, List<SignatureVerification> verifiedDetachedSignatures, List<SignatureVerification.Failure> invalidDetachedSignatures, String fileName, Date modificationDate, StreamEncoding fileEncoding, boolean cleartextSigned)

## Method Details

### getRecipientKeyIds

@Nonnull public Set<Long> getRecipientKeyIds()
Return a set of key-ids the messages was encrypted for.

Returns:
  recipient ids

### isEncrypted

public boolean isEncrypted()
Return true, if the message was encrypted.

Returns:
  true if encrypted, false otherwise

### getDecryptionKey

@Nullable public SubkeyIdentifier getDecryptionKey()
Return the `SubkeyIdentifier` of the key that was used to decrypt the message. This can be null if the message was decrypted using a `Passphrase`, or if it was not encrypted at all (e.g. signed only).

Returns:
  subkey identifier of decryption key

### getSymmetricKeyAlgorithm

@Nullable public SymmetricKeyAlgorithm getSymmetricKeyAlgorithm()
Return the algorithm that was used to symmetrically encrypt the message.

Returns:
  encryption algorithm

### getSessionKey

@Nullable public SessionKey getSessionKey()

### getCompressionAlgorithm

@Nullable public CompressionAlgorithm getCompressionAlgorithm()
Return the `CompressionAlgorithm` that was used to compress the message.

Returns:
  compression algorithm

### getSignatures

@Nonnull public Set<org.bouncycastle.openpgp.PGPSignature> getSignatures()
Return a set of all signatures on the message. Note: This method returns just the signatures. There is no guarantee that the signatures are verified or even correct. Use `getVerifiedSignatures()` instead to get all verified signatures.

Returns:
  unverified and verified signatures

### isSigned

public boolean isSigned()
Return true if the message contained at least one signature. Note: This method does not reflect, whether the signature on the message is correct. Use `isVerified()` instead to determine, if the message carries a verifiable signature.

Returns:
  true if message contains at least one unverified or verified signature, false otherwise.

### getVerifiedSignatures

public Map<SubkeyIdentifier,org.bouncycastle.openpgp.PGPSignature> getVerifiedSignatures()
Return a map of all verified signatures on the message. The map contains verified signatures as value, with the `SubkeyIdentifier` of the key that was used to verify the signature as the maps keys.

Returns:
  verified detached and one-pass signatures

### getVerifiedInbandSignatures

public List<SignatureVerification> getVerifiedInbandSignatures()

### getVerifiedDetachedSignatures

public List<SignatureVerification> getVerifiedDetachedSignatures()

### getInvalidInbandSignatures

public List<SignatureVerification.Failure> getInvalidInbandSignatures()

### getInvalidDetachedSignatures

public List<SignatureVerification.Failure> getInvalidDetachedSignatures()

### isVerified

public boolean isVerified()
Return true, if the message is signed and at least one signature on the message was verified successfully.

Returns:
  true if message is verified, false otherwise

### containsVerifiedSignatureFrom

public boolean containsVerifiedSignatureFrom(org.bouncycastle.openpgp.PGPPublicKeyRing certificate)
Return true, if the message contains at least one verified signature made by a key in the given certificate.

Parameters:
  `certificate` - certificate
Returns:
  true if message was signed by the certificate (and the signature is valid), false otherwise

### containsVerifiedSignatureFrom

public boolean containsVerifiedSignatureFrom(OpenPgpFingerprint fingerprint)
Return true, if the message contains at least one valid signature made by the key with the given fingerprint, false otherwise. The fingerprint might be of the signing subkey, or the primary key of the signing certificate.

Parameters:
  `fingerprint` - fingerprint of primary key or signing subkey
Returns:
  true if validly signed, false otherwise

### getFileName

public String getFileName()
Return the name of the encrypted / signed file.

Returns:
  file name

### isForYourEyesOnly

public boolean isForYourEyesOnly()
Return true, if the encrypted data is intended for your eyes only.

Returns:
  true if for-your-eyes-only

### getModificationDate

public Date getModificationDate()
Return the modification date of the encrypted / signed file.

Returns:
  modification date

### getFileEncoding

public StreamEncoding getFileEncoding()
Return the encoding format of the encrypted / signed file.

Returns:
  encoding

### isCleartextSigned

public boolean isCleartextSigned()
Return true if the message was signed using the cleartext signature framework.

Returns:
  true if cleartext signed.

### getBuilder

public static OpenPgpMetadata.Builder getBuilder()