summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-07-05 08:26:12 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-07-05 08:26:12 +0000
commitf07051ecf40f234baf3f6b7f897abc0322dda4d4 (patch)
tree06e59590d442ea69eb911176993cdad9ab9e8d65 /sca-java-2.x/trunk/modules/binding-ws-runtime-axis2
parente14213fce7c1427b333d3f19c7bcc362cb020d98 (diff)
TUSCANY-3881 - Tidy up the binding context and test by re-enabling Rampart support in the ws binding so that WS policy can be applied. For the time being it only demonstrates integrity.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1142920 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws-runtime-axis2')
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF2
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml234
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProvider.java67
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProviderFactory.java57
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java95
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java24
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java41
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory1
8 files changed, 480 insertions, 41 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
index 7a0c6dc64a..61c5ab01dd 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/META-INF/MANIFEST.MF
@@ -91,9 +91,11 @@ Import-Package: javax.servlet,
org.apache.axis2.description,
org.apache.axis2.engine,
org.apache.axis2.handlers,
+ org.apache.axis2.i18n,
org.apache.axis2.receivers,
org.apache.axis2.transport,
org.apache.axis2.transport.http,
+ org.apache.axis2.util,
org.apache.axis2.util.threadpool,
org.apache.commons.httpclient,
org.apache.commons.httpclient.params,
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml
index 7de2b6f2a0..a5b33a8451 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/pom.xml
@@ -71,16 +71,238 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.rampart</groupId>
+ <artifactId>rampart-core</artifactId>
+ <version>1.5.1</version>
+ <exclusions>
+ <!--
+ We can live without most of the Rampart dependencies. The following
+ jars were added to Tuscany support Rampart
+
+ axiom-dom-1.2.10.jar,
+ mex-1.5.4-impl.jar,
+ not-yet-commons-ssl-0.3.9.jar,
+ opensaml-2.2.3.jar,
+ openws-1.2.2.jar,
+ rampart-core-1.5.1.jar,
+ rampart-policy-1.5.1.jar,
+ rampart-trust-1.5.1.jar,
+ wss4j-1.5.10.jar,
+ xmlsec-1.4.4.jar,
+ xmltooling-1.2.0.jar
+ -->
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>addressing</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.opensaml</groupId>
+ <artifactId>opensaml1</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>bouncycastle</groupId>
+ <artifactId>bcprov-jdk14</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-ext-jdk15</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.jcip</groupId>
+ <artifactId>jcip-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jargs</groupId>
+ <artifactId>jargs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>resolver</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>serializer</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.santuario</groupId>
+ <artifactId>xmlsec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- replace the Rampart xmlsec with the version Tuscany is using -->
+ <dependency>
+ <groupId>org.apache.santuario</groupId>
+ <artifactId>xmlsec</artifactId>
+ <version>1.4.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ <version>2.2.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.jcip</groupId>
+ <artifactId>jcip-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-ext-jdk15</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.commons.ssl</groupId>
+ <artifactId>not-yet-commons-ssl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jargs</groupId>
+ <artifactId>jargs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>resolver</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xerces</groupId>
+ <artifactId>serializer</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- replace the Rampart xalan with the version Tuscany is using -->
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
- <exclusions>
+ <exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- </exclusion>
+ </exclusion>
</exclusions>
</dependency>
@@ -101,10 +323,12 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-stax-api_1.0_spec</artifactId>
</exclusion>
+ <!-- needed by rampart
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
+ -->
</exclusions>
</dependency>
@@ -150,6 +374,12 @@
<version>2.5</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-wspolicy</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
<!-- Runtime dependencies -->
<dependency>
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProvider.java
new file mode 100644
index 0000000000..12f3d81c98
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProvider.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2.policy.wspolicy;
+
+import java.util.logging.Logger;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider;
+import org.apache.tuscany.sca.host.http.SecurityContext;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy;
+import org.apache.tuscany.sca.policy.wspolicy.WSPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev: 918583 $ $Date: 2010-03-03 17:16:15 +0000 (Wed, 03 Mar 2010) $
+ */
+public class WSPolicyProvider extends BasePolicyProvider<WSPolicy> {
+ private final Logger logger = Logger.getLogger(WSPolicyProvider.class.getName());
+
+ public WSPolicyProvider(PolicySubject subject) {
+ super(WSPolicy.class, subject);
+ }
+
+ public void configureBinding(Object context) {
+ ConfigurationContext configContext = ((Axis2BaseBindingProvider)context).getAxisConfigurationContext();
+
+ for ( Object policy : findPolicies() ) {
+ if ( policy instanceof WSPolicy ) {
+ WSPolicy wsPolicy = (WSPolicy)policy;
+ try {
+ configContext.getAxisConfiguration().applyPolicy(wsPolicy.getNeethiPolicy());
+ configContext.getAxisConfiguration().engageModule("rampart");
+
+ // TUSCANY-2824
+ // hack to make service side pick up rampart policies
+ // "rampartPolicy" comes from RampartMessageData.KEY_RAMPART_POLICY
+ // but I'm avoiding adding an explicit dependency just yet.
+ // There must be a proper way of getting rampart to recognize
+ // these policies
+ configContext.setProperty("rampartPolicy", wsPolicy.getNeethiPolicy());
+
+ } catch ( AxisFault e ) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProviderFactory.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProviderFactory.java
new file mode 100644
index 0000000000..fc4879c0d9
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProviderFactory.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2.policy.wspolicy;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.wspolicy.WSPolicy;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev: 916317 $ $Date: 2010-02-25 15:16:44 +0000 (Thu, 25 Feb 2010) $
+ */
+public class WSPolicyProviderFactory implements PolicyProviderFactory<WSPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public WSPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new WSPolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new WSPolicyProvider(endpoint);
+ }
+
+ public Class<WSPolicy> getModelType() {
+ return WSPolicy.class;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
index 8fc5befc78..e25f5768e5 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java
@@ -19,7 +19,9 @@
package org.apache.tuscany.sca.binding.ws.axis2.provider;
+import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
@@ -49,16 +51,24 @@ import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentErrorMsgs;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.ModuleBuilder;
import org.apache.axis2.deployment.URLBasedAxisConfigurator;
import org.apache.axis2.deployment.util.Utils;
import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.AxisModule;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.Version;
import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
import org.apache.axis2.description.WSDL2Constants;
import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.i18n.Messages;
import org.apache.tuscany.sca.assembly.AbstractContract;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
@@ -135,21 +145,20 @@ public class Axis2EngineIntegration {
try {
axis2Config = AccessController.doPrivileged(new PrivilegedExceptionAction<Axis2Config>() {
public Axis2Config run() throws AxisFault, MalformedURLException {
- // collect together the classloaders that Axis2 requireds in order to load
- // pluggable items such as the Tuscany MessageReceivers and the xerces
+ // collect together the classloaders that Axis2 requires in order to load
+ // pluggable items such as the Tuscany MessageReceivers and the Xerces
// document builder.
ClassLoader wsBindingCL = getClass().getClassLoader();
ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader();
- ClassLoaderContext classLoaderContext =
- new ClassLoaderContext(wsBindingCL, axis2CL);
+ ClassLoaderContext classLoaderContext = new ClassLoaderContext(wsBindingCL, axis2CL);
- classLoaderContext =
- new ClassLoaderContext(classLoaderContext.getClassLoader(), serviceDiscovery,
- XMLInputFactory.class, DocumentBuilderFactory.class);
+ classLoaderContext = new ClassLoaderContext(classLoaderContext.getClassLoader(),
+ serviceDiscovery,
+ XMLInputFactory.class,
+ DocumentBuilderFactory.class);
- URL axis2xmlURL =
- wsBindingCL
- .getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml");
+ URL axis2xmlURL = wsBindingCL.getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml");
+
if (axis2xmlURL != null) {
URL repositoryURL = new URL(axis2xmlURL, "../repository/");
Axis2Config config = new Axis2Config();
@@ -190,9 +199,73 @@ public class Axis2EngineIntegration {
} catch (PrivilegedActionException e) {
throw new ServiceRuntimeException(e.getException());
}
-
}
+ // Some code to programatically load an Axis2 module only if we need it
+ // currently hard coded to load rampart only. Needs generalization
+ public synchronized static void loadRampartModule(ConfigurationContext axis2ConfigContext) {
+ try {
+ final AxisConfiguration axisConfiguration = axis2ConfigContext.getAxisConfiguration();
+ final URL rampartURL = new URL(axis2Config.repositoryURL.toString() + "modules/rampart-1.4.mar");
+
+ ClassLoader deploymentClassLoader = org.apache.axis2.deployment.util.Utils.createClassLoader(
+ new URL[]{rampartURL},
+ axisConfiguration.getModuleClassLoader(),
+ true,
+ (File) axisConfiguration.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR));
+
+ final AxisModule module = new AxisModule();
+ module.setModuleClassLoader(deploymentClassLoader);
+ module.setParent(axisConfiguration);
+
+ if (module.getName() == null) {
+ module.setName("rampart-1.4");
+ module.setVersion(new Version("1.4"));
+ }
+
+ populateModule(axis2ConfigContext, module, rampartURL);
+ module.setFileName(rampartURL);
+
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws IOException {
+ DeploymentEngine.addNewModule(module, axisConfiguration);
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (AxisFault)e.getException();
+ }
+
+ org.apache.axis2.util.Utils.calculateDefaultModuleVersion(axisConfiguration.getModules(),
+ axisConfiguration);
+ axisConfiguration.validateSystemPredefinedPhases();
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ private static void populateModule(ConfigurationContext axis2ConfigContext, AxisModule module, URL moduleUrl) throws DeploymentException {
+ try {
+ ClassLoader classLoader = module.getModuleClassLoader();
+ InputStream moduleStream = classLoader.getResourceAsStream("META-INF/module.xml");
+ if (moduleStream == null) {
+ moduleStream = classLoader.getResourceAsStream("meta-inf/module.xml");
+ }
+ if (moduleStream == null) {
+ throw new DeploymentException(Messages.getMessage(DeploymentErrorMsgs.MODULE_XML_MISSING, moduleUrl.toString()));
+ }
+ ModuleBuilder moduleBuilder = new ModuleBuilder(moduleStream, module, axis2ConfigContext.getAxisConfiguration());
+ moduleBuilder.populateModule();
+ } catch (IOException e) {
+ throw new DeploymentException(e);
+ }
+ }
+
//=========================================================
/**
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
index fb9bcb12f8..7b22dc443b 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
@@ -64,6 +64,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.policy.util.PolicyHelper;
import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
import org.apache.tuscany.sca.provider.PolicyProvider;
@@ -108,17 +109,18 @@ public class Axis2ReferenceBindingProvider extends Axis2BaseBindingProvider impl
contract.getInterface().resetDataBinding(OMElement.class.getName());
}
- isSOAP11Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP11_INTENT);
- isSOAP12Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP12_INTENT);
+ // TODO - why don't intents get aggregated to EPR correctly?
+ isSOAP11Required = PolicyHelper.isIntentRequired((PolicySubject)wsBinding, Constants.SOAP11_INTENT);
+ isSOAP12Required = PolicyHelper.isIntentRequired((PolicySubject)wsBinding, Constants.SOAP12_INTENT);
- isMTOMRequired = PolicyHelper.isIntentRequired(wsBinding, Axis2BindingProviderFactory.MTOM_INTENT);
+ isMTOMRequired = PolicyHelper.isIntentRequired((PolicySubject)wsBinding, Axis2BindingProviderFactory.MTOM_INTENT);
- // TODO - this is not correct as there may be other, custom, policies that
- // require rampart. For example this is not going to pick up the case
- // of external policy attachment
- isRampartRequired = PolicyHelper.isIntentRequired(wsBinding, Constants.AUTHENTICATION_INTENT) ||
- PolicyHelper.isIntentRequired(wsBinding, Constants.CONFIDENTIALITY_INTENT) ||
- PolicyHelper.isIntentRequired(wsBinding, Constants.INTEGRITY_INTENT);
+ // if the endpoint contains any WS Policy expressions then we probably need rampart
+ // TODO - need to take into account Axis configuration policy also
+ QName wsPolicyQName = new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "Policy");
+ if (PolicyHelper.getPolicies(endpointReference, wsPolicyQName).size() > 0){
+ isRampartRequired = true;
+ }
// Validate the configuration for provided policies
@@ -167,6 +169,10 @@ public class Axis2ReferenceBindingProvider extends Axis2BaseBindingProvider impl
// Apply the configuration from any other policies
+ if (isRampartRequired){
+ Axis2EngineIntegration.loadRampartModule(configContext);
+ }
+
for (PolicyProvider pp : this.endpointReference.getPolicyProviders()) {
pp.configureBinding(this);
}
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
index 6e860752cf..00b3a113fb 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
@@ -23,6 +23,7 @@ import java.net.URISyntaxException;
import java.util.logging.Logger;
import javax.wsdl.Port;
+import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
@@ -35,6 +36,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.policy.util.PolicyHelper;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
@@ -90,24 +92,18 @@ public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implem
configContext.setContextRoot(servletHost.getContextPath());
// Determine the configuration from the bindings "mayProvides" intents
-
- isSOAP12Required = PolicyHelper.isIntentRequired(wsBinding, Constants.SOAP12_INTENT);
-
- isMTOMRequired = PolicyHelper.isIntentRequired(wsBinding, Axis2BindingProviderFactory.MTOM_INTENT);
-
- // this is not correct as there may be other, custom, policies that
- // require rampart. For example this is not going to pick up the case
- // of external policy attachment
- isRampartRequired = PolicyHelper.isIntentRequired(wsBinding, Constants.AUTHENTICATION_INTENT) ||
- PolicyHelper.isIntentRequired(wsBinding, Constants.CONFIDENTIALITY_INTENT) ||
- PolicyHelper.isIntentRequired(wsBinding, Constants.INTEGRITY_INTENT);
-
-
- // Apply the configuration from any other policies
-
- for (PolicyProvider pp : endpoint.getPolicyProviders()) {
- pp.configureBinding(this);
- }
+ // TODO - why don't intents get aggregated to EP correctly?
+ isSOAP12Required = PolicyHelper.isIntentRequired((PolicySubject)wsBinding, Constants.SOAP12_INTENT);
+
+ isMTOMRequired = PolicyHelper.isIntentRequired((PolicySubject)wsBinding, Axis2BindingProviderFactory.MTOM_INTENT);
+
+ // if the endpoint contains any WS Policy expressions then we probably need rampart
+ // TODO - need to take into account Axis configuration policy also
+ QName wsPolicyQName = new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "Policy");
+ if (PolicyHelper.getPolicies(endpoint, wsPolicyQName).size() > 0){
+ isRampartRequired = true;
+ }
+
// Update port addresses with runtime information
// We can safely assume there is only one port here because you configure
@@ -142,7 +138,7 @@ public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implem
// Apply the configuration from the mayProvides intents
if (isRampartRequired){
- // TODO - do we need to go back to configurator?
+ Axis2EngineIntegration.loadRampartModule(configContext);
}
if (isMTOMRequired) {
@@ -152,6 +148,7 @@ public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implem
if (isJMSRequired){
// TODO - do we need to go back to configurator?
}
+
wsBinding.setURI(deployedURI);
// Check the WSDL style as we only support some of them
@@ -178,6 +175,12 @@ public class Axis2ServiceBindingProvider extends Axis2BaseBindingProvider implem
public void start() {
try {
createAxisService(deployedURI, wsdlPort);
+
+ // Apply the configuration from any other policies
+
+ for (PolicyProvider pp : endpoint.getPolicyProviders()) {
+ pp.configureBinding(this);
+ }
if (deployedURI.startsWith("http://") ||
deployedURI.startsWith("https://") ||
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
index ae1acbd541..35a7eba505 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
+++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -18,3 +18,4 @@
# Implementation class for binding-ws-runtime-axis2 specific policy extensions
org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.BasicAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy
org.apache.tuscany.sca.binding.ws.axis2.policy.security.http.ssl.HTTPSPolicyProviderFactory;model=org.apache.tuscany.sca.policy.security.http.ssl.HTTPSPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.wspolicy.WSPolicyProviderFactory;model=org.apache.tuscany.sca.policy.wspolicy.WSPolicy