Class MessageMetadata


  • public class MessageMetadata
    extends java.lang.Object
    View for extracting metadata about a MessageMetadata.Message.
    • Method Detail

      • 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.5.X
        Returns:
        converted OpenPgpMetadata object
      • isUsingCleartextSignatureFramework

        public boolean isUsingCleartextSignatureFramework()
      • isEncrypted

        public boolean isEncrypted()
      • isEncryptedFor

        public boolean isEncryptedFor​(@Nonnull
                                      org.bouncycastle.openpgp.PGPKeyRing keys)
      • 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 java.util.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
      • 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 java.util.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 java.util.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)
      • isVerifiedDetachedSignedBy

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

        @Nonnull
        public java.util.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 java.util.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 java.util.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 java.util.Iterator<java.util.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 java.util.List<SignatureVerification.Failure> getRejectedInlineSignatures()
        Return a list of all rejected inline-signatures of the message.
        Returns:
        list of rejected inline-signatures
      • getRejectedInlineSignaturesByLayer

        @Nonnull
        public java.util.Iterator<java.util.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 java.lang.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:
        RFC4880 §5.9. Literal Data Packet
      • 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 java.util.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:
        RFC4880 §5.9. Literal Data Packet
      • 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:
        RFC4880 §5.9. Literal Data Packet
      • 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()