You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by vd...@apache.org on 2004/04/14 23:38:44 UTC
cvs commit: xml-security/src/org/apache/xml/security/transforms Transforms.java
vdkoogh 2004/04/14 14:38:44
Modified: src/org/apache/xml/security/algorithms JCEMapper.java
src/org/apache/xml/security/transforms Transforms.java
Log:
Speed optimizations..
Patches posted to dev list at April 14th 2004
Submitted by: raul-info@r-bg.com
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.20 +12 -7 xml-security/src/org/apache/xml/security/algorithms/JCEMapper.java
Index: JCEMapper.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/algorithms/JCEMapper.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- JCEMapper.java 6 Mar 2004 11:39:49 -0000 1.19
+++ JCEMapper.java 14 Apr 2004 21:38:44 -0000 1.20
@@ -21,6 +21,8 @@
import java.security.Key;
import java.security.Provider;
import java.security.Security;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.transform.TransformerException;
@@ -48,6 +50,8 @@
/** Field _nscontext */
private static Element _nscontext = null;
+
+ private static Map uriToProvider = new HashMap();
/**
* Method init
@@ -179,13 +183,13 @@
log.debug("Request for URI " + AlgorithmURI);
try {
+
+ ProviderIdClass prov=(ProviderIdClass)
+ uriToProvider.get(AlgorithmURI);
+ if (prov!=null) {
+ return prov;
+ }
- /*
- Attr jceName = (Attr) XPathAPI.selectSingleNode(
- JCEMapper._providerList,
- "./x:Algorithms/x:Algorithm[@URI='" + AlgorithmURI
- + "']/x:Provider[1]/@JCEName", JCEMapper._nscontext);
- */
NodeList providers = XPathAPI.selectNodeList(JCEMapper._providerList,
"./x:Algorithms/x:Algorithm[@URI='"
+ AlgorithmURI + "']/x:ProviderAlgo",
@@ -205,6 +209,7 @@
log.debug("Found " + result.getAlgorithmID() + " from provider "
+ result.getProviderId());
+ uriToProvider.put(AlgorithmURI,result);
return result;
}
}
1.14 +25 -14 xml-security/src/org/apache/xml/security/transforms/Transforms.java
Index: Transforms.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/transforms/Transforms.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Transforms.java 8 Feb 2004 06:11:35 -0000 1.13
+++ Transforms.java 14 Apr 2004 21:38:44 -0000 1.14
@@ -35,6 +35,7 @@
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -245,20 +246,30 @@
* @return the number of transformations
* @throws TransformationException
*/
- public int getLength() throws TransformationException {
-
- try {
- Element nscontext = XMLUtils.createDSctx(this._doc, "ds",
- Constants.SignatureSpecNS);
- NodeList transformElems =
- XPathAPI.selectNodeList(this._constructionElement,
- "./ds:Transform", nscontext);
-
- return transformElems.getLength();
- } catch (TransformerException ex) {
- throw new TransformationException("empty", ex);
- }
- }
+ public int getLength() throws TransformationException
+ {
+ /*Element nscontext = XMLUtils.createDSctx(this._doc, "ds",
+ Constants.SignatureSpecNS);
+ NodeList transformElems =
+ XPathAPI.selectNodeList(this._constructionElement,
+ "./ds:Transform", nscontext);
+ return transformElems.getLength();*/
+ int size=0;
+ Node sibling= this._constructionElement.getFirstChild();
+ while (sibling!=null)
+ {
+ if ("Transform".equals(sibling.getLocalName())
+ && Constants.SignatureSpecNS.equals(sibling.getNamespaceURI())) {
+ size++;
+ }
+ sibling=sibling.getNextSibling();
+ }
+ if (size==0)
+ {
+ throw new TransformationException("empty");
+ }
+ return size;
+ }
/**
* Return the <it>i</it><sup>th</sup> <code>{@link Transform}</code>.