public class PdfSignatureInstanceItext extends PdfSignatureInstance
Constructor and Description |
---|
PdfSignatureInstanceItext() |
Modifier and Type | Method and Description |
---|---|
void |
addArchivalTimestamp(java.lang.String tsaUrl,
java.lang.String username,
java.lang.String password,
PadesLTVParameters params,
java.lang.String newTimestampedFilePath)
Add the validation data contained in params to this document's DSS (document security store) as
defined by PAdES-LTV (PAdES - long term validation).
|
void |
addArchivalTimestamp(java.lang.String tsaUrl,
java.lang.String username,
java.lang.String password,
PadesLTVParameters params,
java.lang.String newTimestampedFilePath,
java.lang.String digestAlgorithm)
Add the validation data contained in params to this document's DSS (document security store) as
defined by PAdES-LTV (PAdES - long term validation).
|
void |
certify()
Add a certification signature as defined in initSign.
|
void |
certify(CertificationSignature.ModificationPermission allowedModification)
Add a certification signature as defined in initSign.
|
void |
certify(CertificationSignature.ModificationPermission allowedModification,
LegalContentAttestation attestation)
Add a certification signature as defined in initSign.
|
void |
closeDocument()
Close document instances that may still be open.
|
CertificationSignature |
getCertificationSignature()
Extract the certification signature if included.
|
PadesLTVParameters |
getDocumentSecurityStore()
Get all validation data included in the document security store (dss).
|
SignatureAppearanceSetter |
getDocumentTimestampSignatureAppearanceSetter(java.lang.String newTimestampedFilePath)
Returns a signature appearance setter to change the appearance of the document timestamp.
|
SignatureAppearanceSetter |
getSignatureAppearanceSetter()
Returns a signature appearance setter to change the appearance of the signature in the PDF
document.
|
PdfSignatureDetails[] |
getSignatures()
Extract all PDF signatures (approval and certification signatures) contained in the document.
|
void |
initSign(java.io.InputStream originalPdf,
byte[] pwd,
java.io.OutputStream signedPdf,
java.security.PrivateKey privateKey,
java.security.cert.Certificate[] certChain,
PdfSignatureParameters params)
Set all details needed to create a PDF signature.
|
void |
initSign(java.lang.String originalFilePath,
byte[] pwd,
java.lang.String signedFilePath,
java.security.PrivateKey privateKey,
java.security.cert.Certificate[] certChain,
PdfSignatureParameters params)
Set all details needed to create a PDF signature.
|
void |
initVerify(java.io.InputStream pdfStream,
byte[] pwd)
Specify the signed PDF document to be further analyzed.
|
void |
initVerify(java.lang.String path,
byte[] pwd)
Specify the signed PDF document to be further analyzed.
|
void |
sign()
Sign the PDF document given as defined in initSign.
|
certificateInfosToText, setCmsSecurityProvider, verify
public void initSign(java.lang.String originalFilePath, byte[] pwd, java.lang.String signedFilePath, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certChain, PdfSignatureParameters params) throws java.io.IOException, PdfSignatureException
PdfSignatureInstance
SecurityProvider.setSecurityProvider(new IaikPkcs11SecurityProvider((IAIKPkcs11)pkcs11Provider));
If using EC-keys and the IAIK ECCelerate toolkit, also use the corresponding CMS security
provider: SecurityProvider.setSecurityProvider(new ECCelerateProvider());
initSign
in class PdfSignatureInstance
originalFilePath
- path to the PDF document, that shall be signedpwd
- password to open the document if encrypted (may be null)signedFilePath
- path where to save the signed PDF documentprivateKey
- private key to use for creating the signaturecertChain
- certificate chain corresponding to the given private keyparams
- parameters defining the required characteristics of the signaturejava.io.IOException
- if the original file can't be read or the signed file can't be writtenPdfSignatureException
- if specified parameters are invalid or certificates can't be parsedpublic void initSign(java.io.InputStream originalPdf, byte[] pwd, java.io.OutputStream signedPdf, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certChain, PdfSignatureParameters params) throws java.io.IOException, PdfSignatureException
PdfSignatureInstance
SecurityProvider.setSecurityProvider(new IaikPkcs11SecurityProvider((IAIKPkcs11)pkcs11Provider));
If using EC-keys and the IAIK ECCelerate toolkit, also use the corresponding CMS security
provider: SecurityProvider.setSecurityProvider(new ECCelerateProvider());
If using PdfBox the given originalPdf stream will be wrapped in a
NonClosingIteratingInputStream
.initSign
in class PdfSignatureInstance
originalPdf
- the stream to read the PDF document from, that shall be signedpwd
- password to open the document if encrypted (may be null)signedPdf
- stream to write the signed PDF document toprivateKey
- private key to use for creating the signaturecertChain
- certificate chain corresponding to the given private keyparams
- parameters defining the required characteristics of the signaturejava.io.IOException
- if the original file can't be read or the signed file can't be writtenPdfSignatureException
- if specified parameters are invalid or certificates can't be parsedpublic SignatureAppearanceSetter getSignatureAppearanceSetter()
public void initVerify(java.lang.String path, byte[] pwd) throws java.io.IOException
PdfSignatureInstance
initVerify
in class PdfSignatureInstance
path
- path to the signed PDF document that shall be analyzedpwd
- password to open the document if encrypted (may be null)java.io.IOException
- if the document can't be readpublic void initVerify(java.io.InputStream pdfStream, byte[] pwd) throws java.io.IOException
PdfSignatureInstance
NonClosingIteratingInputStream
.initVerify
in class PdfSignatureInstance
pdfStream
- the stream to read the PDF document that shall be analyzedpwd
- password to open the document if encrypted (may be null)java.io.IOException
- if the stream can't be readpublic void sign() throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
sign
in class PdfSignatureInstance
PdfSignatureException
- if errors during signing occurjava.io.IOException
- if the signed document can't be writtenpublic void certify() throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
certify
in class PdfSignatureInstance
PdfSignatureException
- if errors during signing occurjava.io.IOException
- if the signed document can't be writtenCertificationSignature.ModificationPermission
public void certify(CertificationSignature.ModificationPermission allowedModification) throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
certify
in class PdfSignatureInstance
allowedModification
- the modifications allowed in order not to invalidate the signaturePdfSignatureException
- if errors during signing occurjava.io.IOException
- if the signed document can't be writtenCertificationSignature.ModificationPermission
public void certify(CertificationSignature.ModificationPermission allowedModification, LegalContentAttestation attestation) throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
certify
in class PdfSignatureInstance
allowedModification
- the modifications allowed in order not to invalidate the signatureattestation
- legal content attestation certifying the document's contentPdfSignatureException
- if errors during signing occurjava.io.IOException
- if the signed document can't be writtenCertificationSignature.ModificationPermission
public PdfSignatureDetails[] getSignatures() throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
PdfSignatureDetails[] signatures = signatureInstance.getSignatures(); for (int i = 0; i < signatures.length; i++) { PdfSignatureDetails signature = signatures[i]; if (signature instanceof ApprovalSignature) { ((ApprovalSignature) signature).verifySignatureValue(); if (signature instanceof CertificationSignature) { ModificationPermission permissions = ((CertificationSignature) signature) .getModificationPermission(); } } else if (signature instanceof DocumentTimestamp) { PadesLTVParameters ltvParams = ((DocumentTimestamp) signature).getLTVParams(); } }
getSignatures
in class PdfSignatureInstance
PdfSignatureException
- if no signed document has been specified with initVerifyjava.io.IOException
- if the document can't be readpublic CertificationSignature getCertificationSignature() throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
getCertificationSignature
in class PdfSignatureInstance
PdfSignatureException
- if more than one certification signature was foundjava.io.IOException
- if the document can't be readpublic PadesLTVParameters getDocumentSecurityStore() throws PdfSignatureException, java.io.IOException
PdfSignatureInstance
getDocumentSecurityStore
in class PdfSignatureInstance
PdfSignatureException
- if some dss data can't be parsedjava.io.IOException
- if some dss data can't be readpublic void addArchivalTimestamp(java.lang.String tsaUrl, java.lang.String username, java.lang.String password, PadesLTVParameters params, java.lang.String newTimestampedFilePath) throws PdfSignatureException, iaik.tsp.TspVerificationException, java.io.IOException
PdfSignatureInstance
addArchivalTimestamp
in class PdfSignatureInstance
tsaUrl
- URL of the timestamp authorityusername
- username for authorizationpassword
- password for authorizationparams
- parameters including the validation data to be addednewTimestampedFilePath
- the file path where the new document containing the data and timestamp shall be savedPdfSignatureException
- if the validation data can't be encoded or the timestamp can't be creatediaik.tsp.TspVerificationException
- if errors occur when requesting and verifying the timestampjava.io.IOException
- if the validation data or the document timestamp can't be writtenpublic void addArchivalTimestamp(java.lang.String tsaUrl, java.lang.String username, java.lang.String password, PadesLTVParameters params, java.lang.String newTimestampedFilePath, java.lang.String digestAlgorithm) throws PdfSignatureException, iaik.tsp.TspVerificationException, java.io.IOException
PdfSignatureInstance
addArchivalTimestamp
in class PdfSignatureInstance
tsaUrl
- URL of the timestamp authorityusername
- username for authorizationpassword
- password for authorizationparams
- parameters including the validation data to be addednewTimestampedFilePath
- the file path where the new document containing the data and timestamp shall be saveddigestAlgorithm
- digest algorithm used to digest the timestamped data (timestamp imprint)PdfSignatureException
- if the validation data can't be encoded or the timestamp can't be creatediaik.tsp.TspVerificationException
- if errors occur when requesting and verifying the timestampjava.io.IOException
- if the validation data or the document timestamp can't be writtenpublic SignatureAppearanceSetter getDocumentTimestampSignatureAppearanceSetter(java.lang.String newTimestampedFilePath) throws PdfSignatureException, java.io.IOException
PdfSignatureException
java.io.IOException
public void closeDocument()
PdfSignatureInstance
closeDocument
in class PdfSignatureInstance