cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1040748 - in /cxf/branches/2.2.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/
Date Tue, 30 Nov 2010 20:04:09 GMT
Author: dkulp
Date: Tue Nov 30 20:04:08 2010
New Revision: 1040748

URL: http://svn.apache.org/viewvc?rev=1040748&view=rev
Log:
Merged revisions 1040739 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.3.x-fixes

................
  r1040739 | dkulp | 2010-11-30 14:53:55 -0500 (Tue, 30 Nov 2010) | 11 lines
  
  Merged revisions 1040728 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1040728 | dkulp | 2010-11-30 14:45:06 -0500 (Tue, 30 Nov 2010) | 3 lines
    
    Update to make sure the proper spring-dm application bundle classloader
    is used to load the ws-security related things like properties files and
    callbacks and such
  ........
................

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
    cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
    cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java?rev=1040748&r1=1040747&r2=1040748&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
Tue Nov 30 20:04:08 2010
@@ -62,7 +62,9 @@ public class BusApplicationContextResour
             //ignore
         }
         try {
-            if (URL.class.isAssignableFrom(resourceType)) {
+            if (ClassLoader.class.isAssignableFrom(resourceType)) {
+                return resourceType.cast(context.getClassLoader());
+            } else if (URL.class.isAssignableFrom(resourceType)) {
                 Resource r = context.getResource(resourceName);
                 if (r != null && r.exists()) {
                     return resourceType.cast(r.getURL());

Modified: cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java?rev=1040748&r1=1040747&r2=1040748&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
Tue Nov 30 20:04:08 2010
@@ -40,6 +40,7 @@ import org.apache.cxf.helpers.HttpHeader
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.security.SecurityContext;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.OperationInfo;
@@ -110,39 +111,53 @@ public class OsgiServletController exten
             } else {
                 ei = d.getEndpointInfo();
                 Bus bus = d.getBus();
-                if (null != request.getQueryString()
-                    && request.getQueryString().length() > 0
-                    && bus.getExtension(QueryHandlerRegistry.class) != null) {
-
-                    String ctxUri = request.getPathInfo();
-                    String baseUri = request.getRequestURL().toString()
-                        + "?" + request.getQueryString();
-                    // update the EndPoint Address with request url
-                    if ("GET".equals(request.getMethod())) {
-                        updateDests(request);
+                ClassLoader orig = Thread.currentThread().getContextClassLoader();
+                try {
+                    ResourceManager manager = bus.getExtension(ResourceManager.class);
+                    if (manager != null) {
+                        ClassLoader loader = manager.resolveResource("", ClassLoader.class);
+                        if (loader != null) {
+                            //need to set the context classloader to the loader of the bundle
+                            Thread.currentThread().setContextClassLoader(loader);
+                        }
                     }
-
-                    for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers())
{
-                        if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
-
-                            res.setContentType(qh.getResponseContentType(baseUri, ctxUri));
-                            OutputStream out = res.getOutputStream();
-                            try {
-                                qh.writeResponse(baseUri, ctxUri, ei, out);
-                                out.flush();
-                                return;
-                            } catch (Exception e) {
-                                LOG.warning(qh.getClass().getName()
-                                    + " Exception caught writing response: "
-                                    + e.getMessage());
-                                throw new ServletException(e);
+                    
+                    if (null != request.getQueryString()
+                        && request.getQueryString().length() > 0
+                        && bus.getExtension(QueryHandlerRegistry.class) != null)
{
+    
+                        String ctxUri = request.getPathInfo();
+                        String baseUri = request.getRequestURL().toString()
+                            + "?" + request.getQueryString();
+                        // update the EndPoint Address with request url
+                        if ("GET".equals(request.getMethod())) {
+                            updateDests(request);
+                        }
+    
+                        for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers())
{
+                            if (qh.isRecognizedQuery(baseUri, ctxUri, ei)) {
+    
+                                res.setContentType(qh.getResponseContentType(baseUri, ctxUri));
+                                OutputStream out = res.getOutputStream();
+                                try {
+                                    qh.writeResponse(baseUri, ctxUri, ei, out);
+                                    out.flush();
+                                    return;
+                                } catch (Exception e) {
+                                    LOG.warning(qh.getClass().getName()
+                                        + " Exception caught writing response: "
+                                        + e.getMessage());
+                                    throw new ServletException(e);
+                                }
                             }
                         }
+                    } else if ("/".equals(address) || address.length() == 0) {
+                        updateDests(request);
                     }
-                } else if ("/".equals(address) || address.length() == 0) {
-                    updateDests(request);
+                    invokeDestination(request, res, d);
+                } finally {
+                    Thread.currentThread().setContextClassLoader(orig);
                 }
-                invokeDestination(request, res, d);
                 
             }
         } catch (IOException e) {

Modified: cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java?rev=1040748&r1=1040747&r2=1040748&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
Tue Nov 30 20:04:08 2010
@@ -18,7 +18,9 @@
  */
 package org.apache.cxf.ws.security.wss4j;
 
+import java.io.InputStream;
 import java.net.URI;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -30,10 +32,12 @@ import javax.xml.namespace.QName;
 
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.SoapInterceptor;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.PhaseInterceptor;
+import org.apache.cxf.resource.ResourceManager;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.Crypto;
@@ -175,8 +179,7 @@ public abstract class AbstractWSS4JInter
         if (sigPropFile != null) {
             crypto = cryptoTable.get(sigPropFile);
             if (crypto == null) {
-                crypto = CryptoFactory.getInstance(sigPropFile, this
-                        .getClassLoader(reqData.getMsgContext()));
+                crypto = loadCryptoFromPropertiesFile(sigPropFile, reqData);
                 cryptoTable.put(sigPropFile, crypto);
             }
         } else if (getString(WSHandlerConstants.SIG_PROP_REF_ID, reqData
@@ -200,6 +203,37 @@ public abstract class AbstractWSS4JInter
         } 
         return crypto;
     }
+    
+    protected Crypto loadCryptoFromPropertiesFile(String propFilename, RequestData reqData)
{
+        ClassLoader orig = Thread.currentThread().getContextClassLoader();
+        try {
+            try {
+                URL url = ClassLoaderUtils.getResource(propFilename, this.getClass());
+                if (url == null) {
+                    ResourceManager manager = ((Message)reqData.getMsgContext()).getExchange()
+                            .getBus().getExtension(ResourceManager.class);
+                    ClassLoader loader = manager.resolveResource("", ClassLoader.class);
+                    if (loader != null) {
+                        Thread.currentThread().setContextClassLoader(loader);
+                    }
+                    url = manager.resolveResource(propFilename, URL.class);
+                }
+                if (url != null) {
+                    Properties props = new Properties();
+                    InputStream in = url.openStream(); 
+                    props.load(in);
+                    in.close();
+                    return CryptoFactory.getInstance(props,
+                                                     this.getClassLoader(reqData.getMsgContext()));
+                }
+            } catch (Exception e) {
+                //ignore
+            } 
+            return CryptoFactory.getInstance(propFilename, this.getClassLoader(reqData.getMsgContext()));
+        } finally {
+            Thread.currentThread().setContextClassLoader(orig);
+        }
+    }
 
     protected Crypto loadDecryptionCrypto(RequestData reqData) 
         throws WSSecurityException {
@@ -210,8 +244,7 @@ public abstract class AbstractWSS4JInter
         if (decPropFile != null) {
             crypto = cryptoTable.get(decPropFile);
             if (crypto == null) {
-                crypto = CryptoFactory.getInstance(decPropFile, this
-                        .getClassLoader(reqData.getMsgContext()));
+                crypto = loadCryptoFromPropertiesFile(decPropFile, reqData);
                 cryptoTable.put(decPropFile, crypto);
             }
         } else if (getString(WSHandlerConstants.DEC_PROP_REF_ID, reqData
@@ -249,8 +282,7 @@ public abstract class AbstractWSS4JInter
         if (encPropFile != null) {
             crypto = cryptoTable.get(encPropFile);
             if (crypto == null) {
-                crypto = CryptoFactory.getInstance(encPropFile, this
-                        .getClassLoader(reqData.getMsgContext()));
+                crypto = loadCryptoFromPropertiesFile(encPropFile, reqData);
                 cryptoTable.put(encPropFile, crypto);
             }
         } else if (getString(WSHandlerConstants.ENC_PROP_REF_ID, reqData



Mime
View raw message