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 2017/08/10 16:03:58 UTC

svn commit: r1804682 - in /santuario/xml-security-java/trunk/src/test/java: javax/xml/crypto/test/dsig/ org/apache/xml/security/test/dom/encryption/ org/apache/xml/security/test/dom/keys/ org/apache/xml/security/test/dom/keys/keyresolver/ org/apache/xm...

Author: coheigea
Date: Thu Aug 10 16:03:58 2017
New Revision: 1804682

URL: http://svn.apache.org/viewvc?rev=1804682&view=rev
Log:
Removing BouncyCastle where it is not needed with Java 8

Modified:
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java
    santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java Thu Aug 10 16:03:58 2017
@@ -18,9 +18,7 @@
  */
 package javax.xml.crypto.test.dsig;
 
-import java.lang.reflect.Constructor;
 import java.security.Key;
-import java.security.Provider;
 import java.security.Security;
 import java.util.Collections;
 
@@ -68,24 +66,6 @@ public class SignatureDigestMethodTest e
     }
 
     public SignatureDigestMethodTest() throws Exception {
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection.
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 2);
-                bcInstalled = true;
-            }
-        }
 
         db = XMLUtils.createDocumentBuilder(false);
         // create common objects
@@ -117,11 +97,6 @@ public class SignatureDigestMethodTest e
         kvks = new KeySelectors.KeyValueKeySelector();
     }
 
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
-    }
-
     @org.junit.Test
     public void testSHA1() throws Exception {
         test_create_signature_enveloping(rsaSha1, sha1, rsaki,

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java Thu Aug 10 16:03:58 2017
@@ -22,16 +22,13 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
 import java.nio.charset.StandardCharsets;
 import java.security.Key;
 import java.security.KeyPairGenerator;
 import java.security.KeyPair;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivateKey;
-import java.security.Provider;
 import java.security.PublicKey;
-import java.security.Security;
 
 import javax.crypto.Cipher;
 import javax.crypto.KeyGenerator;
@@ -114,31 +111,6 @@ public class XMLCipherTest extends org.j
 
         haveKeyWraps =
             JCEMapper.translateURItoJCEID(EncryptionConstants.ALGO_ID_KEYWRAP_AES128) != null;
-
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection.
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 2);
-                bcInstalled = true;
-            }
-        }
-
-    }
-
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
     }
 
     /**

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java Thu Aug 10 16:03:58 2017
@@ -19,13 +19,10 @@
 package org.apache.xml.security.test.dom.encryption;
 
 import java.io.File;
-import java.lang.reflect.Constructor;
 import java.security.Key;
 import java.security.KeyStore;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Security;
 import java.security.cert.Certificate;
 import java.security.cert.X509Certificate;
 import java.util.Base64;
@@ -78,24 +75,6 @@ public class XMLEncryption11Test extends
      *  Constructor XMLEncryption11Test
      */
     public XMLEncryption11Test() throws Exception {
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection. If it is not available, then skip this test as it is
-        // required for GCM algorithm support
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 2);
-            }
-        }
 
         // Create the comparison strings
         String filename =
@@ -136,11 +115,6 @@ public class XMLEncryption11Test extends
         }
     }
 
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
-    }
-
     /**
      * rsa-oaep-mgf1p, Digest:SHA256, MGF:SHA1, PSource: None
      */

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java Thu Aug 10 16:03:58 2017
@@ -19,11 +19,8 @@
 package org.apache.xml.security.test.dom.keys;
 
 import java.io.FileInputStream;
-import java.lang.reflect.Constructor;
 import java.security.KeyFactory;
-import java.security.Provider;
 import java.security.PublicKey;
-import java.security.Security;
 import java.security.spec.X509EncodedKeySpec;
 import java.util.Base64;
 
@@ -54,32 +51,9 @@ public class DEREncodedKeyValueTest exte
     public DEREncodedKeyValueTest() throws Exception {
         documentBuilder = XMLUtils.createDocumentBuilder(false);
 
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection.
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 1);
-                ecKeyControl = loadPublicKey("ec.key", "EC");
-            }
-        }
-
         rsaKeyControl = loadPublicKey("rsa.key", "RSA");
         dsaKeyControl = loadPublicKey("dsa.key", "DSA");
-    }
-
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
+        ecKeyControl = loadPublicKey("ec.key", "EC");
     }
 
     @org.junit.Test
@@ -117,10 +91,6 @@ public class DEREncodedKeyValueTest exte
 
     @org.junit.Test
     public void testECPublicKeyFromElement() throws Exception {
-        if (ecKeyControl == null) {
-            return;
-        }
-
         Document doc = loadXML("DEREncodedKeyValue-EC.xml");
         NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpec11NS, Constants._TAG_DERENCODEDKEYVALUE);
         Element element = (Element) nl.item(0);
@@ -147,10 +117,6 @@ public class DEREncodedKeyValueTest exte
 
     @org.junit.Test
     public void testECPublicKeyFromKey() throws Exception {
-        if (ecKeyControl == null) {
-            return;
-        }
-
         DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), ecKeyControl);
         assertEquals(ecKeyControl, derEncodedKeyValue.getPublicKey());
         assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java Thu Aug 10 16:03:58 2017
@@ -18,10 +18,7 @@
  */
 package org.apache.xml.security.test.dom.keys.keyresolver;
 
-import java.lang.reflect.Constructor;
-import java.security.Provider;
 import java.security.PublicKey;
-import java.security.Security;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -40,38 +37,16 @@ public class DEREncodedKeyValueResolverT
     private PublicKey ecKeyControl;
 
     public DEREncodedKeyValueResolverTest() throws Exception {
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection.
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 1);
-                ecKeyControl = loadPublicKey("ec.key", "EC");
-            }
-        }
 
         rsaKeyControl = loadPublicKey("rsa.key", "RSA");
         dsaKeyControl = loadPublicKey("dsa.key", "DSA");
+        ecKeyControl = loadPublicKey("ec.key", "EC");
 
         if (!Init.isInitialized()) {
             Init.init();
         }
     }
 
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
-    }
-
     @org.junit.Test
     public void testRSAPublicKey() throws Exception {
         Document doc = loadXML("DEREncodedKeyValue-RSA.xml");
@@ -92,10 +67,6 @@ public class DEREncodedKeyValueResolverT
 
     @org.junit.Test
     public void testECPublicKey() throws Exception {
-        if (ecKeyControl == null) {
-            return;
-        }
-
         Document doc = loadXML("DEREncodedKeyValue-EC.xml");
         Element element = doc.getDocumentElement();
 

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java Thu Aug 10 16:03:58 2017
@@ -23,11 +23,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
 import java.security.KeyStore;
 import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Security;
 import java.security.cert.X509Certificate;
 
 import javax.xml.xpath.XPath;
@@ -61,27 +58,6 @@ public class ECDSASignatureTest extends
     private javax.xml.parsers.DocumentBuilder db;
 
     public ECDSASignatureTest() throws Exception {
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection. If it is not available, then skip this test as it is
-        // required for elliptic curves
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {
-                //ignore
-            }
-            if (cons == null) {
-                // BouncyCastle is not available so just return
-                return;
-            } else {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 1);
-            }
-        }
 
         //String id = "http://apache.org/xml/properties/dom/document-class-name";
         //dbf.setAttribute(id, IndexedDocument.class.getName());
@@ -90,15 +66,8 @@ public class ECDSASignatureTest extends
         org.apache.xml.security.Init.init();
     }
 
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
-    }
-
     @org.junit.Test
     public void testOne() throws Exception {
-        org.junit.Assume.assumeTrue(Security.getProvider("BC") != null);
-
         //
         // This test fails with the IBM JDK
         //
@@ -117,8 +86,6 @@ public class ECDSASignatureTest extends
     @org.junit.Test
     @org.junit.Ignore
     public void testTwo() throws Exception {
-        org.junit.Assume.assumeTrue(Security.getProvider("BC") != null);
-
         File file =
             makeDataFile("src/test/resources/org/apache/xml/security/samples/input/ecdsaSignature.xml");
         try (InputStream is = new FileInputStream(file)) {
@@ -129,8 +96,6 @@ public class ECDSASignatureTest extends
     @org.junit.Test
     @org.junit.Ignore
     public void testThree()  throws Exception {
-        org.junit.Assume.assumeTrue(Security.getProvider("BC") != null);
-
         File file = makeDataFile("src/test/resources/at/buergerkarte/testresp.xml");
         try (InputStream is = new FileInputStream(file)) {
             doVerify(is);

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java Thu Aug 10 16:03:58 2017
@@ -22,13 +22,10 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
 import java.nio.charset.StandardCharsets;
 import java.security.Key;
 import java.security.KeyStore;
 import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Security;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.Base64;
@@ -86,25 +83,6 @@ public class XMLEncryption11Test extends
     @Before
     public void setUp() throws Exception {
 
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection. If it is not available, then skip this test as it is
-        // required for GCM algorithm support
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {     //NOPMD
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 2);
-            }
-        }
-
         org.apache.xml.security.Init.init();
 
         xmlInputFactory = XMLInputFactory.newInstance();
@@ -118,11 +96,6 @@ public class XMLEncryption11Test extends
         nodeCount = countNodes(doc);
     }
 
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
-    }
-
     /**
      * rsa-oaep-mgf1p, Digest:SHA256, MGF:SHA1, PSource: None
      */

Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java?rev=1804682&r1=1804681&r2=1804682&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java Thu Aug 10 16:03:58 2017
@@ -21,11 +21,8 @@ package org.apache.xml.security.test.sta
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
 import java.security.Key;
 import java.security.KeyStore;
-import java.security.Provider;
-import java.security.Security;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.List;
@@ -66,30 +63,6 @@ public class SignatureDigestVerification
 
         xmlInputFactory = XMLInputFactory.newInstance();
         xmlInputFactory.setEventAllocator(new XMLSecEventAllocator());
-
-        //
-        // If the BouncyCastle provider is not installed, then try to load it
-        // via reflection.
-        //
-        if (Security.getProvider("BC") == null) {
-            Constructor<?> cons = null;
-            try {
-                Class<?> c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
-                cons = c.getConstructor(new Class[] {});
-            } catch (Exception e) {     //NOPMD
-                //ignore
-            }
-            if (cons != null) {
-                Provider provider = (Provider)cons.newInstance();
-                Security.insertProviderAt(provider, 2);
-                bcInstalled = true;
-            }
-        }
-    }
-
-    @org.junit.AfterClass
-    public static void cleanup() throws Exception {
-        Security.removeProvider("BC");
     }
 
     @Test