"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "examples/src/main/java/org/apache/pdfbox/examples/signature/validation/AddValidationInformation.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

AddValidationInformation.java  (pdfbox-2.0.23-src):AddValidationInformation.java  (pdfbox-2.0.24-src)
skipping to change at line 61 skipping to change at line 61
import org.apache.pdfbox.io.IOUtils; import org.apache.pdfbox.io.IOUtils;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog; import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.encryption.SecurityProvider; import org.apache.pdfbox.pdmodel.encryption.SecurityProvider;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
import org.apache.pdfbox.util.Hex; import org.apache.pdfbox.util.Hex;
import org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers; import org.bouncycastle.asn1.ocsp.OCSPObjectIdentifiers;
import org.bouncycastle.cert.ocsp.BasicOCSPResp; import org.bouncycastle.cert.ocsp.BasicOCSPResp;
import org.bouncycastle.cert.ocsp.OCSPException; import org.bouncycastle.cert.ocsp.OCSPException;
import org.bouncycastle.cert.ocsp.OCSPResp; import org.bouncycastle.cert.ocsp.OCSPResp;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.CMSSignedData;
import org.bouncycastle.tsp.TSPException;
import org.bouncycastle.tsp.TimeStampToken;
import org.bouncycastle.tsp.TimeStampTokenInfo;
/** /**
* An example for adding Validation Information to a signed PDF, inspired by ETS I TS 102 778-4 * An example for adding Validation Information to a signed PDF, inspired by ETS I TS 102 778-4
* V1.1.2 (2009-12), Part 4: PAdES Long Term - PAdES-LTV Profile. This procedure appends the * V1.1.2 (2009-12), Part 4: PAdES Long Term - PAdES-LTV Profile. This procedure appends the
* Validation Information of the last signature (more precise its signer(s)) to a copy of the * Validation Information of the last signature (more precise its signer(s)) to a copy of the
* document. The signature and the signed data will not be touched and stay vali d. * document. The signature and the signed data will not be touched and stay vali d.
* <p> * <p>
* See also <a href="http://eprints.hsr.ch/id/eprint/616">Bachelor thesis (in Ge rman) about LTV</a> * See also <a href="http://eprints.hsr.ch/id/eprint/616">Bachelor thesis (in Ge rman) about LTV</a>
* *
* @author Alexis Suter * @author Alexis Suter
skipping to change at line 148 skipping to change at line 153
{ {
certInformationHelper = new CertInformationCollector(); certInformationHelper = new CertInformationCollector();
CertSignatureInformation certInfo = null; CertSignatureInformation certInfo = null;
try try
{ {
PDSignature signature = SigUtils.getLastRelevantSignature(document); PDSignature signature = SigUtils.getLastRelevantSignature(document);
if (signature != null) if (signature != null)
{ {
certInfo = certInformationHelper.getLastCertInfo(signature, file name); certInfo = certInformationHelper.getLastCertInfo(signature, file name);
signDate = signature.getSignDate(); signDate = signature.getSignDate();
if ("ETSI.RFC3161".equals(signature.getSubFilter()))
{
byte[] contents = signature.getContents();
TimeStampToken timeStampToken = new TimeStampToken(new CMSSi
gnedData(contents));
TimeStampTokenInfo timeStampInfo = timeStampToken.getTimeSta
mpInfo();
signDate = Calendar.getInstance();
signDate.setTime(timeStampInfo.getGenTime());
}
} }
} }
catch (CertificateProccessingException e) catch (CertificateProccessingException e)
{ {
throw new IOException("An Error occurred processing the Signature", e); throw new IOException("An Error occurred processing the Signature", e);
} }
catch (CMSException e)
{
throw new IOException("An Error occurred processing the Signature",
e);
}
catch (TSPException e)
{
throw new IOException("An Error occurred processing the Signature",
e);
}
if (certInfo == null) if (certInfo == null)
{ {
throw new IOException( throw new IOException(
"No Certificate information or signature found in the given document"); "No Certificate information or signature found in the given document");
} }
PDDocumentCatalog docCatalog = document.getDocumentCatalog(); PDDocumentCatalog docCatalog = document.getDocumentCatalog();
COSDictionary catalog = docCatalog.getCOSObject(); COSDictionary catalog = docCatalog.getCOSObject();
catalog.setNeedToBeUpdated(true); catalog.setNeedToBeUpdated(true);
 End of changes. 3 change blocks. 
0 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)