How to fetch XML embedded into Custom Security Handler?

I have been given the challenge to open PDF files with a custom security handler. I have no control over the PDF files or how the security is added to them. The goal is to use a remote server already in place, to retrieve the password for the file. Now here is the catch: the validity is checked using unique data embedded as XML in the custom security handler itself. And indeed, I can see that data when I open the encoded PDF file in a hex editor (it will not open in any other program I tried, including CosEdit).

After some searching I opted for PDFTron for this task and have added the library to my C++ project. I studied the samples and found EncTest, which appeared to be a good start. So I added the class MySecurityHandler to my project.

Then I added this code to main function itself:

`
PDFNet::Initialize();
PDFNet::RegisterSecurityHandler(“NewSecurityHandler”, “NewSecurityHandler”, MySecurityHandler::Create);
PDFDoc doc(“C:/encoded.pdf”);

// The rest is just testing to see if I can actually do something

doc.InitSecurityHandler(); // Success: the code I added to MySecurityHandler launches correctly
int c = doc.GetPageCount(); // Success: c = 39
std::string name = doc.GetTrailer().Get(“Encrypt”).Value().Get(“Filter”).Value().GetName(); // Success: name = “NewSecurityHandler”

`

That appears to be alright so far. Now my problem is that I have no idea how to reach the XML embedded in the custom security handler, so that I can extract the data that I need to make the API call. Is that even possible, and if so how should I go about that?

I don’t mind a challenge, but could really use some help at this point. Please let me know what other information might be needed to answer my question.

We improved the API so that you can now pass custom data to PDFNet, and get this back when needed.

Please download the latest build, and see the updated EncTest sample code, that shows how to pass in custom data.
https://www.pdftron.com/pdfnet/downloads.html