santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raul Benito" <r...@apache.org>
Subject Re: Document removes xml header
Date Thu, 23 Mar 2006 18:38:51 GMT
The <?xml ...> is removed by the Canocilazation method as it is
mandated by the c14n spec.

Regards,

Raul

On 3/23/06, Michael Kail <michael.kail@rl-ag.com> wrote:
> Morning everybody!
>
> Could it be, that the java class org.w3c.dom.Document removes my xml
> header information(<?xml version="1.0" encoding=...)???
> Before loading the xml file there is a header, after making an enveloped
> xml signature and writing it back into file there is none.
> Could it be that the Document class removes that information? Currently
> am adding the header after signing with JDOM.... But I have to open and
> parse
> The file again(ugly!).
>
> Thanxs!!!!!
>
> There's my source code, if there's any error... tell me:
>
> javax.xml.parsers.DocumentBuilderFactory dbf =
>                  javax.xml.parsers.DocumentBuilderFactory.newInstance();
>
>            //dbf.setNamespaceAware(true);
>
>            javax.xml.parsers.DocumentBuilder db =
> dbf.newDocumentBuilder();
>
>            org.w3c.dom.Document doc = db.parse(signatureFile);
>
>            String BaseURI = signatureFile.toURL().toString();
>
>
> ElementProxy.setDefaultPrefix("http://www.w3.org/2000/09/xmldsig#","");
>
>               XMLSignature sig = new XMLSignature(doc, BaseURI,
>
> XMLSignature.ALGO_ID_SIGNATURE_DSA);
>
>               //add signature information to document
>               Node nl = doc.getFirstChild();
>               nl.appendChild(sig.getElement());
>
>               Transforms transforms = new Transforms(doc);
>
>
> transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
>
>               //add document "archivdescriptor" to signed content
>               sig.addDocument("", transforms,
> Constants.ALGO_ID_DIGEST_SHA1);
>
>               {
>                  X509Certificate cert =
>                     (X509Certificate)
> ks.getCertificate(certificateAlias);
>
>                  sig.addKeyInfo(cert);
>                  sig.addKeyInfo(cert.getPublicKey());
>                  sig.sign(privateKey);
>               }
>
>               FileOutputStream f = new FileOutputStream(signatureFile);
>
>               XMLUtils.outputDOMc14nWithComments(doc, f);
>               f.close();
>


--
http://r-bg.com

Mime
View raw message