summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy')
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java57
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java131
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java48
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java127
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java49
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java53
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java156
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java60
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java54
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java44
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java66
-rw-r--r--sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java57
-rw-r--r--sca-java-2.x/branches/2.0/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/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProviderFactory.java57
14 files changed, 1026 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..699846ead2
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.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.authentication.basic;
+
+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.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public BasicAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new BasicAuthenticationReferencePolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new BasicAuthenticationServicePolicyProvider(endpoint);
+ }
+
+ public Class<BasicAuthenticationPolicy> getModelType() {
+ return BasicAuthenticationPolicy.class;
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..78a150b0b4
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java
@@ -0,0 +1,131 @@
+/*
+ * 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.authentication.basic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;
+import org.apache.tuscany.sca.binding.ws.axis2.context.WSAxis2BindingContext;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationReferencePolicyInterceptor implements PhasedInterceptor {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication");
+
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private BasicAuthenticationPolicy policy;
+
+ public BasicAuthenticationReferencePolicyInterceptor(String context, PolicySet policySet) {
+ super();
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ // TODO - how to get the appropriate expression out of the
+ // policy set. Need WS Policy help here
+ if (policySet != null) {
+ for (PolicyExpression policyExpression : policySet.getPolicies()){
+ if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){
+ policy = (BasicAuthenticationPolicy)policyExpression.getPolicy();
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ WSAxis2BindingContext bindingContext = msg.getBindingContext();
+ OperationClient operationClient = bindingContext.getAxisOperationClient();
+
+ String username = null;
+ String password = null;
+
+ // get the security context
+ Subject subject = SecurityUtil.getSubject(msg);
+ BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject,
+ BasicAuthenticationPrincipal.class);
+
+ // could use the security principal to look up basic auth credentials
+ if ( principal != null ) {
+ username = ((BasicAuthenticationPrincipal)principal).getName();
+ password = ((BasicAuthenticationPrincipal)principal).getPassword();
+ } else if (policy != null ){
+ username = policy.getUserName();
+ password = policy.getPassword();
+
+ principal = new BasicAuthenticationPrincipal(username,
+ password);
+ subject.getPrincipals().add(principal);
+ }
+
+ if (username == null || password == null ){
+ throw new ServiceRuntimeException("Basic authentication username and/or password is null");
+ }
+
+ HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
+ List<String> auth = new ArrayList<String>();
+ auth.add(Authenticator.BASIC);
+ authenticator.setAuthSchemes(auth);
+ authenticator.setPreemptiveAuthentication(true);
+ authenticator.setUsername(username);
+ authenticator.setPassword(password);
+
+ operationClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE,
+ authenticator);
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_POLICY;
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
new file mode 100644
index 0000000000..d4b3851d97
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
@@ -0,0 +1,48 @@
+/*
+ * 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.authentication.basic;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationReferencePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> {
+
+ public BasicAuthenticationReferencePolicyProvider(EndpointReference endpointReference) {
+ super(BasicAuthenticationPolicy.class, endpointReference);
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new BasicAuthenticationReferencePolicyInterceptor(getContext(), ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
new file mode 100644
index 0000000000..33e623135f
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
@@ -0,0 +1,127 @@
+/*
+ * 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.authentication.basic;
+
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.util.base64.Base64Utils;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.sca.binding.ws.axis2.context.WSAxis2BindingContext;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationServicePolicyInterceptor implements PhasedInterceptor {
+ private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication");
+
+ private Invoker next;
+ private PolicySet policySet = null;
+ private String context;
+ private BasicAuthenticationPolicy policy;
+
+ public BasicAuthenticationServicePolicyInterceptor(String context, PolicySet policySet) {
+ super();
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ // TODO - how to get the appropriate expression out of the
+ // policy set. Need WS Policy help here
+ if (policySet != null) {
+ for (PolicyExpression policyExpression : policySet.getPolicies()){
+ if (policyExpression.getPolicy() instanceof BasicAuthenticationPolicy){
+ policy = (BasicAuthenticationPolicy)policyExpression.getPolicy();
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ WSAxis2BindingContext bindingContext = msg.getBindingContext();
+ MessageContext messageContext = bindingContext.getAxisInMessageContext();
+
+ Map httpHeaderProperties = (Map)messageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
+
+ String basicAuthString = (String)httpHeaderProperties.get("Authorization");
+ String decodedBasicAuthString = null;
+ String username = null;
+ String password = null;
+
+ if (basicAuthString != null) {
+ basicAuthString = basicAuthString.trim();
+
+ if (basicAuthString.startsWith("Basic ")) {
+ decodedBasicAuthString = new String(Base64Utils.decode(basicAuthString.substring(6)));
+ }
+
+ int collonIndex = decodedBasicAuthString.indexOf(':');
+
+ if (collonIndex == -1){
+ username = decodedBasicAuthString;
+ } else {
+ username = decodedBasicAuthString.substring(0, collonIndex);
+ password = decodedBasicAuthString.substring(collonIndex + 1);
+ }
+ }
+
+ // get the security context
+ Subject subject = SecurityUtil.getSubject(msg);
+ BasicAuthenticationPrincipal principal = new BasicAuthenticationPrincipal(username,
+ password);
+ subject.getPrincipals().add(principal);
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_POLICY;
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
new file mode 100644
index 0000000000..ec4536c309
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
@@ -0,0 +1,49 @@
+/*
+ * 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.authentication.basic;
+
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationServicePolicyProvider extends BasePolicyProvider<BasicAuthenticationPolicy> {
+
+ public BasicAuthenticationServicePolicyProvider(Endpoint endpoint) {
+ super(BasicAuthenticationPolicy.class, endpoint);
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ PolicySet ps = findPolicySet();
+ return ps == null ? null : new BasicAuthenticationServicePolicyInterceptor(getContext(), ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
new file mode 100644
index 0000000000..ded09392ec
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
@@ -0,0 +1,53 @@
+/*
+ * 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.configuration;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicy {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName NAME = new QName(SCA11_TUSCANY_NS, "wsConfigParam");
+ private Map<String, OMElement> paramElements = new Hashtable<String, OMElement>();
+
+ public Map<String, OMElement> getParamElements() {
+ return paramElements;
+ }
+
+ public QName getSchemaName() {
+ return NAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
new file mode 100644
index 0000000000..c13c009edf
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
@@ -0,0 +1,156 @@
+/*
+ * 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.configuration;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyProcessor implements StAXArtifactProcessor<Axis2ConfigParamPolicy> {
+ public static final QName AXIS2_CONFIG_PARAM_POLICY_QNAME = Axis2ConfigParamPolicy.NAME;
+ public static final String PARAMETER = "parameter";
+ public QName getArtifactType() {
+ return AXIS2_CONFIG_PARAM_POLICY_QNAME;
+ }
+
+ public Axis2ConfigParamPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ public Axis2ConfigParamPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Axis2ConfigParamPolicy policy = new Axis2ConfigParamPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+ OMElement parameterElement = null;
+ String paramName = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( PARAMETER.equals(name.getLocalPart()) ) {
+ paramName = reader.getAttributeValue(null, "name");
+ parameterElement = loadElement(reader);
+ policy.getParamElements().put(paramName, parameterElement);
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( AXIS2_CONFIG_PARAM_POLICY_QNAME.equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(Axis2ConfigParamPolicy arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<Axis2ConfigParamPolicy> getModelType() {
+ return Axis2ConfigParamPolicy.class;
+ }
+
+ public void resolve(Axis2ConfigParamPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+ private OMElement loadElement(XMLStreamReader reader) throws XMLStreamException {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement head = fac.createOMElement(reader.getName());
+ OMElement current = head;
+ while (true) {
+ switch (reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ //since the axis2 code checks against a no namespace we need to generate accordingly
+ QName name = new QName(reader.getName().getLocalPart());
+ OMElement child = fac.createOMElement(name, current);
+
+ int count = reader.getNamespaceCount();
+ for (int i = 0; i < count; i++) {
+ String prefix = reader.getNamespacePrefix(i);
+ String ns = reader.getNamespaceURI(i);
+ child.declareNamespace(ns, prefix);
+ }
+
+ if(!"".equals(name.getNamespaceURI())) {
+ child.declareNamespace(name.getNamespaceURI(), name.getPrefix());
+ }
+
+ // add the attributes for this element
+ count = reader.getAttributeCount();
+ for (int i = 0; i < count; i++) {
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ if (ns != null) {
+ child.addAttribute(qname, value, fac.createOMNamespace(ns, prefix));
+ child.declareNamespace(ns, prefix);
+ } else {
+ child.addAttribute(qname, value, null);
+ }
+ }
+ current = child;
+ break;
+ case XMLStreamConstants.CDATA:
+ fac.createOMText(current, reader.getText());
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ fac.createOMText(current, reader.getText());
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if ( current == head ) {
+ return head;
+ } else {
+ current = (OMElement)current.getParent();
+ }
+ }
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java
new file mode 100644
index 0000000000..a77f71b734
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProvider.java
@@ -0,0 +1,60 @@
+/*
+ * 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.configuration;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.tuscany.sca.binding.ws.axis2.provider.Axis2BaseBindingProvider;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyProvider extends BasePolicyProvider<Axis2ConfigParamPolicy> {
+
+ public Axis2ConfigParamPolicyProvider(PolicySubject subject) {
+ super(Axis2ConfigParamPolicy.class, subject);
+ }
+
+ public void configureBinding(Object context) {
+ ConfigurationContext configurationContext = ((Axis2BaseBindingProvider)context).getAxisConfigurationContext();
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
+ Parameter configParam = null;
+ for (Object policy : findPolicies()) {
+ if (policy instanceof Axis2ConfigParamPolicy) {
+ axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy;
+ for (String paramName : axis2ConfigParamPolicy.getParamElements().keySet()) {
+ configParam =
+ new Parameter(paramName, axis2ConfigParamPolicy.getParamElements().get(paramName)
+ .getFirstElement());
+ configParam.setParameterElement(axis2ConfigParamPolicy.getParamElements().get(paramName));
+ try {
+ configurationContext.getAxisConfiguration().addParameter(configParam);
+ } catch (AxisFault e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java
new file mode 100644
index 0000000000..c4c93cd33d
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java
@@ -0,0 +1,54 @@
+/*
+ * 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.configuration;
+
+
+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.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyProviderFactory implements PolicyProviderFactory<Axis2ConfigParamPolicy> {
+
+ public Axis2ConfigParamPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new Axis2ConfigParamPolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new Axis2ConfigParamPolicyProvider(endpoint);
+ }
+
+ public Class<Axis2ConfigParamPolicy> getModelType() {
+ return Axis2ConfigParamPolicy.class;
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java
new file mode 100644
index 0000000000..e27da2bbd1
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/mtom/Axis2MTOMPolicyProvider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.mtom;
+
+import org.apache.axis2.Constants.Configuration;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2MTOMPolicyProvider extends BasePolicyProvider<Object> {
+
+ public Axis2MTOMPolicyProvider(PolicySubject subject) {
+ super(Object.class, subject);
+ }
+
+ public void configureBinding(Object configuration) {
+
+ if (configuration instanceof ConfigurationContext){
+ ConfigurationContext configurationContext = (ConfigurationContext)configuration;
+ configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false);
+ configurationContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true");
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java
new file mode 100644
index 0000000000..8355c0fa4e
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProvider.java
@@ -0,0 +1,66 @@
+/*
+ * 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.security.http.ssl;
+
+import java.util.logging.Logger;
+
+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.provider.BasePolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HTTPSPolicyProvider extends BasePolicyProvider<HTTPSPolicy> {
+ private final Logger logger = Logger.getLogger(HTTPSPolicyProvider.class.getName());
+
+ public HTTPSPolicyProvider(PolicySubject subject) {
+ super(HTTPSPolicy.class, subject);
+ }
+
+ public void configureBinding(Object context) {
+ SecurityContext securityContext = ((Axis2BaseBindingProvider)context).getHttpSecurityContext();
+
+ for (Object policy : findPolicies()) {
+ if (policy instanceof HTTPSPolicy) {
+ HTTPSPolicy httpsPolicy = (HTTPSPolicy)policy;
+
+ securityContext.setSSLEnabled(true);
+ securityContext.setSSLProperties(httpsPolicy.toProperties());
+
+ // TODO - what is the right way to set trust/key store on client side?
+
+ logger.info("HTTPSPolicyProvider: Setting JVM trust store to " + httpsPolicy.getTrustStore());
+ System.setProperty("javax.net.ssl.trustStore", httpsPolicy.getTrustStore());
+ System.setProperty("javax.net.ssl.trustStorePassword", httpsPolicy.getTrustStorePassword());
+ System.setProperty("javax.net.ssl.trustStoreType", httpsPolicy.getTrustStoreType());
+
+ logger.info("HTTPSPolicyProvider: Setting JVM key store to " + httpsPolicy.getKeyStore());
+ System.setProperty("javax.net.ssl.keyStore", httpsPolicy.getKeyStore());
+ System.setProperty("javax.net.ssl.keyStorePassword", httpsPolicy.getKeyStorePassword());
+ System.setProperty("javax.net.ssl.keyStoreType", httpsPolicy.getKeyStoreType());
+
+ return;
+ }
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.java
new file mode 100644
index 0000000000..592300aaa3
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/security/http/ssl/HTTPSPolicyProviderFactory.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.security.http.ssl;
+
+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.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HTTPSPolicyProviderFactory implements PolicyProviderFactory<BasicAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public HTTPSPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new HTTPSPolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new HTTPSPolicyProvider(endpoint);
+ }
+
+ public Class<BasicAuthenticationPolicy> getModelType() {
+ return BasicAuthenticationPolicy.class;
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProvider.java b/sca-java-2.x/branches/2.0/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/branches/2.0/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/branches/2.0/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/wspolicy/WSPolicyProviderFactory.java b/sca-java-2.x/branches/2.0/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/branches/2.0/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;
+ }
+
+}