cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1356822 - /cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
Date Tue, 03 Jul 2012 16:46:26 GMT
Author: sergeyb
Date: Tue Jul  3 16:46:26 2012
New Revision: 1356822

URL: http://svn.apache.org/viewvc?rev=1356822&view=rev
Log:
TLSParameterJaxBUtils needs to use ResourceManager to locate the store resources if ClassLoaderUtils
can not locate them

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java?rev=1356822&r1=1356821&r2=1356822&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
(original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
Tue Jul  3 16:46:26 2012
@@ -39,6 +39,8 @@ import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.security.CertStoreType;
@@ -46,6 +48,7 @@ import org.apache.cxf.configuration.secu
 import org.apache.cxf.configuration.security.KeyStoreType;
 import org.apache.cxf.configuration.security.SecureRandomParameters;
 import org.apache.cxf.configuration.security.TrustManagersType;
+import org.apache.cxf.resource.ResourceManager;
 
 /**
  * This class provides some functionality to convert the JAXB
@@ -121,8 +124,7 @@ public final class TLSParameterJaxBUtils
         if (kst.isSetFile()) {
             keyStore.load(new FileInputStream(kst.getFile()), password);
         } else if (kst.isSetResource()) {
-            final java.io.InputStream is =
-                ClassLoaderUtils.getResourceAsStream(kst.getResource(), kst.getClass());
+            final java.io.InputStream is = getResourceAsStream(kst.getResource());
             if (is == null) {
                 final String msg =
                     "Could not load keystore resource " + kst.getResource();
@@ -157,8 +159,7 @@ public final class TLSParameterJaxBUtils
             return createTrustStore(new FileInputStream(pst.getFile()));
         }
         if (pst.isSetResource()) {
-            final java.io.InputStream is =
-                ClassLoaderUtils.getResourceAsStream(pst.getResource(), pst.getClass());
+            final java.io.InputStream is = getResourceAsStream(pst.getResource());
             if (is == null) {
                 final String msg =
                     "Could not load truststore resource " + pst.getResource();
@@ -174,6 +175,18 @@ public final class TLSParameterJaxBUtils
         return null;
     }
 
+    private static InputStream getResourceAsStream(String resource) {
+        InputStream is = ClassLoaderUtils.getResourceAsStream(resource, TLSParameterJaxBUtils.class);
+        if (is == null) {
+            Bus bus = BusFactory.getThreadDefaultBus(true);
+            ResourceManager rm = bus.getExtension(ResourceManager.class);
+            if (rm != null) {
+                is = rm.getResourceAsStream(resource);
+            }
+        }
+        return is;
+    }
+    
     /**
      * Create a KeyStore containing the trusted CA certificates contained
      * in the supplied input stream.



Mime
View raw message