Get to Encrypt dictionary from Custom Security Handler

Hi

is it somehow possible to get to the Encrypt dictionary from a custom security handler using the C++ SDK?

I can do this even before a security handler is called:

pdftron::SDF::Obj enc = mp_doc->GetTrailer().FindObj("Encrypt");

I need this info in "bool GetAuthorizationData (Permission p)"; which is part of my custom security handler.

I see InitSecurityHandler takes a custom_data pointer: https://www.pdftron.com/pdfnet/docs/PDFNetC/d6/d3f/classpdftron_1_1_p_d_f_1_1_p_d_f_doc.html#adc0d28e22efa7856249874012a81d4fe

However, I cannot find any info on how to implement SecurityHandler::Initialize().
Op vrijdag 2 december 2016 23:14:33 UTC+1 schreef Merijn Vandenabeele:

Hi

is it somehow possible to get to the Encrypt dictionary from a custom security handler using the C++ SDK?

I can do this even before a security handler is called:

pdftron::SDF::Obj enc = mp_doc->GetTrailer().FindObj(“Encrypt”);

I need this info in “bool GetAuthorizationData (Permission p)”; which is part of my custom security handler.

Did you look at the sample code in EncTest?
https://www.pdftron.com/pdfnet/samplecode/EncTest.cpp.html

In particular the MySecurityHandler class?

If you just call StdSecurityHandler::Initialize then that would cover the basics, and you would initialize whatever you need to do.

Hi Ryan

thanks for your answer, and sorry for the late reply.

I have looked at the sample with MySecurityHandler. I think the library has a bug and I’m experiencing the same issue in our application. Creating the PDFDoc object immediately calls GetAuthorizationData from MySecyrityHandler. From the docs - and it used to be like this in the past - GetAuthorizationData is called when the application calls InitSecurityHandler. Later, when InitSecurityHandler is called, the password is asked for again, so you have to enter it twice.

Anyway, this example is not an answer to my question. I wanted to know how I could get to the custom_data pointer that is passed along with InitSecurityHandler in the C++ SDK. This would allow me to pass along some extra data needed to get the correct password.

Kind regards,
Merijn
Op woensdag 7 december 2016 19:21:48 UTC+1 schreef Ryan:

Did you look at the sample code in EncTest?
https://www.pdftron.com/pdfnet/samplecode/EncTest.cpp.html

In particular the MySecurityHandler class?

If you just call StdSecurityHandler::Initialize then that would cover the basics, and you would initialize whatever you need to do.

Thank you for bringing these issues to our attention.

They have been fixed and will be available in the next releases.