Class PdfPadesSigner
-
Constructor Summary
ConstructorsConstructorDescriptionPdfPadesSigner(PdfReader reader, OutputStream outputStream) Create an instance of PdfPadesSigner class. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd revocation information for all the signatures which could be found in the provided document.voidprolongSignatures(ITSAClient tsaClient) Add revocation information for all the signatures which could be found in the provided document.setCrlClient(ICrlClient crlClient) SetICrlClientto be used for LTV Verification.setEstimatedSize(int estimatedSize) Set estimated size of a signature to be applied.setExternalDigest(IExternalDigest externalDigest) SetIExternalDigestto be used for main signing operation.setIssuingCertificateRetriever(IIssuingCertificateRetriever issuingCertificateRetriever) SetIIssuingCertificateRetrieverto be used before main signing operation.setOcspClient(IOcspClient ocspClient) SetIOcspClientto be used for LTV Verification.setStampingProperties(StampingProperties stampingProperties) Set stamping properties to be used during main signing operation.setTemporaryDirectoryPath(String temporaryDirectoryPath) Set temporary directory to be used for temporary files creation.setTimestampSignatureName(String timestampSignatureName) Set the name to be used for timestamp signature creation.setTrustedCertificates(List<Certificate> certificateList) Set certificate list to be used by theIIssuingCertificateRetrieverto retrieve missing certificates.voidsignWithBaselineBProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature) Sign the document provided inPdfSignerinstance with PaDES Baseline-B Profile.voidsignWithBaselineBProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey) Sign the document provided inPdfSignerinstance with PaDES Baseline-B Profile.voidsignWithBaselineLTAProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature, ITSAClient tsaClient) Sign the document provided inPdfSignerinstance with PaDES Baseline-LTA Profile.voidsignWithBaselineLTAProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey, ITSAClient tsaClient) Sign the document provided inPdfSignerinstance with PaDES Baseline-LTA Profile.voidsignWithBaselineLTProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature, ITSAClient tsaClient) Sign the document provided inPdfSignerinstance with PaDES Baseline-LT Profile.voidsignWithBaselineLTProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey, ITSAClient tsaClient) Sign the document provided inPdfSignerinstance with PaDES Baseline-LT Profile.voidsignWithBaselineTProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature, ITSAClient tsaClient) Sign the document provided inPdfSignerinstance with PaDES Baseline-T Profile.voidsignWithBaselineTProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey, ITSAClient tsaClient) Sign the document provided inPdfSignerinstance with PaDES Baseline-T Profile.
-
Constructor Details
-
PdfPadesSigner
Create an instance of PdfPadesSigner class. One instance shall be used for one signing operation.- Parameters:
-
reader-PdfReaderinstance to read original PDF file -
outputStream-OutputStreamoutput stream to write the resulting PDF file into
-
-
Method Details
-
signWithBaselineBProfile
public void signWithBaselineBProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-B Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
externalSignature-IExternalSignatureinstance to be used for main signing operation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineBProfile
public void signWithBaselineBProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-B Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
privateKey-PrivateKeyinstance to be used for main signing operation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineTProfile
public void signWithBaselineTProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature, ITSAClient tsaClient) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-T Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
externalSignature-IExternalSignatureinstance to be used for main signing operation -
tsaClient-ITSAClientinstance to be used for timestamp creation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineTProfile
public void signWithBaselineTProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey, ITSAClient tsaClient) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-T Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
privateKey-PrivateKeyinstance to be used for main signing operation -
tsaClient-ITSAClientinstance to be used for timestamp creation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineLTProfile
public void signWithBaselineLTProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature, ITSAClient tsaClient) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-LT Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
externalSignature-IExternalSignatureinstance to be used for main signing operation -
tsaClient-ITSAClientinstance to be used for timestamp creation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineLTProfile
public void signWithBaselineLTProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey, ITSAClient tsaClient) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-LT Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
privateKey-PrivateKeyinstance to be used for main signing operation -
tsaClient-ITSAClientinstance to be used for timestamp creation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineLTAProfile
public void signWithBaselineLTAProfile(SignerProperties signerProperties, Certificate[] chain, IExternalSignature externalSignature, ITSAClient tsaClient) throws IOException, GeneralSecurityException Sign the document provided inPdfSignerinstance with PaDES Baseline-LTA Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
externalSignature-IExternalSignatureinstance to be used for main signing operation -
tsaClient-ITSAClientinstance to be used for timestamp creation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
signWithBaselineLTAProfile
public void signWithBaselineLTAProfile(SignerProperties signerProperties, Certificate[] chain, PrivateKey privateKey, ITSAClient tsaClient) throws GeneralSecurityException, IOException Sign the document provided inPdfSignerinstance with PaDES Baseline-LTA Profile.- Parameters:
-
signerProperties-SignerPropertiesproperties to be used for main signing operation -
chain- the chain of certificates to be used for signing operation -
privateKey-PrivateKeyinstance to be used for main signing operation -
tsaClient-ITSAClientinstance to be used for timestamp creation - Throws:
-
GeneralSecurityException- in case of signing related exceptions -
IOException- in case of files related exceptions
-
prolongSignatures
Add revocation information for all the signatures which could be found in the provided document. Also add timestamp signature on top of that.- Parameters:
-
tsaClient-ITSAClientTSA Client to be used for timestamp signature creation - Throws:
-
IOException- in case of files related exceptions -
GeneralSecurityException- in case of signing related exceptions
-
prolongSignatures
Add revocation information for all the signatures which could be found in the provided document.- Throws:
-
IOException- in case of files related exceptions -
GeneralSecurityException- in case of signing related exceptions
-
setTemporaryDirectoryPath
Set temporary directory to be used for temporary files creation.If none is set, temporary documents will be created in memory.
- Parameters:
-
temporaryDirectoryPath-Stringrepresenting relative or absolute path to the directory - Returns:
-
same instance of
PdfPadesSigner
-
setTimestampSignatureName
Set the name to be used for timestamp signature creation.This setter is only relevant if
signWithBaselineLTAProfile(com.itextpdf.signatures.SignerProperties, java.security.cert.Certificate[], com.itextpdf.signatures.IExternalSignature, com.itextpdf.signatures.ITSAClient)orprolongSignatures(com.itextpdf.signatures.ITSAClient)methods are used.If none is set, randomly generated signature name will be used.
- Parameters:
-
timestampSignatureName-Stringrepresenting the name of a timestamp signature to be applied - Returns:
-
same instance of
PdfPadesSigner
-
setStampingProperties
Set stamping properties to be used during main signing operation.If none is set, stamping properties with append mode enabled will be used
- Parameters:
-
stampingProperties-StampingPropertiesinstance to be used during main signing operation - Returns:
-
same instance of
PdfPadesSigner
-
setEstimatedSize
Set estimated size of a signature to be applied.This parameter represents estimated amount of bytes to be preserved for the signature.
If none is set, 0 will be used and the required space will be calculated during the signing.
- Parameters:
-
estimatedSize- amount of bytes to be used as estimated value - Returns:
-
same instance of
PdfPadesSigner
-
setOcspClient
SetIOcspClientto be used for LTV Verification.This setter is only relevant if Baseline-LT Profile level or higher is used.
If none is set, there will be an attempt to create default OCSP Client instance using the certificate chain.
- Parameters:
-
ocspClient-IOcspClientinstance to be used for LTV Verification - Returns:
-
same instance of
PdfPadesSigner
-
setCrlClient
SetICrlClientto be used for LTV Verification.This setter is only relevant if Baseline-LT Profile level or higher is used.
If none is set, there will be an attempt to create default CRL Client instance using the certificate chain.
- Parameters:
-
crlClient-ICrlClientinstance to be used for LTV Verification - Returns:
-
same instance of
PdfPadesSigner
-
setExternalDigest
SetIExternalDigestto be used for main signing operation.If none is set,
BouncyCastleDigestinstance will be used instead.- Parameters:
-
externalDigest-IExternalDigestto be used for main signing operation. - Returns:
-
same instance of
PdfPadesSigner
-
setIssuingCertificateRetriever
public PdfPadesSigner setIssuingCertificateRetriever(IIssuingCertificateRetriever issuingCertificateRetriever) SetIIssuingCertificateRetrieverto be used before main signing operation.If none is set,
IssuingCertificateRetrieverinstance will be used instead.- Parameters:
-
issuingCertificateRetriever-IIssuingCertificateRetrieverinstance to be used for getting missing certificates in chain or CRL response issuer certificates. - Returns:
-
same instance of
PdfPadesSigner.
-
setTrustedCertificates
Set certificate list to be used by theIIssuingCertificateRetrieverto retrieve missing certificates.- Parameters:
-
certificateList- certificate list for getting missing certificates in chain or CRL response issuer certificates. - Returns:
-
same instance of
PdfPadesSigner.
-