Class MessageMetadata

java.lang.Object
org.pgpainless.decryption_verification.MessageMetadata

public class MessageMetadata extends Object
View for extracting metadata about a MessageMetadata.Message.
  • Field Details

  • Constructor Details

  • Method Details

    • toLegacyMetadata

      @Nonnull public OpenPgpMetadata toLegacyMetadata()
      Convert this MessageMetadata object into a legacy OpenPgpMetadata object. This method is intended to be used for a transition period between the 1.3 / 1.4+ branches. TODO: Remove in 1.6.X
      Returns:
      converted OpenPgpMetadata object
    • isUsingCleartextSignatureFramework

      public boolean isUsingCleartextSignatureFramework()
    • isEncrypted

      public boolean isEncrypted()
    • isEncryptedFor

      public boolean isEncryptedFor(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keys)
    • isAuthenticatablySignedBy

      public boolean isAuthenticatablySignedBy(String userId, boolean email, CertificateAuthority certificateAuthority)
      Return true, if the message was signed by a certificate for which we can authenticate a binding to the given userId.
      Parameters:
      userId - userId
      email - if true, treat the user-id as an email address and match all userIDs containing this address
      certificateAuthority - certificate authority
      Returns:
      true, if we can authenticate a binding for a signing key with sufficient evidence
    • isAuthenticatablySignedBy

      public boolean isAuthenticatablySignedBy(String userId, boolean email, CertificateAuthority certificateAuthority, int targetAmount)
      Return true, if the message was verifiably signed by a certificate for which we can authenticate a binding to the given userId.
      Parameters:
      userId - userId
      email - if true, treat the user-id as an email address and match all userIDs containing this address
      certificateAuthority - certificate authority
      targetAmount - target trust amount
      Returns:
      true, if we can authenticate a binding for a signing key with sufficient evidence
    • getRecipientKeyIds

      public List<Long> getRecipientKeyIds()
      Return a list containing all recipient keyIDs.
      Returns:
      list of recipients
    • getEncryptionLayers

      @Nonnull public Iterator<MessageMetadata.EncryptedData> getEncryptionLayers()
    • getEncryptionAlgorithm

      @Nullable public SymmetricKeyAlgorithm getEncryptionAlgorithm()
      Return the SymmetricKeyAlgorithm of the outermost encrypted data packet, or null if message is unencrypted.
      Returns:
      encryption algorithm
    • getEncryptionAlgorithms

      @Nonnull public Iterator<SymmetricKeyAlgorithm> getEncryptionAlgorithms()
      Return an Iterator of SymmetricKeyAlgorithms encountered in the message. The first item returned by the iterator is the algorithm of the outermost encrypted data packet, the next item that of the next nested encrypted data packet and so on. The iterator might also be empty, in case of an unencrypted message.
      Returns:
      iterator of symmetric encryption algorithms
    • getCompressionLayers

      @Nonnull public Iterator<MessageMetadata.CompressedData> getCompressionLayers()
    • getCompressionAlgorithm

      @Nullable public CompressionAlgorithm getCompressionAlgorithm()
      Return the CompressionAlgorithm of the outermost compressed data packet, or null, if the message does not contain any compressed data packets.
      Returns:
      compression algorithm
    • getCompressionAlgorithms

      @Nonnull public Iterator<CompressionAlgorithm> getCompressionAlgorithms()
      Return an Iterator of CompressionAlgorithms encountered in the message. The first item returned by the iterator is the algorithm of the outermost compressed data packet, the next item that of the next nested compressed data packet and so on. The iterator might also be empty, in case of a message without any compressed data packets.
      Returns:
      iterator of compression algorithms
    • getSessionKey

      @Nullable public SessionKey getSessionKey()
      Return the SessionKey of the outermost encrypted data packet. If the message was unencrypted, this method returns
      null
      .
      Returns:
      session key of the message
    • getSessionKeys

      @Nonnull public Iterator<SessionKey> getSessionKeys()
      Return an Iterator of SessionKeys for all encrypted data packets in the message. The first item returned by the iterator is the session key of the outermost encrypted data packet, the next item that of the next nested encrypted data packet and so on. The iterator might also be empty, in case of an unencrypted message.
      Returns:
      iterator of session keys
    • isVerifiedSignedBy

      public boolean isVerifiedSignedBy(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keys)
    • getVerifiedSignatures

      public List<SignatureVerification> getVerifiedSignatures()
    • isVerifiedDetachedSignedBy

      public boolean isVerifiedDetachedSignedBy(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keys)
    • getVerifiedDetachedSignatures

      @Nonnull public List<SignatureVerification> getVerifiedDetachedSignatures()
      Return a list of all verified detached signatures. This list contains all acceptable, correct detached signatures.
      Returns:
      verified detached signatures
    • getRejectedDetachedSignatures

      @Nonnull public List<SignatureVerification.Failure> getRejectedDetachedSignatures()
      Return a list of all rejected detached signatures.
      Returns:
      rejected detached signatures
    • isVerifiedInlineSignedBy

      public boolean isVerifiedInlineSignedBy(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keys)
    • getVerifiedInlineSignatures

      @Nonnull public List<SignatureVerification> getVerifiedInlineSignatures()
      Return a list of all verified inline-signatures. This list contains all acceptable, correct signatures that were part of the message itself.
      Returns:
      verified inline signatures
    • getVerifiedInlineSignaturesByLayer

      @Nonnull public Iterator<List<SignatureVerification>> getVerifiedInlineSignaturesByLayer()
      Return an Iterator of Lists of verified inline-signatures of the message. Since signatures might occur in different layers within a message, this method can be used to gain more detailed insights into what signatures were encountered at what layers of the message structure. Each item of the Iterator represents a layer of the message and contains only signatures from this layer. An empty list means no (or no acceptable) signatures were encountered in that layer.
      Returns:
      iterator of lists of signatures by-layer.
    • getRejectedInlineSignatures

      @Nonnull public List<SignatureVerification.Failure> getRejectedInlineSignatures()
      Return a list of all rejected inline-signatures of the message.
      Returns:
      list of rejected inline-signatures
    • getRejectedInlineSignaturesByLayer

      @Nonnull public Iterator<List<SignatureVerification.Failure>> getRejectedInlineSignaturesByLayer()
      Similar to getVerifiedInlineSignaturesByLayer(), this method returns all rejected inline-signatures of the message, but organized by layer.
      Returns:
      rejected inline-signatures by-layer
    • getFilename

      @Nullable public String getFilename()
      Return the value of the literal data packet's filename field. This value can be used to store a decrypted file under its original filename, but since this field is not necessarily part of the signed data of a message, usage of this field is discouraged.
      Returns:
      filename
      See Also:
    • isForYourEyesOnly

      public boolean isForYourEyesOnly()
      Returns true, if the filename of the literal data packet indicates that the data is intended for your eyes only.
      Returns:
      isForYourEyesOnly
    • getModificationDate

      @Nullable public Date getModificationDate()
      Return the value of the literal data packets modification date field. This value can be used to restore the modification date of a decrypted file, but since this field is not necessarily part of the signed data, its use is discouraged.
      Returns:
      modification date
      See Also:
    • getLiteralDataEncoding

      @Nullable public StreamEncoding getLiteralDataEncoding()
      Return the value of the format field of the literal data packet. This value indicates what format (text, binary data, ...) the data has. Since this field is not necessarily part of the signed data of a message, its usage is discouraged.
      Returns:
      format
      See Also:
    • getDecryptionKey

      public SubkeyIdentifier getDecryptionKey()
      Return the SubkeyIdentifier of the decryption key that was used to decrypt the outermost encryption layer. If the message was unencrypted, this might return
      null
      .
      Returns:
      decryption key
    • isVerifiedSigned

      public boolean isVerifiedSigned()