Author: asoldano
Date: 2013-09-11 10:49:26 -0400 (Wed, 11 Sep 2013)
New Revision: 17912
Modified:
stack/cxf/trunk/modules/resources/src/main/resources/modules/wildfly800/org/jboss/as/webservices/server/integration/main/module.xml
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
Log:
[JBWS-3703] Early initialize WSSConfig and set dependency to org.bouncycastle module
Modified:
stack/cxf/trunk/modules/resources/src/main/resources/modules/wildfly800/org/jboss/as/webservices/server/integration/main/module.xml
===================================================================
---
stack/cxf/trunk/modules/resources/src/main/resources/modules/wildfly800/org/jboss/as/webservices/server/integration/main/module.xml 2013-09-11
10:59:44 UTC (rev 17911)
+++
stack/cxf/trunk/modules/resources/src/main/resources/modules/wildfly800/org/jboss/as/webservices/server/integration/main/module.xml 2013-09-11
14:49:26 UTC (rev 17912)
@@ -88,6 +88,7 @@
<module name="com.sun.xml.messaging.saaj"
services="export" export="true"/>
<module name="org.apache.ws.security" export="true"/>
<module name="org.apache.santuario.xmlsec"
export="true"/>
+ <module name="org.bouncycastle" export="true"/>
<module name="org.springframework.spring" optional="true"
export="true">
<imports>
<include path="META-INF"/>
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java 2013-09-11
10:59:44 UTC (rev 17911)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java 2013-09-11
14:49:26 UTC (rev 17912)
@@ -21,6 +21,13 @@
*/
package org.jboss.wsf.stack.cxf.config;
+import static org.jboss.wsf.stack.cxf.Loggers.ROOT_LOGGER;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.ws.security.WSSConfig;
+import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.management.StackConfig;
import org.jboss.wsf.spi.management.StackConfigFactory;
@@ -41,6 +48,28 @@
class CXFStackConfig implements StackConfig
{
+
+ public CXFStackConfig()
+ {
+ final ClassLoader orig = getContextClassLoader();
+ //try early configuration of xmlsec engine through WSS4J:
+ //* to avoid doing this later when the TCCL won't have visibility over the
xmlsec internals
+ //* to make sure any ws client will also have full xmlsec functionalities setup (BC
enabled, etc.)
+ try
+ {
+
setContextClassLoader(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
+ WSSConfig.init();
+ }
+ catch (Exception e)
+ {
+ ROOT_LOGGER.couldNotInitSecurityEngine();
+ ROOT_LOGGER.errorGettingWSSConfig(e);
+ }
+ finally
+ {
+ setContextClassLoader(orig);
+ }
+ }
public String getImplementationTitle()
{
@@ -52,4 +81,50 @@
return getClass().getPackage().getImplementationVersion();
}
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the classloader
+ */
+ private static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
}
\ No newline at end of file
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2013-09-11
10:59:44 UTC (rev 17911)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2013-09-11
14:49:26 UTC (rev 17912)
@@ -38,7 +38,6 @@
import org.apache.cxf.resource.ResourceResolver;
import org.apache.cxf.transport.http.HttpDestinationFactory;
import org.apache.cxf.transport.servlet.ServletDestinationFactory;
-import org.apache.ws.security.WSSConfig;
import org.jboss.ws.api.binding.BindingCustomization;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
@@ -163,17 +162,6 @@
}
}
}
- //try early configuration of xmlsec engine through WSS4J to avoid doing this
- //later when the TCCL won't have visibility over the xmlsec internals
- try
- {
- WSSConfig.getNewInstance();
- }
- catch (Exception e)
- {
- DEPLOYMENT_LOGGER.couldNotInitSecurityEngine();
- DEPLOYMENT_LOGGER.errorGettingWSSConfig(e);
- }
configured = true;
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2013-09-11
10:59:44 UTC (rev 17911)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2013-09-11
14:49:26 UTC (rev 17912)
@@ -92,7 +92,7 @@
BusHolder holder = null;
//set the runtime classloader (pointing to the deployment unit) to allow CXF
accessing to the classes;
- //use origClassLoader (which on AS7 is set to ASIL aggregation module's
classloader by TCCLDeploymentProcessClassLoader) as
+ //use origClassLoader (which on AS7 is set to ASIL aggregation module's
classloader by TCCLDeploymentProcessor) as
//parent to make sure user provided libs in the deployment do no mess up the WS
endpoint's deploy if they duplicates
//libraries already available on the application server modules.
SecurityActions.setContextClassLoader(new
DelegateClassLoader(dep.getRuntimeClassLoader(), origClassLoader));
Show replies by date