Return-Path: Delivered-To: apmail-xml-security-dev-archive@www.apache.org Received: (qmail 73448 invoked from network); 23 Mar 2006 18:39:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Mar 2006 18:39:33 -0000 Received: (qmail 57339 invoked by uid 500); 23 Mar 2006 18:39:32 -0000 Delivered-To: apmail-xml-security-dev-archive@xml.apache.org Received: (qmail 57319 invoked by uid 500); 23 Mar 2006 18:39:31 -0000 Mailing-List: contact security-dev-help@xml.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: security-dev@xml.apache.org List-Id: Delivered-To: mailing list security-dev@xml.apache.org Received: (qmail 57308 invoked by uid 99); 23 Mar 2006 18:39:31 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Mar 2006 10:39:31 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of raul.benito.garcia@gmail.com designates 64.233.184.197 as permitted sender) Received: from [64.233.184.197] (HELO wproxy.gmail.com) (64.233.184.197) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Mar 2006 10:39:31 -0800 Received: by wproxy.gmail.com with SMTP id 69so521086wra for ; Thu, 23 Mar 2006 10:39:10 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ouJt6ZVCH5cYnRDy+GZPF8cbMR3hLyCzc0k1CnGF8qPzBMro1kapD7LPrdCxzXRYzwhEckC67tRXhbbEAY772Re3wfgWrzxJlXZpIkaq1GmxesWXO1ZlGsLK1LtPQs9MgppZCGbVGxIpezUFeRUyJSw00QZsQZd5xOagRVfyIX4= Received: by 10.65.218.11 with SMTP id v11mr1875467qbq; Thu, 23 Mar 2006 10:38:51 -0800 (PST) Received: by 10.64.181.9 with HTTP; Thu, 23 Mar 2006 10:38:51 -0800 (PST) Message-ID: <949ac9410603231038q495d0554p20731fe9787124b4@mail.gmail.com> Date: Thu, 23 Mar 2006 19:38:51 +0100 From: "Raul Benito" Sender: raul.benito.garcia@gmail.com To: security-dev@xml.apache.org Subject: Re: Document removes xml header In-Reply-To: <86849E8D015FC545A1C0F6F19FC290701B5F85@majestix.RL-AG.local> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <86849E8D015FC545A1C0F6F19FC290701B5F85@majestix.RL-AG.local> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N The is removed by the Canocilazation method as it is mandated by the c14n spec. Regards, Raul On 3/23/06, Michael Kail wrote: > Morning everybody! > > Could it be, that the java class org.w3c.dom.Document removes my xml > header information( 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 =3D > javax.xml.parsers.DocumentBuilderFactory.newInstance(); > > //dbf.setNamespaceAware(true); > > javax.xml.parsers.DocumentBuilder db =3D > dbf.newDocumentBuilder(); > > org.w3c.dom.Document doc =3D db.parse(signatureFile); > > String BaseURI =3D signatureFile.toURL().toString(); > > > ElementProxy.setDefaultPrefix("http://www.w3.org/2000/09/xmldsig#",""); > > XMLSignature sig =3D new XMLSignature(doc, BaseURI, > > XMLSignature.ALGO_ID_SIGNATURE_DSA); > > //add signature information to document > Node nl =3D doc.getFirstChild(); > nl.appendChild(sig.getElement()); > > Transforms transforms =3D 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 =3D > (X509Certificate) > ks.getCertificate(certificateAlias); > > sig.addKeyInfo(cert); > sig.addKeyInfo(cert.getPublicKey()); > sig.sign(privateKey); > } > > FileOutputStream f =3D new FileOutputStream(signatureFile); > > XMLUtils.outputDOMc14nWithComments(doc, f); > f.close(); > -- http://r-bg.com