Xades4j and Base64 in EnvelopedXmlObject -


I tried putting the base 64 string in the object in EnvelopedXmlObject:

  DocumentBuilderFactory dbFactory = DocumentBuilderFactory newInstance (); DbFactory.setNamespaceAware (true); DocumentBuilder debugger = DBFTC NE DocumentBuilder (); Document document = dBuilder.newDocument (); String generated document = ...; BASE64Encoder encoder = new BASE64Encoder (); String generated document encoded = encoder.node (generated document .getBytes ("UTF-8")); Node node 1 = document. CreateTextNode (generated encoding document); Data ObjectDesk Data ObjectDisk = New EnvelopedXmlObject (node ​​1, "plain / text", "http://www.w3.org/2000/09/xmldsig#base64"); ....   

When I run this code in file.xml, then each row object "& amp; # 13; which produces an error with the decoding text < / P>

When I add this line: node node 1 = document. CreateTextNode (encoded generated document);

  saveFile ("c: \ temp \\ Temp.xml" , Generated document encoded); String string framefile = Read ("c: \\ temp \\ temp.xml"); node1.setTextContent (stringFromFile);   

Then the generated file is OK - My Where is the mistake? :)

I think that using Base 64 encoder you will produce spry output (insert carriage return in string). You change this character in the output string Can be created:

  generatedDocumentEncoded = generatedDocumentEncoded.replaceAll ("(\ r \ n | \ n)", ""); node node 1 = document.createNext (document encoded);   

or forcing your BASE64Encoder output not chunked output. I am using Apache Commons for that class:

  byte [] bytes = Generated document.getBytes ("UTF-8"); String generated document encoded = new string (base 64.exodebase 64 (bytes, fottle), "utf 8");    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -