ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1603452 - /webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/WSProviderConfig.java
Date Wed, 18 Jun 2014 13:56:19 GMT
Author: coheigea
Date: Wed Jun 18 13:56:18 2014
New Revision: 1603452

URL: http://svn.apache.org/r1603452
Log:
Get WSS4J working with the latest Santuario SNAPSHOT

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/WSProviderConfig.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/WSProviderConfig.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/WSProviderConfig.java?rev=1603452&r1=1603451&r2=1603452&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/WSProviderConfig.java
(original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/WSProviderConfig.java
Wed Jun 18 13:56:18 2014
@@ -67,7 +67,16 @@ public final class WSProviderConfig {
                 AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
                     public Boolean run() {
                         addXMLDSigRIInternal();
-                        addJceProvider("BC", "org.bouncycastle.jce.provider.BouncyCastleProvider");
+                        String bcProviderStr = 
+                            addJceProvider("BC", "org.bouncycastle.jce.provider.BouncyCastleProvider");
+                        // If we have BouncyCastle v1.49 installed then use IvParameterSpec
in
+                        // Santuario. This can be removed when we pick up BouncyCastle 1.51+
+                        if (bcProviderStr != null) {
+                            Provider bcProvider = Security.getProvider(bcProviderStr);
+                            if (bcProvider.getInfo().contains("v1.49")) {
+                                useIvParameterSpec();
+                            }
+                        }
                         return true;
                     }
                 });
@@ -122,6 +131,24 @@ public final class WSProviderConfig {
         }
     }
     
+    private static void useIvParameterSpec() {
+        try {
+            // Don't override if it was set explicitly
+            AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    String ivParameterSpec = "org.apache.xml.security.cipher.gcm.useIvParameterSpec";
+                    if (System.getProperty(ivParameterSpec) == null) {
+                        System.setProperty(ivParameterSpec, "true");
+                        return false;
+                    }
+                    return true; 
+                }
+            });
+        } catch (Throwable t) { //NOPMD
+            //ignore
+        }
+    }
+    
     private static void addXMLDSigRIInternal() {
         Security.removeProvider("ApacheXMLDSig");
         addJceProvider("ApacheXMLDSig", SantuarioUtil.getSantuarioProvider());



Mime
View raw message