/** * Gets the certificate information of a signature. * * @param signature the signature of the document. * @param fileName of the document. * @return the CertSignatureInformation containing all certificate information * @throws CertificateProccessingException when there is an error processing the certificates * @throws IOException on a data processing error */ public CertSignatureInformation getLastCertInfo(PDSignature signature, String fileName) throws CertificateProccessingException, IOException { try (FileInputStream documentInput = new FileInputStream(fileName)) { byte[] signatureContent = signature.getContents(documentInput); return getCertInfo(signatureContent); } }
/** * Will return the embedded signature between the byterange gap. * * @param pdfFile The signed pdf file as InputStream * @return a byte array containing the signature * @throws IOException if the pdfFile can't be read */ public byte[] getContents(InputStream pdfFile) throws IOException { int[] byteRange = getByteRange(); int begin = byteRange[0]+byteRange[1]+1; int len = byteRange[2]-begin; return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,len})); }
/** * Will return the embedded signature between the byterange gap. * * @param pdfFile The signed pdf file as byte array * @return a byte array containing the signature * @throws IOException if the pdfFile can't be read */ public byte[] getContents(byte[] pdfFile) throws IOException { int[] byteRange = getByteRange(); int begin = byteRange[0]+byteRange[1]+1; int len = byteRange[2]-begin; return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,len})); }
if (signature != null) byte[] sigBlock = signature.getContents(documentBytes); CMSSignedData signedData = new CMSSignedData(sigBlock);
@Override public String getHexContents() { if (this.signature != null) { byte[] cont = signature.getContents(); if (cont != null) { return DatatypeConverter.printHexBinary(cont); } } return null; }
@Override public InputStream getData() { if (this.signature != null) { byte[] contents = signature.getContents(); return contents == null ? null : new ByteArrayInputStream(contents); } return null; }
/** * Will return the embedded signature between the byterange gap. * * @param pdfFile The signed pdf file as InputStream * @return a byte array containing the signature * @throws IOException if the pdfFile can't be read */ public byte[] getContents(InputStream pdfFile) throws IOException { int[] byteRange = getByteRange(); int begin = byteRange[0]+byteRange[1]+1; int len = byteRange[2]-begin; return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,len})); }
/** * Will return the embedded signature between the byterange gap. * * @param pdfFile The signed pdf file as byte array * @return a byte array containing the signature * @throws IOException if the pdfFile can't be read */ public byte[] getContents(byte[] pdfFile) throws IOException { int[] byteRange = getByteRange(); int begin = byteRange[0]+byteRange[1]+1; int len = byteRange[2]-begin; return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,len})); }
/** * Will return the embedded signature between the byterange gap. * * @param pdfFile The signed pdf file as InputStream * @return a byte array containing the signature * @throws IOException if the pdfFile can't be read */ public byte[] getContents(InputStream pdfFile) throws IOException { int[] byteRange = getByteRange(); int begin = byteRange[0]+byteRange[1]+1; int len = byteRange[2]-begin; return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,len})); }
/** * Will return the embedded signature between the byterange gap. * * @param pdfFile The signed pdf file as byte array * @return a byte array containing the signature * @throws IOException if the pdfFile can't be read */ public byte[] getContents(byte[] pdfFile) throws IOException { int[] byteRange = getByteRange(); int begin = byteRange[0]+byteRange[1]+1; int len = byteRange[2]-begin; return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,len})); }
/** * @param pdSignature {@link org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature} * object. * @param document {@link PDDocument} containing representation of initial PDF file. */ public PBoxPDSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature pdSignature, PDDocument document, COSObject signatureReference) { super(pdSignature, SIGNATURE_TYPE); this.document = document; COSObjectKey key = new COSObjectKey(signatureReference); signatureOffset = (this.document.getDocument().getXrefTable().get(key)).longValue(); contents = ((org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature) this.simplePDObject).getContents(); }
/** * Gets the certificate information of a signature. * * @param signature the signature of the document. * @param fileName of the document. * @return the CertSignatureInformation containing all certificate information * @throws CertificateProccessingException when there is an error processing the certificates * @throws IOException on a data processing error */ public CertSignatureInformation getLastCertInfo(PDSignature signature, String fileName) throws CertificateProccessingException, IOException { FileInputStream documentInput = null; try { documentInput = new FileInputStream(fileName); byte[] signatureContent = signature.getContents(documentInput); return getCertInfo(signatureContent); } finally { IOUtils.closeQuietly(documentInput); } }
if (signature != null) byte[] sigBlock = signature.getContents(documentBytes); CMSSignedData signedData = new CMSSignedData(sigBlock);