Class OpenPgpMetadata
- java.lang.Object
-
- org.pgpainless.decryption_verification.OpenPgpMetadata
-
public class OpenPgpMetadata extends Object
-
-
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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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 theCompressionAlgorithm
that was used to compress the message.SubkeyIdentifier
getDecryptionKey()
Return theSubkeyIdentifier
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
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.
-
-
-
Constructor Detail
-
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)
-
-
Method Detail
-
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 theSubkeyIdentifier
of the key that was used to decrypt the message. This can be null if the message was decrypted using aPassphrase
, 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 theCompressionAlgorithm
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. UsegetVerifiedSignatures()
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. UseisVerified()
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 theSubkeyIdentifier
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
-
getBuilder
public static OpenPgpMetadata.Builder getBuilder()
-
-