You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Tilman Hausherr <TH...@t-online.de> on 2020/07/02 06:06:36 UTC

Re: Signing example NullPointerException at util.Hex.getBytes

Hi,

This means writeExternalSignature() was called with a null argument.
That method is called if signatureInterface  is set, but  
signatureInterface.sign()  has returned is null.

So you need to find out why your sign() method has returned null.

Tilman

Am 02.07.2020 um 08:07 schrieb Okan Konur:
> Hello, hope you are well.
>
> We are trying to get PADES working with PDFBox.
> I am working on
> CreateSignature.java
>
> I checked out the trunk version of examples signature directory.
> Then changed the Loader class reference with the 2.0 branch version, after
> I realized the loader class is new. I am working with latest
> pdfbox-2.0.20.jar.
>
> My problem is at the document.saveIncremental(output) line.
> I get the following exception:
>
> Exception in thread "main" java.lang.NullPointerException
> at org.apache.pdfbox.util.Hex.getBytes(Hex.java:83)
> at
> org.apache.pdfbox.pdfwriter.COSWriter.writeExternalSignature(COSWriter.java:792)
> at
> org.apache.pdfbox.pdfwriter.COSWriter.doWriteSignature(COSWriter.java:745)
> at
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1150)
> at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:452)
> at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1386)
> at
> org.apache.pdfbox.pdmodel.PDDocument.saveIncremental(PDDocument.java:1392)
> at CreateSignature.signDetached(CreateSignature.java:157)
> at CreateSignature.signDetached(CreateSignature.java:96)
> at CreateSignature.main(CreateSignature.java:180)
>
>
> I can post the source code but it is mostly the same with the repo version.
> I just changed the keystore and pdf file path.
>
> Can you kindly point me in the right direction?
>
> Thanks
>
> Okan
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Signing example NullPointerException at util.Hex.getBytes

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

There is a lot of example code in the examples subproject of the source 
code download from the website download page, start with that one. Don't 
mix with code from the trunk.

External signing is an advanced step, needed only if your signing 
happens in a separate service.

Tilman

Am 02.07.2020 um 09:10 schrieb Okan Konur:
> Oh, I think I misunderstood then. Because I thought pdfbox has its own
> signature implementation and I was trying to use it without implementing my
> signature method for the moment.
> If we must always provide signature implementation ourselves with the sign
> method in signatureInterface, what does external signing mean in this
> context? Sorry, I have looked into the docs and the site and couldn't make
> sense of it.
>
> Thanks for your quick response by the way, Tilman.
>
> On Thu, Jul 2, 2020 at 9:06 AM Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Hi,
>>
>> This means writeExternalSignature() was called with a null argument.
>> That method is called if signatureInterface  is set, but
>> signatureInterface.sign()  has returned is null.
>>
>> So you need to find out why your sign() method has returned null.
>>
>> Tilman
>>
>> Am 02.07.2020 um 08:07 schrieb Okan Konur:
>>> Hello, hope you are well.
>>>
>>> We are trying to get PADES working with PDFBox.
>>> I am working on
>>> CreateSignature.java
>>>
>>> I checked out the trunk version of examples signature directory.
>>> Then changed the Loader class reference with the 2.0 branch version,
>> after
>>> I realized the loader class is new. I am working with latest
>>> pdfbox-2.0.20.jar.
>>>
>>> My problem is at the document.saveIncremental(output) line.
>>> I get the following exception:
>>>
>>> Exception in thread "main" java.lang.NullPointerException
>>> at org.apache.pdfbox.util.Hex.getBytes(Hex.java:83)
>>> at
>>>
>> org.apache.pdfbox.pdfwriter.COSWriter.writeExternalSignature(COSWriter.java:792)
>>> at
>>>
>> org.apache.pdfbox.pdfwriter.COSWriter.doWriteSignature(COSWriter.java:745)
>>> at
>>>
>> org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1150)
>>> at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:452)
>>> at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1386)
>>> at
>>>
>> org.apache.pdfbox.pdmodel.PDDocument.saveIncremental(PDDocument.java:1392)
>>> at CreateSignature.signDetached(CreateSignature.java:157)
>>> at CreateSignature.signDetached(CreateSignature.java:96)
>>> at CreateSignature.main(CreateSignature.java:180)
>>>
>>>
>>> I can post the source code but it is mostly the same with the repo
>> version.
>>> I just changed the keystore and pdf file path.
>>>
>>> Can you kindly point me in the right direction?
>>>
>>> Thanks
>>>
>>> Okan
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Signing example NullPointerException at util.Hex.getBytes

Posted by Okan Konur <ok...@gmail.com>.
Oh, I think I misunderstood then. Because I thought pdfbox has its own
signature implementation and I was trying to use it without implementing my
signature method for the moment.
If we must always provide signature implementation ourselves with the sign
method in signatureInterface, what does external signing mean in this
context? Sorry, I have looked into the docs and the site and couldn't make
sense of it.

Thanks for your quick response by the way, Tilman.

On Thu, Jul 2, 2020 at 9:06 AM Tilman Hausherr <TH...@t-online.de>
wrote:

> Hi,
>
> This means writeExternalSignature() was called with a null argument.
> That method is called if signatureInterface  is set, but
> signatureInterface.sign()  has returned is null.
>
> So you need to find out why your sign() method has returned null.
>
> Tilman
>
> Am 02.07.2020 um 08:07 schrieb Okan Konur:
> > Hello, hope you are well.
> >
> > We are trying to get PADES working with PDFBox.
> > I am working on
> > CreateSignature.java
> >
> > I checked out the trunk version of examples signature directory.
> > Then changed the Loader class reference with the 2.0 branch version,
> after
> > I realized the loader class is new. I am working with latest
> > pdfbox-2.0.20.jar.
> >
> > My problem is at the document.saveIncremental(output) line.
> > I get the following exception:
> >
> > Exception in thread "main" java.lang.NullPointerException
> > at org.apache.pdfbox.util.Hex.getBytes(Hex.java:83)
> > at
> >
> org.apache.pdfbox.pdfwriter.COSWriter.writeExternalSignature(COSWriter.java:792)
> > at
> >
> org.apache.pdfbox.pdfwriter.COSWriter.doWriteSignature(COSWriter.java:745)
> > at
> >
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1150)
> > at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:452)
> > at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1386)
> > at
> >
> org.apache.pdfbox.pdmodel.PDDocument.saveIncremental(PDDocument.java:1392)
> > at CreateSignature.signDetached(CreateSignature.java:157)
> > at CreateSignature.signDetached(CreateSignature.java:96)
> > at CreateSignature.main(CreateSignature.java:180)
> >
> >
> > I can post the source code but it is mostly the same with the repo
> version.
> > I just changed the keystore and pdf file path.
> >
> > Can you kindly point me in the right direction?
> >
> > Thanks
> >
> > Okan
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>