Class PdfSignatureInfo
java.lang.Object
com.codename1.pdf.PdfSignatureInfo
One digital signature found in a PDF, as [#find(byte[])] reads it.
This class checks everything that needs no public-key cryptography:
that the signed byte ranges hash to the digest the signature commits
to (isDigestValid()), that the certificate is the one the signature
names (isCertificateBound()) and that nothing was appended after
signing (coversWholeDocument()). The signature itself is verified by
PdfSigner.verify on a device, or by the JDK on a
server over getSignedAttributes() and getSignatureValue().
Trust is out of scope: a self-signed certificate verifies as well as a
CA-issued one. Compare getSignerCertificate() with the certificate
you expect, or validate its chain, before believing who signed.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTrue when the signed ranges reach the end of the file, so nothing was added after signing.static List<PdfSignatureInfo> find(byte[] pdf) Everyadbe.pkcs7.detached(orETSI.CAdES.detached) signature inpdf, in file order.long[]The four/ByteRangenumbers: offset and length of the bytes signed before the signature, then after it.SHA256withRSAorSHA256withECDSA.byte[]The raw signature value (DER for ECDSA).byte[]The DER signed attributes, the exact bytes the signature is over.byte[]The signer's DER X.509 certificate.The common name of the signer's certificate, or null.byte[]The certificate's DERSubjectPublicKeyInfo, the key to verify with.booleanTrue when the signature'ssigningCertificateV2attribute names the embedded signer certificate, so the certificate cannot have been swapped for another with the same key.booleanTrue when the signed bytes hash to the digest the signature commits to.
-
Method Details
-
find
Everyadbe.pkcs7.detached(orETSI.CAdES.detached) signature inpdf, in file order. A signature dictionary whose contents cannot be read as a SHA-256 CMS signature is skipped. -
getByteRange
public long[] getByteRange()The four/ByteRangenumbers: offset and length of the bytes signed before the signature, then after it. -
coversWholeDocument
public boolean coversWholeDocument()True when the signed ranges reach the end of the file, so nothing was added after signing. An incremental update after the signature (a later annotation, a second signature) makes this false while the signature itself stays valid for the bytes it covers. -
isDigestValid
public boolean isDigestValid()True when the signed bytes hash to the digest the signature commits to. False means the document was changed after it was signed. -
isCertificateBound
public boolean isCertificateBound()True when the signature'ssigningCertificateV2attribute names the embedded signer certificate, so the certificate cannot have been swapped for another with the same key. -
getSignedAttributes
public byte[] getSignedAttributes()The DER signed attributes, the exact bytes the signature is over. -
getSignatureValue
public byte[] getSignatureValue()The raw signature value (DER for ECDSA). -
getSignerCertificate
public byte[] getSignerCertificate()The signer's DER X.509 certificate. -
getSignerPublicKey
public byte[] getSignerPublicKey()The certificate's DERSubjectPublicKeyInfo, the key to verify with. -
getSignerName
The common name of the signer's certificate, or null. -
getSignatureAlgorithm
SHA256withRSAorSHA256withECDSA.
-