loading an encrypted xml document?
Added by Anonymous about 15 years ago
Legacy ID: #7449839 Legacy Poster: y10k (y10k)
In one of my xquery, I use doc() function to load a plain xml document and reference it later on. The xquery is called using s9api. However, due to external requirements, I need to encrypt the XML so the content of it will not be exposed to the user directly. I did this with a very simple encryption schema that is handled by calling a Java method of mine in run-time. The decryption is done in memory (i.e. loading the file from disk, decrypt it as a Java String.) Now I have a XML file stored in a Java String; what is the best way to pass that xml content into my xquery file so it can reference it? Thanks a lot.
Replies (6)
Please register to reply
RE: loading an encrypted xml document?
-
Added by Anonymous about 15 years ago
Legacy ID: #7449880 Legacy Poster: y10k (y10k)
sry I think I put this in a wrong section of the forum.
RE: loading an encrypted xml document?
-
Added by Anonymous about 15 years ago
Legacy ID: #7450004 Legacy Poster: David Lee (daldei)
Simpliest is probably using XQueryEvaluator.setSource( Source ) You will need a "Source" object built from the string. One way is using "StreamSource" which can be constructed from an InputStream The InputStream can be created from a string indirectly using ByteArrayInputStream Make sure you dont get transcoding errors by converting from your decoded "String" to a byte array. If possible avoid using String if you can get your decryptor to output to a byte[] instead. Then construct the ByteArrayInputStream, the StreamSource and call setSource(). voila ! -David
RE: loading an encrypted xml document?
-
Added by Anonymous about 15 years ago
Legacy ID: #7460078 Legacy Poster: y10k (y10k)
Thanks a lot, David. I will give it a shot.
RE: loading an encrypted xml document?
-
Added by Anonymous about 15 years ago
Legacy ID: #7460087 Legacy Poster: y10k (y10k)
Another question: if I reference multiple XMLs, I can only specify one as source. What's the best alternative for that case?
RE: loading an encrypted xml document?
-
Added by Anonymous about 15 years ago
Legacy ID: #7460092 Legacy Poster: y10k (y10k)
I am thinking about passing the decrypted content in as an external variable. However, I am not sure what's the best way to convert a string of XML into a xdmitem or xdmvalue.
RE: loading an encrypted xml document?
-
Added by Anonymous about 15 years ago
Legacy ID: #7460107 Legacy Poster: David Lee (daldei)
To get a String as a XdmNode for a variable, follow the same path to get a Source object then use DocumentBuilder.build( Source )
Please register to reply