Class MakeSignature
java.lang.Object
com.itextpdf.text.pdf.security.MakeSignature
Class that signs your PDF.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<byte[]> processCrl(Certificate cert, Collection<CrlClient> crlList) Processes a CRL list.static voidsignDeferred(PdfReader reader, String fieldName, OutputStream outs, ExternalSignatureContainer externalSignatureContainer) Signs a PDF where space was already reserved.static voidsignDetached(PdfSignatureAppearance sap, ExternalDigest externalDigest, ExternalSignature externalSignature, Certificate[] chain, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize, MakeSignature.CryptoStandard sigtype) Signs the document using the detached mode, CMS or CAdES equivalent.static voidsignDetached(PdfSignatureAppearance sap, ExternalDigest externalDigest, ExternalSignature externalSignature, Certificate[] chain, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize, MakeSignature.CryptoStandard sigtype, SignaturePolicyInfo signaturePolicy) Signs the document using the detached mode, CMS or CAdES equivalent.static voidsignDetached(PdfSignatureAppearance sap, ExternalDigest externalDigest, ExternalSignature externalSignature, Certificate[] chain, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize, MakeSignature.CryptoStandard sigtype, org.bouncycastle.asn1.esf.SignaturePolicyIdentifier signaturePolicy) Signs the document using the detached mode, CMS or CAdES equivalent.static voidsignExternalContainer(PdfSignatureAppearance sap, ExternalSignatureContainer externalSignatureContainer, int estimatedSize) Sign the document using an external container, usually a PKCS7.
-
Field Details
-
LOGGER
The Logger instance.
-
-
Constructor Details
-
MakeSignature
public MakeSignature()
-
-
Method Details
-
signDetached
public static void signDetached(PdfSignatureAppearance sap, ExternalDigest externalDigest, ExternalSignature externalSignature, Certificate[] chain, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize, MakeSignature.CryptoStandard sigtype) throws IOException, DocumentException, GeneralSecurityException Signs the document using the detached mode, CMS or CAdES equivalent.- Parameters:
sap- the PdfSignatureAppearanceexternalDigest- an implementation that provides the digestexternalSignature- the interface providing the actual signingchain- the certificate chaincrlList- the CRL listocspClient- the OCSP clienttsaClient- the Timestamp clientestimatedSize- the reserved size for the signature. It will be estimated if 0sigtype- Either Signature.CMS or Signature.CADES- Throws:
DocumentExceptionIOExceptionGeneralSecurityExceptionNoSuchAlgorithmExceptionException
-
signDetached
public static void signDetached(PdfSignatureAppearance sap, ExternalDigest externalDigest, ExternalSignature externalSignature, Certificate[] chain, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize, MakeSignature.CryptoStandard sigtype, SignaturePolicyInfo signaturePolicy) throws IOException, DocumentException, GeneralSecurityException Signs the document using the detached mode, CMS or CAdES equivalent.- Parameters:
sap- the PdfSignatureAppearanceexternalDigest- an implementation that provides the digestexternalSignature- the interface providing the actual signingchain- the certificate chaincrlList- the CRL listocspClient- the OCSP clienttsaClient- the Timestamp clientestimatedSize- the reserved size for the signature. It will be estimated if 0sigtype- Either Signature.CMS or Signature.CADESsignaturePolicy- the signature policy (for EPES signatures)- Throws:
DocumentExceptionIOExceptionGeneralSecurityExceptionNoSuchAlgorithmExceptionException
-
signDetached
public static void signDetached(PdfSignatureAppearance sap, ExternalDigest externalDigest, ExternalSignature externalSignature, Certificate[] chain, Collection<CrlClient> crlList, OcspClient ocspClient, TSAClient tsaClient, int estimatedSize, MakeSignature.CryptoStandard sigtype, org.bouncycastle.asn1.esf.SignaturePolicyIdentifier signaturePolicy) throws IOException, DocumentException, GeneralSecurityException Signs the document using the detached mode, CMS or CAdES equivalent.- Parameters:
sap- the PdfSignatureAppearanceexternalDigest- an implementation that provides the digestexternalSignature- the interface providing the actual signingchain- the certificate chaincrlList- the CRL listocspClient- the OCSP clienttsaClient- the Timestamp clientestimatedSize- the reserved size for the signature. It will be estimated if 0sigtype- Either Signature.CMS or Signature.CADESsignaturePolicy- the signature policy (for EPES signatures)- Throws:
DocumentExceptionIOExceptionGeneralSecurityExceptionNoSuchAlgorithmExceptionException
-
processCrl
Processes a CRL list.- Parameters:
cert- a Certificate if one of the CrlList implementations needs to retrieve the CRL URL from it.crlList- a list of CrlClient implementations- Returns:
- a collection of CRL bytes that can be embedded in a PDF.
-
signExternalContainer
public static void signExternalContainer(PdfSignatureAppearance sap, ExternalSignatureContainer externalSignatureContainer, int estimatedSize) throws GeneralSecurityException, IOException, DocumentException Sign the document using an external container, usually a PKCS7. The signature is fully composed externally, iText will just put the container inside the document.- Parameters:
sap- the PdfSignatureAppearanceexternalSignatureContainer- the interface providing the actual signingestimatedSize- the reserved size for the signature- Throws:
GeneralSecurityExceptionIOExceptionDocumentException
-
signDeferred
public static void signDeferred(PdfReader reader, String fieldName, OutputStream outs, ExternalSignatureContainer externalSignatureContainer) throws DocumentException, IOException, GeneralSecurityException Signs a PDF where space was already reserved.- Parameters:
reader- the original PDFfieldName- the field to sign. It must be the last fieldouts- the output PDFexternalSignatureContainer- the signature container doing the actual signing. Only the method ExternalSignatureContainer.sign is used- Throws:
DocumentExceptionIOExceptionGeneralSecurityException
-