santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Mullan <>
Subject Re: Namespace definition in XMLObject
Date Wed, 11 May 2011 12:57:01 GMT
On 5/11/11 7:37 AM, Wolfgang Schmiesing wrote:
> Hi,
> I'm currently using the "javax.xml.crypto.dsig" API to create a signature. Now,
> is there any way of assigning a namespace definition to
> an <Object> element inside the signature? The output I need should look similar
> to this:
> <Signature>
> ...
> <Object xmlns:test="" Id="someId">
> <test:someElem />
> <test:someElem />
> </Object>
> </Signature>
> I'm currently creating the <Object> element using the following call:
>> XMLSignatureFactory.newXMLObject( List content, String id, String mimeType,
>> String encoding );
> This returns a javax.xml.crypto.dsig.XMLObject. Unfortunately, I can't find a
> way of assigning a namespace in "XMLObject".
> I managed to create an <Object> element with a namespace using
> "" but
> am currently not able to switch to XMLSecurity APIs. Is this the only way to do
> it or am I missing something?

No, I don't think so. It is a limitation in the API. You can add the namespace 
declarations to the test elements by creating Elements and wrapping them in 
DOMStructures. But in order to add them to the Object element you will need to 
access the underlying DOM and add them using DOM APIs.

Another alternative is to use an XML template of an XML Signature where all of 
the namespace declarations are already in place. That is you unmarshal an 
XMLSignature object from XML (with empty or bogus DigestValue and SignatureValue 
elements) using XMLSignatureFactory.unmarshal and then sign it using 


> Kind regards,
> Wolfgang

View raw message