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 2006/09/24 19:46:45 UTC

svn commit: r449442 - in /xml/security/trunk: CHANGELOG.txt src/org/apache/xml/security/transforms/TransformSpi.java

Author: raul
Date: Sun Sep 24 10:46:44 2006
New Revision: 449442

URL: http://svn.apache.org/viewvc?view=rev&rev=449442
Log:
Fixed bug 40512. Made TransformSPI backward compatible. Now it is possible to use implementations for the >1.3 versions paying the performance hit of the old implementation.

Modified:
    xml/security/trunk/CHANGELOG.txt
    xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java

Modified: xml/security/trunk/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/xml/security/trunk/CHANGELOG.txt?view=diff&rev=449442&r1=449441&r2=449442
==============================================================================
--- xml/security/trunk/CHANGELOG.txt (original)
+++ xml/security/trunk/CHANGELOG.txt Sun Sep 24 10:46:44 2006
@@ -1,5 +1,10 @@
 Changelog for "Apache xml-security" <http://xml.apache.org/security/>
 New in ...
+	Fixed bug 40512. Made TransformSPI backward compatible. Now it is possible 
+		to use implementations for the >1.3 versions paying the performance hit
+		of the old implementation.
+
+New in 1.4RC1	
 	Fixed bug 40290.
 	Fixed bug 40298.
 	Fixed bug 40360. Changed a little  the way the IdResolver works when 
@@ -37,7 +42,7 @@
         Fixed bug 38655
 	Fixed bug 38444.
 	Fixed bug 38605.
-	Fixed bug 39200
+	Fixed bug 39200(API CHANGE)
 		Refactored the way keyresolver works instead of calling canResolve/resolveX only resolveX is used  
 		and if it returns null it means it cannot resolve.
 	Minor Optimizations. 

Modified: xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java?view=diff&rev=449442&r1=449441&r2=449442
==============================================================================
--- xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java (original)
+++ xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java Sun Sep 24 10:46:44 2006
@@ -25,6 +25,8 @@
 import org.apache.xml.security.signature.XMLSignatureInput;
 import org.xml.sax.SAXException;
 
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
 
 /**
  * Base class which all Transform algorithms extend. The common methods that
@@ -32,7 +34,21 @@
  *
  * @author Christian Geuer-Pollmann
  */
-public abstract class TransformSpi {  
+public abstract class TransformSpi {
+	/**
+	 * For API compatibility not thread safe.
+	 * @deprecated
+	 */
+	protected Transform _transformObject = null;
+	/**
+	 * Set the transform object. 
+	 * Depeprecated For API compatibility.
+	 * @param transform
+	 * @deprecated
+	 */
+	protected void setTransform(Transform transform) {
+	   this._transformObject = transform;
+	}
    /**
     * The mega method which MUST be implemented by the Transformation Algorithm.
     *
@@ -68,13 +84,46 @@
     * @throws SAXException
     * @throws TransformationException
     */
-   protected abstract XMLSignatureInput enginePerformTransform(
+   protected XMLSignatureInput enginePerformTransform(
       XMLSignatureInput input, Transform _transformObject)
          throws IOException,
                 CanonicalizationException, InvalidCanonicalizerException,
                 TransformationException, ParserConfigurationException,
-                SAXException;
+                SAXException {
+	   //Default implementation overide with a much better
+	   TransformSpi tmp;
+	try {
+		tmp = (TransformSpi) getClass().newInstance();
+		tmp.setTransform(_transformObject);
+		return tmp.enginePerformTransform(input);
+	} catch (InstantiationException e) {
+		throw new TransformationException("",e);
+	} catch (IllegalAccessException e) {
+		throw new TransformationException("",e);
+	}
+   }
 
+   /**
+    * The mega method which MUST be implemented by the Transformation Algorithm.
+    * @deprecated
+    * @param input {@link XMLSignatureInput} as the input of transformation
+ * @param _transformObject TODO
+    * @return {@link XMLSignatureInput} as the result of transformation
+    * @throws CanonicalizationException
+    * @throws IOException
+    * @throws InvalidCanonicalizerException
+    * @throws ParserConfigurationException
+    * @throws SAXException
+    * @throws TransformationException
+    */
+   protected XMLSignatureInput enginePerformTransform(
+      XMLSignatureInput input)
+         throws IOException,
+                CanonicalizationException, InvalidCanonicalizerException,
+                TransformationException, ParserConfigurationException,
+                SAXException {
+	   throw new NotImplementedException();
+   };
    /**
     * Returns the URI representation of <code>Transformation algorithm</code>
     *



Re: svn commit: r449442 - in /xml/security/trunk: CHANGELOG.txt src/org/apache/xml/security/transforms/TransformSpi.java

Posted by Sean Mullan <Se...@Sun.COM>.
Hi Raul,

One comment -
sun.reflect.generics.reflectiveObjects.NotImplementedException is not a 
standard exception class, so it may not be in all Java runtimes and 
could change w/o warning. You should use 
java.lang.UnsupportedOperationException instead.

Thanks,
Sean

raul@apache.org wrote:
> Author: raul
> Date: Sun Sep 24 10:46:44 2006
> New Revision: 449442
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=449442
> Log:
> Fixed bug 40512. Made TransformSPI backward compatible. Now it is possible to use implementations for the >1.3 versions paying the performance hit of the old implementation.
> 
> Modified:
>     xml/security/trunk/CHANGELOG.txt
>     xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java
> 
> Modified: xml/security/trunk/CHANGELOG.txt
> URL: http://svn.apache.org/viewvc/xml/security/trunk/CHANGELOG.txt?view=diff&rev=449442&r1=449441&r2=449442
> ==============================================================================
> --- xml/security/trunk/CHANGELOG.txt (original)
> +++ xml/security/trunk/CHANGELOG.txt Sun Sep 24 10:46:44 2006
> @@ -1,5 +1,10 @@
>  Changelog for "Apache xml-security" <http://xml.apache.org/security/>
>  New in ...
> +	Fixed bug 40512. Made TransformSPI backward compatible. Now it is possible 
> +		to use implementations for the >1.3 versions paying the performance hit
> +		of the old implementation.
> +
> +New in 1.4RC1	
>  	Fixed bug 40290.
>  	Fixed bug 40298.
>  	Fixed bug 40360. Changed a little  the way the IdResolver works when 
> @@ -37,7 +42,7 @@
>          Fixed bug 38655
>  	Fixed bug 38444.
>  	Fixed bug 38605.
> -	Fixed bug 39200
> +	Fixed bug 39200(API CHANGE)
>  		Refactored the way keyresolver works instead of calling canResolve/resolveX only resolveX is used  
>  		and if it returns null it means it cannot resolve.
>  	Minor Optimizations. 
> 
> Modified: xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java
> URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java?view=diff&rev=449442&r1=449441&r2=449442
> ==============================================================================
> --- xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java (original)
> +++ xml/security/trunk/src/org/apache/xml/security/transforms/TransformSpi.java Sun Sep 24 10:46:44 2006
> @@ -25,6 +25,8 @@
>  import org.apache.xml.security.signature.XMLSignatureInput;
>  import org.xml.sax.SAXException;
>  
> +import sun.reflect.generics.reflectiveObjects.NotImplementedException;
> +
>  
>  /**
>   * Base class which all Transform algorithms extend. The common methods that
> @@ -32,7 +34,21 @@
>   *
>   * @author Christian Geuer-Pollmann
>   */
> -public abstract class TransformSpi {  
> +public abstract class TransformSpi {
> +	/**
> +	 * For API compatibility not thread safe.
> +	 * @deprecated
> +	 */
> +	protected Transform _transformObject = null;
> +	/**
> +	 * Set the transform object. 
> +	 * Depeprecated For API compatibility.
> +	 * @param transform
> +	 * @deprecated
> +	 */
> +	protected void setTransform(Transform transform) {
> +	   this._transformObject = transform;
> +	}
>     /**
>      * The mega method which MUST be implemented by the Transformation Algorithm.
>      *
> @@ -68,13 +84,46 @@
>      * @throws SAXException
>      * @throws TransformationException
>      */
> -   protected abstract XMLSignatureInput enginePerformTransform(
> +   protected XMLSignatureInput enginePerformTransform(
>        XMLSignatureInput input, Transform _transformObject)
>           throws IOException,
>                  CanonicalizationException, InvalidCanonicalizerException,
>                  TransformationException, ParserConfigurationException,
> -                SAXException;
> +                SAXException {
> +	   //Default implementation overide with a much better
> +	   TransformSpi tmp;
> +	try {
> +		tmp = (TransformSpi) getClass().newInstance();
> +		tmp.setTransform(_transformObject);
> +		return tmp.enginePerformTransform(input);
> +	} catch (InstantiationException e) {
> +		throw new TransformationException("",e);
> +	} catch (IllegalAccessException e) {
> +		throw new TransformationException("",e);
> +	}
> +   }
>  
> +   /**
> +    * The mega method which MUST be implemented by the Transformation Algorithm.
> +    * @deprecated
> +    * @param input {@link XMLSignatureInput} as the input of transformation
> + * @param _transformObject TODO
> +    * @return {@link XMLSignatureInput} as the result of transformation
> +    * @throws CanonicalizationException
> +    * @throws IOException
> +    * @throws InvalidCanonicalizerException
> +    * @throws ParserConfigurationException
> +    * @throws SAXException
> +    * @throws TransformationException
> +    */
> +   protected XMLSignatureInput enginePerformTransform(
> +      XMLSignatureInput input)
> +         throws IOException,
> +                CanonicalizationException, InvalidCanonicalizerException,
> +                TransformationException, ParserConfigurationException,
> +                SAXException {
> +	   throw new NotImplementedException();
> +   };
>     /**
>      * Returns the URI representation of <code>Transformation algorithm</code>
>      *
> 
>