You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2004/12/24 13:26:17 UTC
cvs commit: xml-security/src/org/apache/xml/security/utils/resolver/implementations ResolverXPointer.java ResolverFragment.java
raul 2004/12/24 04:26:17
Modified: src/org/apache/xml/security/signature XMLSignatureInput.java
Manifest.java Reference.java
src/org/apache/xml/security/utils CachedXPathAPIHolder.java
IdResolver.java
src/org/apache/xml/security/utils/resolver/implementations
ResolverXPointer.java ResolverFragment.java
Log:
Fix BUG 32836(http://issues.apache.org/bugzilla/show_bug.cgi?id=32836)
Now store also the document in the thread local
and when different reset the CachedXPathAPI.
Revision Changes Path
1.33 +11 -2 xml-security/src/org/apache/xml/security/signature/XMLSignatureInput.java
Index: XMLSignatureInput.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/signature/XMLSignatureInput.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XMLSignatureInput.java 24 Dec 2004 10:41:07 -0000 1.32
+++ XMLSignatureInput.java 24 Dec 2004 12:26:17 -0000 1.33
@@ -489,7 +489,16 @@
*/
public CachedXPathAPIHolder getCachedXPathAPI() {
if (this._cxpathAPI==null) {
- this._cxpathAPI=new CachedXPathAPIHolder();
+ if (this.isOctetStream()) {
+ this._cxpathAPI=new CachedXPathAPIHolder(null);
+ } else {
+ if (this._inputNodeSet!=null) {
+ this._cxpathAPI=new CachedXPathAPIHolder(((Node)this._inputNodeSet.iterator().next()).getOwnerDocument());
+ }
+ if (this.isElement()) {
+ this._cxpathAPI=new CachedXPathAPIHolder(XMLUtils.getOwnerDocument(_subNode));
+ }
+ }
}
return this._cxpathAPI;
}
1.32 +4 -4 xml-security/src/org/apache/xml/security/signature/Manifest.java
Index: Manifest.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/signature/Manifest.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Manifest.java 18 Nov 2004 22:51:32 -0000 1.31
+++ Manifest.java 24 Dec 2004 12:26:17 -0000 1.32
@@ -73,7 +73,7 @@
/** Field _perManifestResolvers */
Vector _perManifestResolvers = new Vector();
- CachedXPathAPIHolder cx=new CachedXPathAPIHolder();
+ //CachedXPathAPIHolder cx=new CachedXPathAPIHolder();
/**
* Consturts {@link Manifest}
*
@@ -145,7 +145,7 @@
// the this._doc is handed implicitly by the this.getOwnerDocument()
Reference ref = new Reference(this._doc, BaseURI, referenceURI, this,
- transforms, digestURI,cx);
+ transforms, digestURI);
if (ReferenceId != null) {
ref.setId(ReferenceId);
@@ -213,7 +213,7 @@
if (this._references.elementAt(i) == null) {
// not yet constructed, so _we_ have to
- Reference ref = new Reference(_referencesEl[i], this._baseURI, this,cx);
+ Reference ref = new Reference(_referencesEl[i], this._baseURI, this);
this._references.set(i, ref);
}
@@ -309,7 +309,7 @@
for (int i =
0; i < this._referencesEl.length; i++) {
Reference currentRef =
- new Reference(_referencesEl[i], this._baseURI, this,cx);
+ new Reference(_referencesEl[i], this._baseURI, this);
this._references.set(i, currentRef);
1.37 +3 -7 xml-security/src/org/apache/xml/security/signature/Reference.java
Index: Reference.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/signature/Reference.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- Reference.java 23 Sep 2004 20:23:18 -0000 1.36
+++ Reference.java 24 Dec 2004 12:26:17 -0000 1.37
@@ -36,7 +36,6 @@
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.transforms.params.InclusiveNamespaces;
import org.apache.xml.security.utils.Base64;
-import org.apache.xml.security.utils.CachedXPathAPIHolder;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.DigesterOutputStream;
import org.apache.xml.security.utils.IdResolver;
@@ -116,7 +115,6 @@
//J-
Manifest _manifest = null;
XMLSignatureInput _transformsOutput;
- CachedXPathAPIHolder cx;
//J+
/**
@@ -132,7 +130,7 @@
* @param cx for speed-up the xpath selections.
* @throws XMLSignatureException
*/
- protected Reference(Document doc, String BaseURI, String ReferenceURI, Manifest manifest, Transforms transforms, String messageDigestAlgorithm,CachedXPathAPIHolder cx)
+ protected Reference(Document doc, String BaseURI, String ReferenceURI, Manifest manifest, Transforms transforms, String messageDigestAlgorithm)
throws XMLSignatureException {
super(doc);
@@ -141,7 +139,6 @@
this._baseURI = BaseURI;
this._manifest = manifest;
- this.cx=cx;
this.setURI(ReferenceURI);
@@ -182,11 +179,10 @@
* @param cx The CachedXPathAPIHolder to use in this reference.
* @throws XMLSecurityException
*/
- protected Reference(Element element, String BaseURI, Manifest manifest,CachedXPathAPIHolder cx)
+ protected Reference(Element element, String BaseURI, Manifest manifest)
throws XMLSecurityException {
- super(element, BaseURI);
- this.cx=cx;
+ super(element, BaseURI);
this._manifest = manifest;
}
1.4 +12 -9 xml-security/src/org/apache/xml/security/utils/CachedXPathAPIHolder.java
Index: CachedXPathAPIHolder.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/CachedXPathAPIHolder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CachedXPathAPIHolder.java 24 Dec 2004 11:23:35 -0000 1.3
+++ CachedXPathAPIHolder.java 24 Dec 2004 12:26:17 -0000 1.4
@@ -17,6 +17,7 @@
package org.apache.xml.security.utils;
import org.apache.xpath.CachedXPathAPI;
+import org.w3c.dom.Document;
/**
@@ -24,15 +25,15 @@
*/
public class CachedXPathAPIHolder {
static ThreadLocal local=new ThreadLocal();
- //Just to call reset after a time.
- static final int RESET_NUMBER=10;
- static int resetCounter=RESET_NUMBER;
+ static ThreadLocal localDoc=new ThreadLocal();
+ Document doc;
CachedXPathAPI cx;
/**
*
*/
- public CachedXPathAPIHolder() {
+ public CachedXPathAPIHolder(Document doc) {
cx=null;
+ this.doc=doc;
// TODO Auto-generated constructor stub
}
/**
@@ -44,12 +45,14 @@
if (cx==null) {
cx=new CachedXPathAPI();
local.set(cx);
+ localDoc.set(doc);
} else {
- resetCounter--;
- if (resetCounter<0) {
- cx.getXPathContext().reset();
- resetCounter=RESET_NUMBER;
- }
+ if (localDoc.get()!=doc) {
+ //Different docs reset.
+ cx.getXPathContext().reset();
+ localDoc.set(doc);
+ }
+
}
//cx.getXPathContext().reset();//
//cx=new CachedXPathAPI();
1.20 +1 -1 xml-security/src/org/apache/xml/security/utils/IdResolver.java
Index: IdResolver.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/IdResolver.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- IdResolver.java 25 Sep 2004 19:42:23 -0000 1.19
+++ IdResolver.java 24 Dec 2004 12:26:17 -0000 1.20
@@ -119,7 +119,7 @@
}
// this must be done so that Xalan can catch ALL namespaces
//XMLUtils.circumventBug2650(doc);
- CachedXPathAPI cx=new CachedXPathAPIHolder().getCachedXPathAPI();//cxHolder.getCachedXPathAPI();
+ CachedXPathAPI cx=new CachedXPathAPIHolder(doc).getCachedXPathAPI();//cxHolder.getCachedXPathAPI();
result = IdResolver.getElementByIdInDSNamespace(doc, id,cx);
if (result != null) {
1.23 +1 -1 xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java
Index: ResolverXPointer.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ResolverXPointer.java 25 Sep 2004 19:42:22 -0000 1.22
+++ ResolverXPointer.java 24 Dec 2004 12:26:17 -0000 1.23
@@ -90,7 +90,7 @@
//Set resultSet = XMLUtils.convertNodelistToSet(resultNode);
- XMLSignatureInput result = new XMLSignatureInput(resultNode,new CachedXPathAPIHolder());
+ XMLSignatureInput result = new XMLSignatureInput(resultNode,new CachedXPathAPIHolder(doc));
result.setMIMEType("text/xml");
1.22 +1 -1 xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
Index: ResolverFragment.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ResolverFragment.java 25 Sep 2004 19:42:22 -0000 1.21
+++ ResolverFragment.java 24 Dec 2004 12:26:17 -0000 1.22
@@ -89,7 +89,7 @@
}
//Set resultSet = dereferenceSameDocumentURI(selectedElem);
- XMLSignatureInput result = new XMLSignatureInput(selectedElem,new CachedXPathAPIHolder());
+ XMLSignatureInput result = new XMLSignatureInput(selectedElem,new CachedXPathAPIHolder(doc));
result.setExcludeComments(true);
//log.debug("We return a nodeset with " + resultSet.size() + " nodes");