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/14 10:34:08 UTC
svn commit: r1804976 - in
/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption:
BaltimoreEncTest.java DecryptionTest.java
Author: coheigea
Date: Mon Aug 14 10:34:08 2017
New Revision: 1804976
URL: http://svn.apache.org/viewvc?rev=1804976&view=rev
Log:
Fixing tests with JDK7
Modified:
santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java
santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java?rev=1804976&r1=1804975&r2=1804976&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java Mon Aug 14 10:34:08 2017
@@ -22,8 +22,11 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
+import java.lang.reflect.Constructor;
import java.security.KeyFactory;
import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.Security;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
@@ -72,6 +75,25 @@ public class BaltimoreEncTest extends or
@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();
@@ -107,6 +129,11 @@ public class BaltimoreEncTest extends or
rsaKey = keyFactory.generatePrivate(pkcs8Spec);
}
+ @org.junit.AfterClass
+ public static void cleanup() throws Exception {
+ Security.removeProvider("BC");
+ }
+
@Test
public void test_five_content_3des_cbc() throws Exception {
// Read in document
Modified: santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java?rev=1804976&r1=1804975&r2=1804976&view=diff
==============================================================================
--- santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java (original)
+++ santuario/xml-security-java/branches/2.0.x-fixes/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java Mon Aug 14 10:34:08 2017
@@ -21,12 +21,15 @@ 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.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.PrivateKey;
+import java.security.Provider;
import java.security.PublicKey;
+import java.security.Security;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
@@ -88,12 +91,37 @@ public class DecryptionTest extends Asse
@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();
xmlInputFactory.setEventAllocator(new XMLSecEventAllocator());
}
+ @org.junit.AfterClass
+ public static void cleanup() throws Exception {
+ Security.removeProvider("BC");
+ }
+
@Test
public void testDecryptElementValidation() throws Exception {
// Read in plaintext document