1

I am trying to unlock the password protected PDF using bcprov-jdk15on-1.56.jar and itextpdf-5.5.10.jar but I am getting following exception. I am using 'User Defined Java Class' task of transformation.

Exception: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer information of other classes in the same package

Here is the lines of code I wrote,

String pdfFilePath = get(Fields.In, "PDFFilePath").getString(r);

String dest = pdfFilePath +"_unlocked.pdf";

try {
    PdfReader reader = new PdfReader(pdfFilePath,owner_password.getBytes());
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));

    stamper.close();
    reader.close();
}
catch(Exception e) {
    logBasic("EXCEPTION WHILE UNLOCKING PDF = " + e.getMessage());
}

Any idea, what's wrong with this?

Thanks, Nilesh

Alexey Subach
  • 11,903
  • 7
  • 34
  • 60
NNaseet
  • 68
  • 1
  • 8

1 Answers1

2

It seems that you have multiple BouncyCastle jars in your classpath. Try using version 1.49 which is the version iText 5.5.10 is compiled against and if it does not help, you will have to figure out which jars happen to be in your classpath and get rid of the duplicates.

Alexey Subach
  • 11,903
  • 7
  • 34
  • 60
  • Running `mvn dependency:tree` might help there. – Amedee Van Gasse Jan 27 '17 at 09:25
  • @Alexey- Thanks. There was already a bcprov-jdk14-138.jar which comes default with Pentaho (along with all other libraries). Deleted it and not getting the above error. But now I am running into other issue. It's not able to open the PDF file with that password. Password is correct; I can open PDF with same password from Acrobat reader. I get error "PdfReader not opened with owner password" from Pentaho UDJC task. – NNaseet Jan 27 '17 at 14:37
  • @NNaseet, this might be more of a question to the developers of `Pentaho`, on whether they use `iText` correctly. However, the problem can be much simpler: pdf documents may have user and owner passwords, and only owner passwords allow full control over documents. The password you provide is most likely a user password which is enough to read the document, but not enough to do the manipulations that are tried to be done. – Alexey Subach Jan 27 '17 at 17:34
  • @AlexeySubach - yes, it is owner password only. Yeah, I am checking with Pentaho community. Thanks for your help ! – NNaseet Jan 27 '17 at 18:38
  • @AlexeySubach - Looks like that is user password, because same program worked for other PDF with owner password. – NNaseet Jan 27 '17 at 19:48