You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Oliver Schmidt <os...@gmx.net> on 2003/10/02 17:15:36 UTC
[Patch] InclusiveNamespaces
Hi,
Scott Cantor <sc...@wideopenwest.com> wrote on Thu, 6 Feb 2003 23:22:37
-0500:
> Specifically, can I specify the InclusiveNamespaces PrefixList?
> ...
> I dug into the code in cvs, and from what I can tell, the SignedInfo.java
method to c14nize
> the SignedInfo node doesn't appear to be
> passing any prefixes into the engine call, which would explain my problem.
> ...
> losing my XPath Transform namespace declaration used in my expression
because
> the prefix isn't visibly used except inside the XPath element content.
I have the same problem. The following patch (it is not meant to be perfect)
corrects the SignedInfo class, i.e. the InclusiveNamespaces Element is
evaluated according to the "Exclusive XML Canonicalization Standard" at
http://www.w3.org/TR/xml-exc-c14n/ .
Best Regards,
Oliver Schmidt
Index: SignedInfo.java
===================================================================
RCS file:
/home/cvspublic/xml-security/src/org/apache/xml/security/signature/SignedInfo.java,v
retrieving revision 1.18
diff -u -3 -p -r1.18 SignedInfo.java
--- SignedInfo.java 29 Apr 2003 21:36:55 -0000 1.18
+++ SignedInfo.java 2 Oct 2003 15:14:02 -0000
@@ -200,7 +200,7 @@ public class SignedInfo extends Manifest
Canonicalizer.getInstance(this.getCanonicalizationMethodURI());
this._c14nizedBytes =
- c14nizer.canonicalizeSubtree(this._constructionElement);
+ c14nizer.canonicalizeSubtree(this._constructionElement,
this.getInclusiveNamespaces());
javax.xml.parsers.DocumentBuilderFactory dbf =
javax.xml.parsers.DocumentBuilderFactory.newInstance();
@@ -314,6 +314,47 @@ public class SignedInfo extends Manifest
}
return null;
+ }
+
+ /**
+ * Returns the InclusiveNamespaces list
+ *
+ * @return the InclusiveNamespaces list, an empty String if
+ * the InclusiveNamespaces list element is not specified.
+ */
+ public String getInclusiveNamespaces() {
+
+ NodeList children = this._constructionElement.getChildNodes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Node n = children.item(i);
+
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ boolean found = true;
+
+ try {
+ XMLUtils.guaranteeThatElementInSignatureSpace((Element) n,
+ Constants._TAG_CANONICALIZATIONMETHOD);
+ } catch (XMLSecurityException ex) {
+ found = false;
+ }
+
+ if (found) {
+ NodeList children2 = n.getChildNodes();
+ for (int j = 0; j < children2.getLength(); ++j) {
+ Node m = children2.item(j);
+ if (m.getNodeType() == Node.ELEMENT_NODE) {
+ Element e = (Element) m;
+ if (e.getLocalName() != null &&
e.getLocalName().equals("InclusiveNamespaces")) {
+ return e.getAttributeNS(null, "PrefixList");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return "";
}
/**
--
NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse für Mail, Message, More! +++
Re: [Patch] InclusiveNamespaces
Posted by Erwin van der Koogh <er...@koogh.com>.
>> Specifically, can I specify the InclusiveNamespaces PrefixList?
>> ...
>> I dug into the code in cvs, and from what I can tell, the
>> SignedInfo.java
> method to c14nize
>> the SignedInfo node doesn't appear to be
>> passing any prefixes into the engine call, which would explain my
>> problem. ...
>> losing my XPath Transform namespace declaration used in my expression
> because
>> the prefix isn't visibly used except inside the XPath element content.
>
> I have the same problem. The following patch (it is not meant to be
> perfect) corrects the SignedInfo class, i.e. the InclusiveNamespaces
> Element is evaluated according to the "Exclusive XML Canonicalization
> Standard" at http://www.w3.org/TR/xml-exc-c14n/ .
Thanks Oliver!
I will take a look at it hopefully before I will have to start packing up
my computer for yet another move to a new city :)
Erwin