You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2010/07/21 18:50:40 UTC

svn commit: r966311 - in /xml/security/trunk: ./ libs/ src/org/apache/xml/security/keys/keyresolver/ src/org/jcp/xml/dsig/internal/dom/ src_unitTests/javax/xml/crypto/test/ src_unitTests/org/apache/xml/security/test/ src_unitTests/org/apache/xml/securi...

Author: coheigea
Date: Wed Jul 21 16:50:39 2010
New Revision: 966311

URL: http://svn.apache.org/viewvc?rev=966311&view=rev
Log:
Partial fix for Bug 49629  - Some changes to the build system 
This patch covers some build problems:

1) The fix for the recently introduced JDK 1.4 compilation error.
2) Skipped some tests if certain algorithms are not available...this
is to make the tests pass on JDK 1.4.
3) Changed the provider info and version number of XMLDSigRI, added a
"VersionTest" for this to make sure it gets changed.
4) Removed the versionless jars in libs, and replaced them with versioned jars
5) Changed build.xml test and test_jsr105 targets to depend on
build.jar - This is so that the xmlsec jar gets generated before tests
are run, and then copied into build/libs/endorsed
6) Replaced the sun.security.* dependencies in the KeySelectors test class.

Added:
    xml/security/trunk/libs/commons-logging-1.1.jar   (with props)
    xml/security/trunk/libs/commons-logging-api-1.1.jar   (with props)
    xml/security/trunk/libs/serializer-2.7.1.jar   (with props)
    xml/security/trunk/libs/xalan-2.7.1.jar   (with props)
    xml/security/trunk/libs/xercesImpl-2.9.1.jar   (with props)
    xml/security/trunk/libs/xml-apis-1.3.03.jar   (with props)
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/version/
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/version/VersionTest.java
Removed:
    xml/security/trunk/libs/commons-logging-api.jar
    xml/security/trunk/libs/commons-logging.jar
    xml/security/trunk/libs/serializer.jar
    xml/security/trunk/libs/xalan.jar
    xml/security/trunk/libs/xercesImpl.jar
    xml/security/trunk/libs/xml-apis.jar
Modified:
    xml/security/trunk/CHANGELOG.txt
    xml/security/trunk/build.xml
    xml/security/trunk/pom.xml
    xml/security/trunk/src/org/apache/xml/security/keys/keyresolver/KeyResolver.java
    xml/security/trunk/src/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
    xml/security/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/ModuleTest.java
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/EncryptContentTest.java
    xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java

Modified: xml/security/trunk/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/xml/security/trunk/CHANGELOG.txt?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/CHANGELOG.txt (original)
+++ xml/security/trunk/CHANGELOG.txt Wed Jul 21 16:50:39 2010
@@ -1,5 +1,6 @@
 Changelog for "Apache xml-security" <http://santuario.apache.org/>
 New in v1.4.4-SNAPSHOT
+    Fixed Bug 49629: Some changes to the build system.
     Fixed Bug 49483: KeyResolver.registerAtStart() leads to ClassCastException. Thanks to Clement Pellerin.
     Fixed Bug 49458: StorageResolver always exhausted after first use. Thanks to Clement Pellerin.
     Fixed Bug 49456: StorageResolver.next() gives ClassCastException. Thanks to Clement Pellerin.

Modified: xml/security/trunk/build.xml
URL: http://svn.apache.org/viewvc/xml/security/trunk/build.xml?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/build.xml (original)
+++ xml/security/trunk/build.xml Wed Jul 21 16:50:39 2010
@@ -22,7 +22,7 @@
 	  value="${product.version.major}.${product.version.minor}.${product.version.level}${product.version.qualifier}"/>
     <property name="product_version" 
 	  value="${product.version.major}_${product.version.minor}_${product.version.level}${product.version.qualifier}"/>
-    <property name="year" value="2000-2009"/>
+    <property name="year" value="2000-2010"/>
     <property name="copyright" 
 			  value="Copyright © ${year} Apache XML Project. All Rights Reserved."/>
 
@@ -54,13 +54,13 @@
     <property name="dir.manifest"       value="${dir.build.bin}/META-INF"/>
 
     <!-- library properties -->
-    <property name="lib.logging"        value="${dir.libs}/commons-logging.jar" />
-    <property name="lib.logging.api"    value="${dir.libs}/commons-logging-api.jar" />
+    <property name="lib.logging"        value="${dir.libs}/commons-logging-1.1.jar" />
+    <property name="lib.logging.api"    value="${dir.libs}/commons-logging-api-1.1.jar" />
     <property name="lib.log4j"          value="${dir.libs}/log4j-1.2.8.jar" />
-    <property name="lib.xalan.1"        value="${dir.libs}/xalan.jar" />
-    <property name="lib.xalan.2"        value="${dir.libs}/serializer.jar" />
-    <property name="lib.xalan.3"        value="${dir.libs}/xml-apis.jar" />
-    <property name="lib.xerces.1"       value="${dir.libs}/xercesImpl.jar" />
+    <property name="lib.xalan.1"        value="${dir.libs}/xalan-2.7.1.jar" />
+    <property name="lib.xalan.2"        value="${dir.libs}/serializer-2.7.1.jar" />
+    <property name="lib.xalan.3"        value="${dir.libs}/xml-apis-1.3.03.jar" />
+    <property name="lib.xerces.1"       value="${dir.libs}/xercesImpl-2.9.1.jar" />
     <property name="lib.jce"            value="${dir.libs}/${jce.provider.prefix}-${jce.provider.jar}" />
     <property name="lib.junit"		value="${dir.libs}/junit-3.8.1.jar" />
     <property name="lib.clover"		value="${dir.libs}/clover.jar" />
@@ -321,7 +321,7 @@
 
 	<!-- T E S T  T A R G E T S -->  
 	<!-- big test -->
-	<target name="test" depends="build.test"
+	<target name="test" depends="build.jar"
 		description="Starts all Junit tests">
 	    <delete dir="${dir.build.junit.xml}"/>
 	    <delete dir="${dir.build.junit.html}"/>
@@ -344,10 +344,15 @@
 	         IBM is 'magically' included in the test ;-))
 	    -->
 	    <available file="data/com/ibm/xss4j-20030127/enveloped-rsa.sig" property="ibm.available"/>
-            <copy file="${lib.xalan.1}" todir="${dir.build.libs2}"/>
-            <copy file="${lib.xalan.2}" todir="${dir.build.libs2}"/>
-            <copy file="${lib.xalan.3}" todir="${dir.build.libs2}"/>
-            <copy file="${lib.xerces.1}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xalan.1}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xalan.2}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xalan.3}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xerces.1}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.logging.api}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.logging}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.junit}" todir="${dir.build.libs2}"/>
+        <copy file="${jar.library}" todir="${dir.build.libs2}"/>
+        <copy file="${jar.tests}" todir="${dir.build.libs2}"/>
 	    <junit filtertrace="true" fork="true" printsummary="on" 
 		   failureproperty="build.test.failed">
 	        <jvmarg value="-Djava.compiler=NONE"/>
@@ -357,6 +362,7 @@
                 <sysproperty key="proxyPort" value="${proxy.port}"/>
                 <sysproperty key="java.util.logging.config.file" 
 			     value="${basedir}/logging.properties"/>
+	            <sysproperty key="product.version" value="${product.version}"/>
 	        <classpath refid="id.classpath.test"/>
 	        <formatter type="xml"/>
 	        <!-- Also put output to screen -->
@@ -378,12 +384,21 @@
 	</target>
 
     <!-- Test JSR 105/XML DSig API -->
-    <target name="test_jsr105" depends="build.test"
+    <target name="test_jsr105" depends="build.jar"
 	    description="Runs JSR 105 interop and unit tests">
         <delete dir="${dir.build.junit.xml}"/>
         <delete dir="${dir.build.junit.html}"/>
         <mkdir dir="${dir.build.junit.xml}"/>
         <mkdir dir="${dir.build.junit.html}"/>
+        <copy file="${lib.xalan.1}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xalan.2}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xalan.3}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.xerces.1}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.logging.api}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.logging}" todir="${dir.build.libs2}"/>
+        <copy file="${lib.junit}" todir="${dir.build.libs2}"/>
+        <copy file="${jar.library}" todir="${dir.build.libs2}"/>
+        <copy file="${jar.tests}" todir="${dir.build.libs2}"/>
         <junit filtertrace="true" fork="true" printsummary="on" 
 	       failureproperty="build.test.failed">
             <sysproperty key="basedir" value="${basedir}"/>

Added: xml/security/trunk/libs/commons-logging-1.1.jar
URL: http://svn.apache.org/viewvc/xml/security/trunk/libs/commons-logging-1.1.jar?rev=966311&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xml/security/trunk/libs/commons-logging-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xml/security/trunk/libs/commons-logging-api-1.1.jar
URL: http://svn.apache.org/viewvc/xml/security/trunk/libs/commons-logging-api-1.1.jar?rev=966311&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xml/security/trunk/libs/commons-logging-api-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xml/security/trunk/libs/serializer-2.7.1.jar
URL: http://svn.apache.org/viewvc/xml/security/trunk/libs/serializer-2.7.1.jar?rev=966311&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xml/security/trunk/libs/serializer-2.7.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xml/security/trunk/libs/xalan-2.7.1.jar
URL: http://svn.apache.org/viewvc/xml/security/trunk/libs/xalan-2.7.1.jar?rev=966311&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xml/security/trunk/libs/xalan-2.7.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xml/security/trunk/libs/xercesImpl-2.9.1.jar
URL: http://svn.apache.org/viewvc/xml/security/trunk/libs/xercesImpl-2.9.1.jar?rev=966311&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xml/security/trunk/libs/xercesImpl-2.9.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: xml/security/trunk/libs/xml-apis-1.3.03.jar
URL: http://svn.apache.org/viewvc/xml/security/trunk/libs/xml-apis-1.3.03.jar?rev=966311&view=auto
==============================================================================
Binary file - no diff available.

Propchange: xml/security/trunk/libs/xml-apis-1.3.03.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: xml/security/trunk/pom.xml
URL: http://svn.apache.org/viewvc/xml/security/trunk/pom.xml?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/pom.xml (original)
+++ xml/security/trunk/pom.xml Wed Jul 21 16:50:39 2010
@@ -192,6 +192,7 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
+                    <version>2.5</version>
                     <configuration>
                         <reportFormat>brief</reportFormat>
                         <useFile>false</useFile>
@@ -200,6 +201,9 @@
                         <includes>
                             <include>org/apache/xml/security/test/AllTests.java</include>
                         </includes>
+                        <systemPropertyVariables>
+                            <product.version>${project.version}</product.version>
+                        </systemPropertyVariables>
                     </configuration>
                 </plugin>
   

Modified: xml/security/trunk/src/org/apache/xml/security/keys/keyresolver/KeyResolver.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/apache/xml/security/keys/keyresolver/KeyResolver.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src/org/apache/xml/security/keys/keyresolver/KeyResolver.java (original)
+++ xml/security/trunk/src/org/apache/xml/security/keys/keyresolver/KeyResolver.java Wed Jul 21 16:50:39 2010
@@ -249,7 +249,8 @@ public class KeyResolver {
        }
        
        if (ex != null) {
-           throw new IllegalArgumentException("Invalid KeyResolver class name", ex);
+           throw (IllegalArgumentException) new
+               IllegalArgumentException("Invalid KeyResolver class name").initCause(ex);
        }
        
        KeyResolver._resolverVector.add(0, resolver);

Modified: xml/security/trunk/src/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java (original)
+++ xml/security/trunk/src/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java Wed Jul 21 16:50:39 2010
@@ -48,12 +48,12 @@ public final class XMLDSigRI extends Pro
 
     static final long serialVersionUID = -5049765099299494554L;
 
-    private static final String INFO = "XMLDSig " + 
-    "(DOM XMLSignatureFactory; DOM KeyInfoFactory)";
+    private static final String INFO = "Apache Santuario XMLDSig " + 
+        "(DOM XMLSignatureFactory; DOM KeyInfoFactory)";
 
     public XMLDSigRI() {
 	/* We are the XMLDSig provider */
-	super("XMLDSig", 1.0, INFO);
+	super("XMLDSig", 1.44, INFO);
 	
 	final Map map = new HashMap();
         map.put("XMLSignatureFactory.DOM", 

Modified: xml/security/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java (original)
+++ xml/security/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java Wed Jul 21 16:50:39 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2009 The Apache Software Foundation.
+ * Copyright 2006-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@ import javax.xml.crypto.*;
 import javax.xml.crypto.dsig.*;
 import javax.xml.crypto.dsig.keyinfo.*;
 import javax.crypto.SecretKey;
-import sun.security.util.DerValue;
-import sun.security.x509.X500Name;
 
 
 /**
@@ -108,7 +106,6 @@ public class KeySelectors {
 			}
 		    }
 		    Iterator xi = xd.getContent().iterator();
-		    boolean hasCRL = false;
 		    while (xi.hasNext()) {
 			Object o = xi.next();
 			// skip non-X509Certificate entries
@@ -217,20 +214,19 @@ public class KeySelectors {
 	    Vector matchResult = new Vector();
 	    for (int j=0; j < pool.size(); j++) {
 		X509Certificate c = (X509Certificate) pool.get(j);
+		
 		switch (matchType) {
 		case MATCH_SUBJECT:
-		    try {
-		        if (c.getSubjectDN().equals(new X500Name((String)value))) {
+		    Principal p1 = new javax.security.auth.x500.X500Principal((String)value);
+	        if (c.getSubjectX500Principal().equals(p1)) {
 			    matchResult.add(c);
-		        }
-		    } catch (IOException ioe) { }
+	        }
 		    break;
 		case MATCH_ISSUER:
-		    try {
-		        if (c.getIssuerDN().equals(new X500Name((String)value))) {
+		    Principal p2 = new javax.security.auth.x500.X500Principal((String)value);
+	        if (c.getIssuerX500Principal().equals(p2)) {
 			    matchResult.add(c);
-		        }
-		    } catch (IOException ioe) { }
+	        }
 		    break;
 		case MATCH_SERIAL:
 		    if (c.getSerialNumber().equals(value)) {
@@ -241,15 +237,12 @@ public class KeySelectors {
 		case MATCH_SUBJECT_KEY_ID:
 		    byte[] extension = c.getExtensionValue("2.5.29.14");
 		    if (extension != null) {
-			try {
-			    DerValue derValue = new DerValue(extension);
-			    DerValue derValue2 = new DerValue(derValue.getOctetString());
-			    byte[] extVal = derValue2.getOctetString();
+			    byte extVal[] = new byte[extension.length - 4];
+			    System.arraycopy(extension, 4, extVal, 0, extVal.length);
 			    
 			    if (Arrays.equals(extVal, (byte[]) value)) {
-				matchResult.add(c);
+			        matchResult.add(c);
 			    }
-			} catch (IOException ex) { }
 		    }
 		    break;
 		case MATCH_CERTIFICATE:

Modified: xml/security/trunk/src_unitTests/org/apache/xml/security/test/ModuleTest.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/org/apache/xml/security/test/ModuleTest.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src_unitTests/org/apache/xml/security/test/ModuleTest.java (original)
+++ xml/security/trunk/src_unitTests/org/apache/xml/security/test/ModuleTest.java Wed Jul 21 16:50:39 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright  2004 The Apache Software Foundation.
+ * Copyright  2004-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -62,6 +62,7 @@ public class ModuleTest extends TestCase
       suite.addTest(org.apache.xml.security.test.keys.content.x509.XMLX509CertificateTest.suite());
       suite.addTest(org.apache.xml.security.test.keys.storage.KeyStoreResolverTest.suite());
       suite.addTest(org.apache.xml.security.test.keys.storage.StorageResolverTest.suite());
+      suite.addTest(org.apache.xml.security.test.version.VersionTest.suite());
       // suite.addTest(org.apache.xml.security.test.algorithms.implementations.KeyWrapTest.suite());
       // suite.addTest(org.apache.xml.security.test.algorithms.implementations.BlockEncryptionTest.suite());
       //J+

Modified: xml/security/trunk/src_unitTests/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src_unitTests/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java (original)
+++ xml/security/trunk/src_unitTests/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java Wed Jul 21 16:50:39 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 The Apache Software Foundation.
+ * Copyright 2009-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -26,24 +26,37 @@ import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.xml.security.algorithms.SignatureAlgorithm;
+import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.signature.XMLSignature;
 import org.w3c.dom.Document;
 
 public class SignatureAlgorithmTest extends TestCase {
+    
+    /** {@link org.apache.commons.logging} logging facility */
+    static org.apache.commons.logging.Log log = 
+        org.apache.commons.logging.LogFactory.getLog(SignatureAlgorithmTest.class.getName());
 
 	static {
 	    org.apache.xml.security.Init.init();
 	}
 
-	public void testSameKeySeveralAlgorithSigning() throws Exception {
+	public void testSameKeySeveralAlgorithmSigning() throws Exception {
 		Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
 		SignatureAlgorithm signatureAlgorithm = new SignatureAlgorithm(doc,XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
 		PrivateKey pk=KeyPairGenerator.getInstance("RSA").genKeyPair().getPrivate();
 		signatureAlgorithm.initSign(pk);
 		signatureAlgorithm.update((byte)2);
 		signatureAlgorithm.sign();
-		SignatureAlgorithm otherSignatureAlgorithm = new SignatureAlgorithm(doc,XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256);
-		otherSignatureAlgorithm.initSign(pk);
+		SignatureAlgorithm otherSignatureAlgorithm =
+             new SignatureAlgorithm(doc, XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256);
+
+		try {
+		    otherSignatureAlgorithm.initSign(pk);
+		} catch (XMLSecurityException ex) {
+            log.warn("Test testSameKeySeveralAlgorithmSigning skipped as necessary algorithms not available");
+            return;
+        }
+		    
 		otherSignatureAlgorithm.update((byte)2);
 		otherSignatureAlgorithm.sign();
 	}

Modified: xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/EncryptContentTest.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/EncryptContentTest.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/EncryptContentTest.java (original)
+++ xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/EncryptContentTest.java Wed Jul 21 16:50:39 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright  2007-2009 The Apache Software Foundation.
+ * Copyright  2007-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,6 +17,10 @@
 package org.apache.xml.security.test.encryption;
 
 import java.io.ByteArrayInputStream;
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
 import javax.crypto.SecretKey;
 import javax.crypto.SecretKeyFactory;
 import javax.crypto.spec.DESedeKeySpec;
@@ -28,6 +32,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.xml.security.algorithms.JCEMapper;
 import org.apache.xml.security.encryption.XMLCipher;
 
 import junit.framework.Test;
@@ -35,6 +40,10 @@ import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 public class EncryptContentTest extends TestCase {
+    
+    /** {@link org.apache.commons.logging} logging facility */
+    static org.apache.commons.logging.Log log = 
+        org.apache.commons.logging.LogFactory.getLog(EncryptContentTest.class.getName());
 
     private static final String DATA =
 	"<users>\n" +
@@ -48,6 +57,7 @@ public class EncryptContentTest extends 
 
     private DocumentBuilder db;
     private SecretKey secretKey;
+    private boolean haveISOPadding;
 
     public static Test suite() throws Exception {
         return new TestSuite(EncryptContentTest.class);
@@ -71,9 +81,31 @@ public class EncryptContentTest extends 
 
 	TransformerFactory tf = TransformerFactory.newInstance();
 	tf.newTransformer();
+	
+	// Determine if we have ISO 10126 Padding - needed for Bulk AES or
+	// 3DES encryption
+
+	haveISOPadding = false;
+	String algorithmId = 
+	    JCEMapper.translateURItoJCEID(org.apache.xml.security.utils.EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128);
+
+	if (algorithmId != null) {
+	    try {
+	        if (Cipher.getInstance(algorithmId) != null)
+	            haveISOPadding = true;
+	    } catch (NoSuchAlgorithmException nsae) {
+	    } catch (NoSuchPaddingException nspe) {
+	    }
+	}
+
     }
 
     public void testContentRemoved() throws Exception {
+        
+        if (!haveISOPadding) {
+            log.warn("Test testContentRemoved skipped as necessary algorithms not available");
+            return;
+        }
 
 	Document doc = db.parse(new ByteArrayInputStream(DATA.getBytes("UTF8")));
 	NodeList dataToEncrypt = doc.getElementsByTagName("user");

Modified: xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java?rev=966311&r1=966310&r2=966311&view=diff
==============================================================================
--- xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java (original)
+++ xml/security/trunk/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java Wed Jul 21 16:50:39 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2007 The Apache Software Foundation.
+ * Copyright 1999-2010 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -664,6 +664,12 @@ public class XMLCipherTester extends Tes
 	}
 
     public void testSerializedData() throws Exception {
+        
+        if (!haveISOPadding) {
+            log.warn("Test testSerializedData skipped as necessary algorithms not available");
+            return;
+        }
+        
         byte[] bits128 = {
             (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13,
             (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17,

Added: xml/security/trunk/src_unitTests/org/apache/xml/security/test/version/VersionTest.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src_unitTests/org/apache/xml/security/test/version/VersionTest.java?rev=966311&view=auto
==============================================================================
--- xml/security/trunk/src_unitTests/org/apache/xml/security/test/version/VersionTest.java (added)
+++ xml/security/trunk/src_unitTests/org/apache/xml/security/test/version/VersionTest.java Wed Jul 21 16:50:39 2010
@@ -0,0 +1,102 @@
+/*
+ * Copyright  2010 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.xml.security.test.version;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.security.Provider;
+import java.security.Security;
+
+/**
+ * Version test.
+ */
+public class VersionTest extends TestCase {
+
+	public VersionTest() {
+		super("VersionTest");
+	}
+
+	public VersionTest(String name) {
+		super(name);
+	}
+
+	public static Test suite() {
+		return new TestSuite(VersionTest.class);
+	}
+	
+	/**
+	 * A unit test for the algorithm below to convert a version number
+	 * to a double.
+	 */
+	public void testConvertVersion() throws Exception {
+	    String version = convertVersion("1.4.4");
+	    assertTrue("1.44".equals(version));
+	    
+	    version = convertVersion("1.4.4-SNAPSHOT");
+        assertTrue("1.44".equals(version));
+        
+        version = convertVersion("1.4");
+        assertTrue("1.4".equals(version));
+	}
+
+	public void testVersion() throws Exception {
+	    Security.addProvider(new org.jcp.xml.dsig.internal.dom.XMLDSigRI());
+	    
+	    Provider provider = Security.getProvider("XMLDSig");
+        assertTrue(provider != null);
+        
+	    String version = System.getProperty("product.version");
+	    assertTrue(version != null);
+	    
+	    version = convertVersion(version);
+	    
+	    double versionD = Double.parseDouble(version);
+	    assertTrue(versionD == provider.getVersion());
+	    
+	    String info = "Apache Santuario XMLDSig " + 
+            "(DOM XMLSignatureFactory; DOM KeyInfoFactory)";
+	    
+	    assertTrue(info.equals(provider.getInfo()));
+	}
+	
+	/**
+	 * Convert the version to a number that can be parsed to a double.
+	 * Namely, remove the "-SNAPSHOT" from the end, and convert version
+	 * numbers like 1.4.4 to 1.44.
+	 */
+	private String convertVersion(String version) {
+	    
+	    // Remove the "-SNAPSHOT" version if it exists
+        int dash = version.indexOf('-');
+        if (dash != -1) {
+            version = version.substring(0, dash);
+        }
+        
+        // Remove the second decimal point if it exists
+        int lastDot = version.lastIndexOf('.');
+        if (version.indexOf('.') != lastDot) {
+            String prefix = version.substring(0, lastDot);
+            String suffix = version.substring(lastDot + 1, version.length());
+            version = prefix.concat(suffix);
+        }
+        
+        return version;
+	}
+	
+}