Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class PdfSignatureInfo
- Object
- 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.
Methods
public static List<PdfSignatureInfo> find(byte[] pdf) | Every adbe.pkcs7.detached (or ETSI.CAdES.detached) signature in pdf, in file order. |
public long[] getByteRange() | The four /ByteRange numbers: offset and length of the bytes signed before the signature, then after it. |
public boolean coversWholeDocument() | True when the signed ranges reach the end of the file, so nothing was added after signing. |
public boolean isDigestValid() | True when the signed bytes hash to the digest the signature commits to. |
public boolean isCertificateBound() | True when the signature’s signingCertificateV2 attribute names the embedded signer certificate, so the certificate cannot have been swapped for another with the same key. |
public byte[] getSignedAttributes() | The DER signed attributes, the exact bytes the signature is over. |
public byte[] getSignatureValue() | The raw signature value (DER for ECDSA). |
public byte[] getSignerCertificate() | The signer’s DER X.509 certificate. |
public byte[] getSignerPublicKey() | The certificate’s DER SubjectPublicKeyInfo, the key to verify with. |
public String getSignerName() | The common name of the signer’s certificate, or null. |
public String getSignatureAlgorithm() | SHA256withRSA or SHA256withECDSA. |
Inherited methods
Method details
find
public static List<PdfSignatureInfo> find(byte[] pdf)adbe.pkcs7.detached (or ETSI.CAdES.detached) signature in
pdf, in file order. A signature dictionary whose contents cannot
be read as a SHA-256 CMS signature is skipped.getByteRange
public long[] getByteRange()/ByteRange numbers: offset and length of the bytes signed
before the signature, then after it.coversWholeDocument
public boolean coversWholeDocument()isDigestValid
public boolean isDigestValid()isCertificateBound
public boolean isCertificateBound()signingCertificateV2 attribute names the
embedded signer certificate, so the certificate cannot have been
swapped for another with the same key.getSignedAttributes
public byte[] getSignedAttributes()getSignatureValue
public byte[] getSignatureValue()getSignerCertificate
public byte[] getSignerCertificate()getSignerPublicKey
public byte[] getSignerPublicKey()SubjectPublicKeyInfo, the key to verify with.getSignerName
public String getSignerName()getSignatureAlgorithm
public String getSignatureAlgorithm()SHA256withRSA or SHA256withECDSA.