diff options
14 files changed, 549 insertions, 112 deletions
diff --git a/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE b/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE index acb4895417..0261992461 100644 --- a/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE +++ b/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE @@ -231,7 +231,9 @@ The following components come under Apache Software License 2.0 aspectjrt-1.6.8.jar
aspectjweaver-1.6.8.jar
axiom-api-1.2.10.jar
+ axiom-dom-1.2.10.jar
axiom-impl-1.2.10.jar
+ axis2-mtompolicy-1.5.4.jar
bsf-utils-3.1.jar
cglib-2.2.jar
commons-beanutils-1.7.0.jar
@@ -276,6 +278,7 @@ The following components come under Apache Software License 2.0 juli-6.0.26.jar
kahadb-5.3.0.jar
log4j-1.2.15.jar
+ mex-1.5.4-impl.jar
myfaces-api-1.2.2.jar
myfaces-impl-1.2.2.jar
neethi-2.0.4.jar
@@ -295,7 +298,12 @@ The following components come under Apache Software License 2.0 ode-scheduler-simple-1.3.2.jar
ode-utils-1.3.2.jar
openjpa-1.2.1.jar
+ opensaml-2.2.3.jar
+ openws-1.2.2.jar
org.apache.axis2.osgi-1.5.3.jar
+ rampart-core-1.5.1.jar
+ rampart-policy-1.5.1.jar
+ rampart-trust-1.5.1.jar
regexp-1.3.jar
spring-aop-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
@@ -312,10 +320,13 @@ The following components come under Apache Software License 2.0 wink-common-1.1.3-incubating.jar
wink-client-1.1.3-incubating.jar
wink-server-1.1.3-incubating.jar
+ wss4j-1.5.10.jar
xalan-2.7.0.jar
xercesImpl-2.8.1.jar
xmlbeans-2.3.0.jar
XmlSchema-1.4.3.jar
+ xmlsec-1.4.4.jar
+ xmltooling-1.2.0.jar
===============================================================================
The serp-1.13.1.jar is distributed under the BSD license with the following copyright:
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java index 8a4adb3d7f..ade541b635 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java @@ -37,7 +37,7 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @tuscany.spi.extension.asclient */ public class PolicyHelper { - public PolicySet getPolicySet(PolicySubject subject, QName policySetName) { + public static PolicySet getPolicySet(PolicySubject subject, QName policySetName) { for (PolicySet ps : subject.getPolicySets()) { if (ps.getName().equals(policySetName)) { return ps; @@ -46,7 +46,7 @@ public class PolicyHelper { return null; } - public Intent getIntent(Definitions subject, QName intentName) { + public static Intent getIntent(Definitions subject, QName intentName) { for (Intent i : subject.getIntents()) { if (i.getName().equals(intentName)) { return i; @@ -55,7 +55,7 @@ public class PolicyHelper { return null; } - public PolicySet getPolicySet(Definitions subject, QName policySetName) { + public static PolicySet getPolicySet(Definitions subject, QName policySetName) { for (PolicySet ps : subject.getPolicySets()) { if (ps.getName().equals(policySetName)) { return ps; @@ -64,7 +64,7 @@ public class PolicyHelper { return null; } - public Intent getIntent(PolicySubject subject, QName intentName) { + public static Intent getIntent(PolicySubject subject, QName intentName) { for (Intent i : subject.getRequiredIntents()) { if (i.getName().equals(intentName)) { return i; @@ -73,7 +73,7 @@ public class PolicyHelper { return null; } - public Collection<PolicyExpression> getPolicyExpressions(PolicySubject subject, QName policyName) { + public static Collection<PolicyExpression> getPolicyExpressions(PolicySubject subject, QName policyName) { Collection<PolicyExpression> policies = new ArrayList<PolicyExpression>(); for (PolicySet ps : subject.getPolicySets()) { for (PolicyExpression exp : ps.getPolicies()) { @@ -85,7 +85,7 @@ public class PolicyHelper { return policies; } - public Collection<Object> getPolicies(PolicySubject subject, QName policyName) { + public static Collection<Object> getPolicies(PolicySubject subject, QName policyName) { Collection<Object> policies = new ArrayList<Object>(); for (PolicySet ps : subject.getPolicySets()) { for (PolicyExpression exp : ps.getPolicies()) { @@ -95,36 +95,18 @@ public class PolicyHelper { } } return policies; - } - - public static PolicySet getPolicySet(Binding wsBinding, QName intentName) { - PolicySet returnPolicySet = null; - - if (wsBinding instanceof PolicySubject) { - PolicySubject policiedBinding = (PolicySubject)wsBinding; - for (PolicySet policySet : policiedBinding.getPolicySets()) { - for (Intent intent : policySet.getProvidedIntents()) { - if (intent.getName().equals(intentName)) { - returnPolicySet = policySet; - break; - } - } - } - } + } - return returnPolicySet; - } + public static boolean isIntentRequired(PolicySubject subject, QName intent) { - public static boolean isIntentRequired(Binding wsBinding, QName intent) { - if (wsBinding instanceof PolicySubject) { - List<Intent> intents = ((PolicySubject)wsBinding).getRequiredIntents(); - for (Intent i : intents) { - if (intent.equals(i.getName())) { - return true; - } + List<Intent> intents = ((PolicySubject)subject).getRequiredIntents(); + for (Intent i : intents) { + if (intent.equals(i.getName())) { + return true; } } - return getPolicySet(wsBinding, intent) != null; + + return getPolicySet(subject, intent) != null; } } 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
diff --git a/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml b/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml index 388fa4ad40..608ca2671c 100644 --- a/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml +++ b/sca-java-2.x/trunk/modules/policy-wspolicy/pom.xml @@ -36,26 +36,24 @@ <version>2.0-SNAPSHOT</version> <scope>provided</scope> </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-assembly-xml</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - + <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-contribution</artifactId> - <version>2.0-SNAPSHOT</version> + <groupId>org.apache.neethi</groupId> + <artifactId>neethi</artifactId> + <version>2.0.4</version> + <exclusions> + <exclusion> + <groupId>wsdl4j</groupId> + <artifactId>wsdl4j</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core-spi</artifactId> - <version>2.0-SNAPSHOT</version> - </dependency> - - <dependency> <groupId>org.apache.ws.commons.axiom</groupId> <artifactId>axiom-api</artifactId> <version>1.2.10</version> @@ -76,24 +74,12 @@ <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.neethi</groupId> - <artifactId>neethi</artifactId> - <version>2.0.4</version> - <exclusions> - <exclusion> - <groupId>wsdl4j</groupId> - <artifactId>wsdl4j</artifactId> - </exclusion> <exclusion> - <groupId>org.codehaus.woodstox</groupId> - <artifactId>wstx-asl</artifactId> - </exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-stax-api_1.0_spec</artifactId> + </exclusion> </exclusions> - </dependency> + </dependency> <dependency> <groupId>org.apache.ws.commons.axiom</groupId> @@ -105,9 +91,17 @@ <groupId>javax.mail</groupId> <artifactId>mail</artifactId> </exclusion> + <exclusion> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-stax-api_1.0_spec</artifactId> + </exclusion> </exclusions> </dependency> - +<!-- <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> @@ -119,7 +113,8 @@ <artifactId>commons-logging</artifactId> </exclusion> </exclusions> - </dependency> + </dependency> +--> </dependencies> </project> diff --git a/sca-java-2.x/trunk/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java b/sca-java-2.x/trunk/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java index 48bf932c27..cbc234bc47 100644 --- a/sca-java-2.x/trunk/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java +++ b/sca-java-2.x/trunk/modules/policy-wspolicy/src/main/java/org/apache/tuscany/sca/policy/wspolicy/xml/WSPolicyProcessor.java @@ -97,7 +97,13 @@ public class WSPolicyProcessor extends BaseStAXArtifactProcessor implements // normalize the neethi tree so we can easily identify // the policy alternatives - neethiPolicy.normalize(true); +/* Messes up the hierarchy if rampart config policies included + try { + neethiPolicy.normalize(true); + } catch (UnsupportedOperationException ex){ + // RampartConfig policies don't support this yet + } +*/ // top-level children of ExactlyOne are policy alternatives so // for each child create a policy model list and pull the @@ -138,6 +144,10 @@ public class WSPolicyProcessor extends BaseStAXArtifactProcessor implements XMLStreamWriter writer = outputFactory.createXMLStreamWriter(outputStream); policyComponent.serialize(writer); + writer.flush(); + writer.close(); + outputStream.flush(); + outputStream.close(); ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); XMLStreamReader reader = inputFactory.createXMLStreamReader(inputStream); diff --git a/sca-java-2.x/trunk/modules/pom.xml b/sca-java-2.x/trunk/modules/pom.xml index ea91532311..2e7839c0d5 100644 --- a/sca-java-2.x/trunk/modules/pom.xml +++ b/sca-java-2.x/trunk/modules/pom.xml @@ -118,13 +118,12 @@ <module>node-launcher</module> <module>node-launcher-equinox</module> <module>node-manager</module> - <module>policy-security</module> - <module>policy-wspolicy</module> - <!--module>policy-xml-ws</module--> <module>policy-logging</module> + <module>policy-security</module> <module>policy-transaction</module> <module>policy-transaction-runtime</module> - <module>policy-transaction-runtime-geronimo</module> + <module>policy-transaction-runtime-geronimo</module> + <module>policy-wspolicy</module> <module>shell</module> <module>sca-api</module> <module>sca-client-impl</module> diff --git a/sca-java-2.x/trunk/testing/itest/ws/pom.xml b/sca-java-2.x/trunk/testing/itest/ws/pom.xml index 7c984eb2eb..1bd8083c05 100644 --- a/sca-java-2.x/trunk/testing/itest/ws/pom.xml +++ b/sca-java-2.x/trunk/testing/itest/ws/pom.xml @@ -37,6 +37,7 @@ <module>endpoints</module> <module>endpoint-references</module> <module>holder-ws-service-multiple-outputs</module> + <module>wspolicy</module> <!-- <module>jms</module> <module>mtom</module> |