Massa Alfonso
2016-01-21 15:09:44 UTC
Hi,
I'm trying to remove a signature from the attached sample PDF with itextpdf 5.5.8 and save the result in another file using this java code:
Provider provider = new BouncyCastleProvider();
Security.addProvider(provider);
PdfReader reader = new PdfReader(inputStream, null);
AcroFields af = reader.getAcroFields();
ArrayList<String> names = af.getSignatureNames();
for (String name : names) {
System.out.println("Signature name: " + name);
System.out.println("Signature covers whole document: " + af.signatureCoversWholeDocument(name));
PdfPKCS7 pk = af.verifySignature(name, provider.getName());
System.out.println("SignatureDate: " + pk.getSignDate());
System.out.println("Certificate: " + pk.getSigningCertificate());
System.out.println("Document modified: " + !pk.verify());
af.removeField(name);
}
PdfStamper stamper = new PdfStamper(reader, outputStream, '\0');
stamper.close();
But I have this exception in removeField:
Exception in thread "main" java.lang.NullPointerException
at com.itextpdf.text.pdf.AcroFields.removeField(AcroFields.java:1814)
at com.itextpdf.text.pdf.AcroFields.removeField(AcroFields.java:1854)
at securityframe.cms.VerificaFirmaCerta.verify(VerificaFirmaCerta.java:47)
at securityframe.cms.VerificaFirmaCerta.main(VerificaFirmaCerta.java:67)
The attached file is signed with FirmaCerta (a italian sw).
Anyone can help me? There is a bug in the signature sw or in the itext library?
Thanks in advance.
Alfonso
AVVISO DI RISERVATEZZA Informazioni riservate possono essere contenute nel messaggio o nei suoi allegati. Se non siete i destinatari indicati nel messaggio, o responsabili per la sua consegna alla persona, o se avete ricevuto il messaggio per errore, siete pregati di non trascriverlo, copiarlo o inviarlo ad alcuno. In tal caso vi invitiamo a cancellare il messaggio ed i suoi allegati. Grazie.
CONFIDENTIALITY NOTICE Confidential information may be contained in this message or in its attachments. If you are not the addressee indicated in this message, or responsible for message delivering to that person, or if you have received this message in error, you may not transcribe, copy or deliver this message to anyone. In that case, you should delete this message and its attachments. Thank you.
I'm trying to remove a signature from the attached sample PDF with itextpdf 5.5.8 and save the result in another file using this java code:
Provider provider = new BouncyCastleProvider();
Security.addProvider(provider);
PdfReader reader = new PdfReader(inputStream, null);
AcroFields af = reader.getAcroFields();
ArrayList<String> names = af.getSignatureNames();
for (String name : names) {
System.out.println("Signature name: " + name);
System.out.println("Signature covers whole document: " + af.signatureCoversWholeDocument(name));
PdfPKCS7 pk = af.verifySignature(name, provider.getName());
System.out.println("SignatureDate: " + pk.getSignDate());
System.out.println("Certificate: " + pk.getSigningCertificate());
System.out.println("Document modified: " + !pk.verify());
af.removeField(name);
}
PdfStamper stamper = new PdfStamper(reader, outputStream, '\0');
stamper.close();
But I have this exception in removeField:
Exception in thread "main" java.lang.NullPointerException
at com.itextpdf.text.pdf.AcroFields.removeField(AcroFields.java:1814)
at com.itextpdf.text.pdf.AcroFields.removeField(AcroFields.java:1854)
at securityframe.cms.VerificaFirmaCerta.verify(VerificaFirmaCerta.java:47)
at securityframe.cms.VerificaFirmaCerta.main(VerificaFirmaCerta.java:67)
The attached file is signed with FirmaCerta (a italian sw).
Anyone can help me? There is a bug in the signature sw or in the itext library?
Thanks in advance.
Alfonso
AVVISO DI RISERVATEZZA Informazioni riservate possono essere contenute nel messaggio o nei suoi allegati. Se non siete i destinatari indicati nel messaggio, o responsabili per la sua consegna alla persona, o se avete ricevuto il messaggio per errore, siete pregati di non trascriverlo, copiarlo o inviarlo ad alcuno. In tal caso vi invitiamo a cancellare il messaggio ed i suoi allegati. Grazie.
CONFIDENTIALITY NOTICE Confidential information may be contained in this message or in its attachments. If you are not the addressee indicated in this message, or responsible for message delivering to that person, or if you have received this message in error, you may not transcribe, copy or deliver this message to anyone. In that case, you should delete this message and its attachments. Thank you.