You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Mathias Berg <ma...@gmail.com> on 2009/12/16 12:05:24 UTC

XMLSignature and output escaped problem

When i try to add a xml block into a  in my XMLSignature file. All the xml
block is being escaped.

What is the best way to add xml block into . I use addText on
ObjectContainer.

I noticed DOMResult has a flag PI_DISABLE_OUTPUT_ESCAPING. How can i use
that?

---------------------------------------------------------------------------
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();

Document rootDoc = db.newDocument();
XMLSignature rootSig = new XMLSignature(rootDoc,
null,XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
rootDoc.appendChild(rootSig.getElement());

//Here we create and sign my sub xml
//this shall later be append into the root doc. created above
Document subXmlDoc= addOrder(rootDoc, rootSig);

//I now create the  in my root doc. here the sub xml shall be appended
String Id = "orderId1";
rootSig.addDocument("#" + Id);
ObjectContainer objOrderId1 = new ObjectContainer(rootDoc);
objOrderId1.setId(Id);

....
//this is where i convert my signed xml so i can get it as a String
XMLSignatureInput orderInput = new XMLSignatureInput((Node) subXmlDoc);
String xmlAsString = new String(orderInput.getBytes(), "UTF-8");

//Now i add the subxml into my rootDoc object
//its here where the xmlAsString is being escaped.
objOrderId1.addText(xmlAsString );
rootSig.appendObject(objOrderId1);

//then i do signature
.......
-- 
View this message in context: http://old.nabble.com/XMLSignature-and-output-escaped-problem-tp26809481p26809481.html
Sent from the Apache XML - Security - Dev mailing list archive at Nabble.com.