public class PdfSignatureInstancePdfbox extends PdfSignatureInstance
| Constructor and Description | 
|---|
PdfSignatureInstancePdfbox()  | 
| 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). 
 | 
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 pdfFile,
          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 | 
setPDVisibleSigProperties(org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigProperties properties)  | 
void | 
sign()
Sign the PDF document given as defined in initSign. 
 | 
certificateInfosToText, setCmsSecurityProvider, verifypublic 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
PdfSignatureInstanceSecurityProvider.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 PdfSignatureInstanceoriginalFilePath - 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
PdfSignatureInstanceSecurityProvider.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 PdfSignatureInstanceoriginalPdf - 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 void setPDVisibleSigProperties(org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigProperties properties)
public void sign()
          throws PdfSignatureException,
                 java.io.IOException
PdfSignatureInstancesign in class PdfSignatureInstancePdfSignatureException - if errors during signing occurjava.io.IOException - if the signed document can't be writtenpublic void certify()
             throws PdfSignatureException,
                    java.io.IOException
PdfSignatureInstancecertify in class PdfSignatureInstancePdfSignatureException - if errors during signing occurjava.io.IOException - if the signed document can't be writtenCertificationSignature.ModificationPermissionpublic void certify(CertificationSignature.ModificationPermission allowedModification) throws PdfSignatureException, java.io.IOException
PdfSignatureInstancecertify in class PdfSignatureInstanceallowedModification - 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.ModificationPermissionpublic void certify(CertificationSignature.ModificationPermission allowedModification, LegalContentAttestation attestation) throws PdfSignatureException, java.io.IOException
PdfSignatureInstancecertify in class PdfSignatureInstanceallowedModification - 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.ModificationPermissionpublic void initVerify(java.lang.String path,
                       byte[] pwd)
                throws java.io.IOException
PdfSignatureInstanceinitVerify in class PdfSignatureInstancepath - 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 pdfFile,
                       byte[] pwd)
                throws java.io.IOException
PdfSignatureInstanceNonClosingIteratingInputStream.initVerify in class PdfSignatureInstancepdfFile - 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 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 PdfSignatureInstancePdfSignatureException - 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
PdfSignatureInstancegetCertificationSignature in class PdfSignatureInstancePdfSignatureException - if more than one certification signature was foundjava.io.IOException - if the document can't be readpublic PadesLTVParameters getDocumentSecurityStore() throws PdfSignatureException, java.io.IOException
PdfSignatureInstancegetDocumentSecurityStore in class PdfSignatureInstancePdfSignatureException - 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,
                                 java.io.IOException,
                                 iaik.tsp.TspVerificationException
PdfSignatureInstanceaddArchivalTimestamp in class PdfSignatureInstancetsaUrl - 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 createdjava.io.IOException - if the validation data or the document timestamp can't be writteniaik.tsp.TspVerificationException - if errors occur when requesting and verifying the timestamppublic 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,
                                 java.io.IOException,
                                 iaik.tsp.TspVerificationException
PdfSignatureInstanceaddArchivalTimestamp in class PdfSignatureInstancetsaUrl - 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 createdjava.io.IOException - if the validation data or the document timestamp can't be writteniaik.tsp.TspVerificationException - if errors occur when requesting and verifying the timestamppublic void closeDocument()
PdfSignatureInstancecloseDocument in class PdfSignatureInstance