Class MessageMetadata
- java.lang.Object
-
- org.pgpainless.decryption_verification.MessageMetadata
-
public class MessageMetadata extends java.lang.Object
View for extracting metadata about aMessageMetadata.Message
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MessageMetadata.CompressedData
static class
MessageMetadata.EncryptedData
static interface
MessageMetadata.Function<A,B>
static class
MessageMetadata.Layer
static class
MessageMetadata.LiteralData
static class
MessageMetadata.Message
static interface
MessageMetadata.Nested
static interface
MessageMetadata.Packet
-
Field Summary
Fields Modifier and Type Field Description protected MessageMetadata.Message
message
-
Constructor Summary
Constructors Constructor Description MessageMetadata(MessageMetadata.Message message)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompressionAlgorithm
getCompressionAlgorithm()
Return theCompressionAlgorithm
of the outermost compressed data packet, or null, if the message does not contain any compressed data packets.java.util.Iterator<CompressionAlgorithm>
getCompressionAlgorithms()
Return anIterator
ofCompressionAlgorithms
encountered in the message.java.util.Iterator<MessageMetadata.CompressedData>
getCompressionLayers()
SubkeyIdentifier
getDecryptionKey()
Return theSubkeyIdentifier
of the decryption key that was used to decrypt the outermost encryption layer.SymmetricKeyAlgorithm
getEncryptionAlgorithm()
Return theSymmetricKeyAlgorithm
of the outermost encrypted data packet, or null if message is unencrypted.java.util.Iterator<SymmetricKeyAlgorithm>
getEncryptionAlgorithms()
Return anIterator
ofSymmetricKeyAlgorithms
encountered in the message.java.util.Iterator<MessageMetadata.EncryptedData>
getEncryptionLayers()
java.lang.String
getFilename()
Return the value of the literal data packet's filename field.StreamEncoding
getLiteralDataEncoding()
Return the value of the format field of the literal data packet.java.util.Date
getModificationDate()
Return the value of the literal data packets modification date field.java.util.List<java.lang.Long>
getRecipientKeyIds()
Return a list containing all recipient keyIDs.java.util.List<SignatureVerification.Failure>
getRejectedDetachedSignatures()
Return a list of all rejected detached signatures.java.util.List<SignatureVerification.Failure>
getRejectedInlineSignatures()
Return a list of all rejected inline-signatures of the message.java.util.Iterator<java.util.List<SignatureVerification.Failure>>
getRejectedInlineSignaturesByLayer()
Similar togetVerifiedInlineSignaturesByLayer()
, this method returns all rejected inline-signatures of the message, but organized by layer.SessionKey
getSessionKey()
Return theSessionKey
of the outermost encrypted data packet.java.util.Iterator<SessionKey>
getSessionKeys()
Return anIterator
ofSessionKeys
for all encrypted data packets in the message.java.util.List<SignatureVerification>
getVerifiedDetachedSignatures()
Return a list of all verified detached signatures.java.util.List<SignatureVerification>
getVerifiedInlineSignatures()
Return a list of all verified inline-signatures.java.util.Iterator<java.util.List<SignatureVerification>>
getVerifiedInlineSignaturesByLayer()
Return anIterator
ofLists
of verified inline-signatures of the message.java.util.List<SignatureVerification>
getVerifiedSignatures()
boolean
isAuthenticatablySignedBy(java.lang.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.boolean
isAuthenticatablySignedBy(java.lang.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.boolean
isEncrypted()
boolean
isEncryptedFor(org.bouncycastle.openpgp.PGPKeyRing keys)
boolean
isForYourEyesOnly()
Returns true, if the filename of the literal data packet indicates that the data is intended for your eyes only.boolean
isUsingCleartextSignatureFramework()
boolean
isVerifiedDetachedSignedBy(org.bouncycastle.openpgp.PGPKeyRing keys)
boolean
isVerifiedInlineSignedBy(org.bouncycastle.openpgp.PGPKeyRing keys)
boolean
isVerifiedSigned()
boolean
isVerifiedSignedBy(org.bouncycastle.openpgp.PGPKeyRing keys)
OpenPgpMetadata
toLegacyMetadata()
Convert thisMessageMetadata
object into a legacyOpenPgpMetadata
object.
-
-
-
Field Detail
-
message
protected MessageMetadata.Message message
-
-
Constructor Detail
-
MessageMetadata
public MessageMetadata(@Nonnull MessageMetadata.Message message)
-
-
Method Detail
-
toLegacyMetadata
@Nonnull public OpenPgpMetadata toLegacyMetadata()
Convert thisMessageMetadata
object into a legacyOpenPgpMetadata
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(java.lang.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
- userIdemail
- if true, treat the user-id as an email address and match all userIDs containing this addresscertificateAuthority
- certificate authority- Returns:
- true, if we can authenticate a binding for a signing key with sufficient evidence
-
isAuthenticatablySignedBy
public boolean isAuthenticatablySignedBy(java.lang.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
- userIdemail
- if true, treat the user-id as an email address and match all userIDs containing this addresscertificateAuthority
- certificate authoritytargetAmount
- target trust amount- Returns:
- true, if we can authenticate a binding for a signing key with sufficient evidence
-
getRecipientKeyIds
public java.util.List<java.lang.Long> getRecipientKeyIds()
Return a list containing all recipient keyIDs.- Returns:
- list of recipients
-
getEncryptionLayers
@Nonnull public java.util.Iterator<MessageMetadata.EncryptedData> getEncryptionLayers()
-
getEncryptionAlgorithm
@Nullable public SymmetricKeyAlgorithm getEncryptionAlgorithm()
Return theSymmetricKeyAlgorithm
of the outermost encrypted data packet, or null if message is unencrypted.- Returns:
- encryption algorithm
-
getEncryptionAlgorithms
@Nonnull public java.util.Iterator<SymmetricKeyAlgorithm> getEncryptionAlgorithms()
Return anIterator
ofSymmetricKeyAlgorithms
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 java.util.Iterator<MessageMetadata.CompressedData> getCompressionLayers()
-
getCompressionAlgorithm
@Nullable public CompressionAlgorithm getCompressionAlgorithm()
Return theCompressionAlgorithm
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 anIterator
ofCompressionAlgorithms
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 theSessionKey
of the outermost encrypted data packet. If the message was unencrypted, this method returnsnull
.- Returns:
- session key of the message
-
getSessionKeys
@Nonnull public java.util.Iterator<SessionKey> getSessionKeys()
Return anIterator
ofSessionKeys
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 java.util.List<SignatureVerification> getVerifiedSignatures()
-
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 anIterator
ofLists
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 theIterator
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 togetVerifiedInlineSignaturesByLayer()
, 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 theSubkeyIdentifier
of the decryption key that was used to decrypt the outermost encryption layer. If the message was unencrypted, this might returnnull
.- Returns:
- decryption key
-
isVerifiedSigned
public boolean isVerifiedSigned()
-
-