summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-ws-axis2-policy/src
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
commit5f3869c451e46aadc943d00087d6847877dd1c50 (patch)
treee22baaff1fb9ea42606b7d04af52e032e3bc03bc /java/sca/modules/binding-ws-axis2-policy/src
parent60744a36aae604ac3c4499ed54f1082ab8f5947d (diff)
Merging the 1.x delta on top of the equinox based modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-ws-axis2-policy/src')
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProcessor.java125
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java (renamed from java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicy.java)35
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java114
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java (renamed from java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProviderFactory.java)12
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java50
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java (renamed from java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationReferencePolicyInterceptor.java)34
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java (renamed from java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationReferencePolicyProvider.java)11
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java (renamed from java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationServicePolicyInterceptor.java)23
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java (renamed from java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationServicePolicyProvider.java)12
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java60
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java60
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor3
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory3
13 files changed, 351 insertions, 191 deletions
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProcessor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProcessor.java
deleted file mode 100644
index 1856830e49..0000000000
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProcessor.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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 static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-import static org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicy.AXIS2_BASIC_AUTHENTICATION_PASSWORD;
-import static org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicy.AXIS2_BASIC_AUTHENTICATION_POLICY_QNAME;
-import static org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicy.AXIS2_BASIC_AUTHENTICATION_USERNAME;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-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.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class Axis2BasicAuthenticationPolicyProcessor implements StAXArtifactProcessor<Axis2BasicAuthenticationPolicy> {
-
- public QName getArtifactType() {
- return Axis2BasicAuthenticationPolicy.AXIS2_BASIC_AUTHENTICATION_POLICY_QNAME;
- }
-
- public Axis2BasicAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- }
-
-
- public Axis2BasicAuthenticationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
- Axis2BasicAuthenticationPolicy policy = new Axis2BasicAuthenticationPolicy();
- int event = reader.getEventType();
- QName name = null;
-
- while (reader.hasNext()) {
- event = reader.getEventType();
- switch (event) {
- case START_ELEMENT : {
- name = reader.getName();
- if ( name.equals(getArtifactType()) ) {
- // no attributes at the moment
- } else if ( AXIS2_BASIC_AUTHENTICATION_USERNAME.equals(name.getLocalPart()) ) {
- policy.setUserName(reader.getElementText());
- } else if ( AXIS2_BASIC_AUTHENTICATION_PASSWORD.equals(name.getLocalPart()) ) {
- policy.setPassword(reader.getElementText());
- }
- break;
- }
- }
-
- if ( event == END_ELEMENT ) {
- if ( getArtifactType().equals(reader.getName()) ) {
- break;
- }
- }
-
- //Read the next element
- if (reader.hasNext()) {
- reader.next();
- }
- }
-
- return policy;
- }
-
- public void write(Axis2BasicAuthenticationPolicy policy, XMLStreamWriter writer)
- throws ContributionWriteException, XMLStreamException {
- String prefix = "tuscany";
- writer.writeStartElement(prefix,
- getArtifactType().getLocalPart(),
- getArtifactType().getNamespaceURI());
- writer.writeNamespace("tuscany", AXIS2_BASIC_AUTHENTICATION_POLICY_QNAME.getNamespaceURI());
-
- if ( policy.getUserName() != null ) {
- writer.writeStartElement(prefix,
- AXIS2_BASIC_AUTHENTICATION_USERNAME,
- getArtifactType().getNamespaceURI());
- writer.writeCharacters(policy.getUserName());
- writer.writeEndElement();
- }
-
- if ( policy.getPassword() != null ) {
- writer.writeStartElement(prefix,
- AXIS2_BASIC_AUTHENTICATION_PASSWORD,
- getArtifactType().getNamespaceURI());
- writer.writeCharacters(policy.getPassword());
- writer.writeEndElement();
- }
-
- writer.writeEndElement();
- }
-
- public Class<Axis2BasicAuthenticationPolicy> getModelType() {
- return Axis2BasicAuthenticationPolicy.class;
- }
-
- public void resolve(Axis2BasicAuthenticationPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
-
- }
-
-}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
index 5aaea5a7a8..244e501901 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicy.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
@@ -16,10 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.policy.Policy;
/**
@@ -28,34 +29,22 @@ import org.apache.tuscany.sca.policy.Policy;
*
* @version $Rev$ $Date$
*/
-public class Axis2BasicAuthenticationPolicy implements Policy {
- private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
- public static final QName AXIS2_BASIC_AUTHENTICATION_POLICY_QNAME = new QName(SCA10_TUSCANY_NS, "axis2BasicAuthentication");
- public static final String AXIS2_BASIC_AUTHENTICATION_USERNAME = "username";
- public static final String AXIS2_BASIC_AUTHENTICATION_PASSWORD = "password";
- public static final String AXIS2_BASIC_AUTHENTICATION_HTTP_HEADER = "httpheader";
+public class Axis2HeaderPolicy implements Policy {
+ public static final QName AXIS2_HEADER_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "axis2Header");
+ public static final String AXIS2_HEADER_NAME = "headerName";
- private String userName;
- private String password;
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
+ private QName headerName;
+
+ public QName getHeaderName() {
+ return headerName;
}
- public String getPassword() {
- return password;
+ public void setHeaderName(QName headerName) {
+ this.headerName = headerName;
}
- public void setPassword(String password) {
- this.password = password;
- }
-
public QName getSchemaName() {
- return AXIS2_BASIC_AUTHENTICATION_POLICY_QNAME;
+ return AXIS2_HEADER_POLICY_QNAME;
}
public boolean isUnresolved() {
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java
new file mode 100644
index 0000000000..3466b9def7
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java
@@ -0,0 +1,114 @@
+/*
+ * 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.header;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.logging.Level;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Axis2HeaderPolicy> {
+
+ public QName getArtifactType() {
+ return Axis2HeaderPolicy.AXIS2_HEADER_POLICY_QNAME;
+ }
+
+ public Axis2HeaderPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ }
+
+
+ public Axis2HeaderPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ Axis2HeaderPolicy policy = new Axis2HeaderPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( name.equals(getArtifactType()) ) {
+ policy.setHeaderName(getQName(reader, Axis2HeaderPolicy.AXIS2_HEADER_NAME));
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( getArtifactType().equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(Axis2HeaderPolicy policy, XMLStreamWriter writer)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS);
+
+ if ( policy.getHeaderName() != null ) {
+ writer.writeStartElement(prefix,
+ Axis2HeaderPolicy.AXIS2_HEADER_NAME,
+ getArtifactType().getNamespaceURI());
+ writer.writeCharacters(policy.getHeaderName().toString());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<Axis2HeaderPolicy> getModelType() {
+ return Axis2HeaderPolicy.class;
+ }
+
+ public void resolve(Axis2HeaderPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProviderFactory.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java
index 5ec4cf9baa..71833df382 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationPolicyProviderFactory.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Implementation;
@@ -31,10 +31,10 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
* @version $Rev$ $Date$
*/
-public class Axis2BasicAuthenticationPolicyProviderFactory implements PolicyProviderFactory<Axis2BasicAuthenticationPolicy> {
+public class Axis2HeaderPolicyProviderFactory implements PolicyProviderFactory<Axis2HeaderPolicy> {
private ExtensionPointRegistry registry;
- public Axis2BasicAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ public Axis2HeaderPolicyProviderFactory(ExtensionPointRegistry registry) {
super();
this.registry = registry;
}
@@ -43,7 +43,7 @@ public class Axis2BasicAuthenticationPolicyProviderFactory implements PolicyProv
* @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation)
*/
public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) {
- return null;//new WSBasicAuthenticationImplementationPolicyProvider(component, implementation);
+ return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation);
}
/**
@@ -52,7 +52,7 @@ public class Axis2BasicAuthenticationPolicyProviderFactory implements PolicyProv
public PolicyProvider createReferencePolicyProvider(RuntimeComponent component,
RuntimeComponentReference reference,
Binding binding) {
- return new Axis2BasicAuthenticationReferencePolicyProvider(component, reference, binding);
+ return new Axis2HeaderReferencePolicyProvider(component, reference, binding);
}
/**
@@ -61,7 +61,7 @@ public class Axis2BasicAuthenticationPolicyProviderFactory implements PolicyProv
public PolicyProvider createServicePolicyProvider(RuntimeComponent component,
RuntimeComponentService service,
Binding binding) {
- return new Axis2BasicAuthenticationServicePolicyProvider(component, service, binding);
+ return new Axis2HeaderServicePolicyProvider(component, service, binding);
}
/**
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java
new file mode 100644
index 0000000000..98d011a8fc
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java
@@ -0,0 +1,50 @@
+/*
+ * 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.header;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.invocation.Message;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderPolicyUtil {
+
+ public static Axis2SOAPHeader getHeader(Message msg, QName headerName){
+
+ Axis2SOAPHeader axis2Header = null;
+
+ for (Object header : msg.getHeaders()){
+ if (header instanceof Axis2SOAPHeader){
+ Axis2SOAPHeader tmpHeader = (Axis2SOAPHeader)header;
+
+ if (tmpHeader.getHeaderName().equals(headerName)){
+ axis2Header = tmpHeader;
+ break;
+ }
+ }
+ }
+
+ return axis2Header;
+ }
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationReferencePolicyInterceptor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java
index c6344bbcbd..1b3315bb76 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationReferencePolicyInterceptor.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java
@@ -16,14 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
+
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.Policy;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -32,17 +46,14 @@ import org.apache.tuscany.sca.policy.PolicySet;
*
* @version $Rev$ $Date$
*/
-public class Axis2BasicAuthenticationReferencePolicyInterceptor implements Interceptor {
- private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
- public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication");
-
+public class Axis2HeaderReferencePolicyInterceptor implements Interceptor {
private Invoker next;
private Operation operation;
private PolicySet policySet = null;
private String context;
- private Axis2BasicAuthenticationPolicy policy;
+ private Axis2HeaderPolicy policy;
- public Axis2BasicAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ public Axis2HeaderReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
super();
this.operation = operation;
this.policySet = policySet;
@@ -53,8 +64,8 @@ public class Axis2BasicAuthenticationReferencePolicyInterceptor implements Inter
private void init() {
if (policySet != null) {
for (Object policyObject : policySet.getPolicies()){
- if (policyObject instanceof Axis2BasicAuthenticationPolicy){
- policy = (Axis2BasicAuthenticationPolicy)policyObject;
+ if (policyObject instanceof Axis2HeaderPolicy){
+ policy = (Axis2HeaderPolicy)policyObject;
break;
}
}
@@ -62,9 +73,8 @@ public class Axis2BasicAuthenticationReferencePolicyInterceptor implements Inter
}
public Message invoke(Message msg) {
- // TODO - We might use interceptors to do the Axis2 config
- // if we can change the infrastructure split the
- // invoker up
+ // TODO - not yet implemented
+
return getNext().invoke(msg);
}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationReferencePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
index b6def7af1f..0af5a09d8d 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationReferencePolicyProvider.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
import java.util.List;
@@ -27,6 +27,7 @@ import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -34,12 +35,12 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
/**
* @version $Rev$ $Date$
*/
-public class Axis2BasicAuthenticationReferencePolicyProvider implements PolicyProvider {
+public class Axis2HeaderReferencePolicyProvider implements PolicyProvider {
private RuntimeComponent component;
private RuntimeComponentReference reference;
private Binding binding;
- public Axis2BasicAuthenticationReferencePolicyProvider(RuntimeComponent component,
+ public Axis2HeaderReferencePolicyProvider(RuntimeComponent component,
RuntimeComponentReference reference,
Binding binding) {
super();
@@ -53,7 +54,7 @@ public class Axis2BasicAuthenticationReferencePolicyProvider implements PolicyPr
List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
- if (Axis2BasicAuthenticationPolicy.class.isInstance(p)) {
+ if (Axis2HeaderPolicy.class.isInstance(p)) {
return ps;
}
}
@@ -76,7 +77,7 @@ public class Axis2BasicAuthenticationReferencePolicyProvider implements PolicyPr
*/
public Interceptor createInterceptor(Operation operation) {
PolicySet ps = findPolicySet();
- return ps == null ? null : new Axis2BasicAuthenticationReferencePolicyInterceptor(getContext(), operation, ps);
+ return ps == null ? null : new Axis2HeaderReferencePolicyInterceptor(getContext(), operation, ps);
}
/**
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationServicePolicyInterceptor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java
index f6c8d072a4..a758ca5261 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationServicePolicyInterceptor.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java
@@ -16,10 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
+
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -32,17 +35,14 @@ import org.apache.tuscany.sca.policy.PolicySet;
*
* @version $Rev$ $Date$
*/
-public class Axis2BasicAuthenticationServicePolicyInterceptor implements Interceptor {
- private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
- public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication");
-
+public class Axis2HeaderServicePolicyInterceptor implements Interceptor {
private Invoker next;
private Operation operation;
private PolicySet policySet = null;
private String context;
- private Axis2BasicAuthenticationPolicy policy;
+ private Axis2HeaderPolicy policy;
- public Axis2BasicAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ public Axis2HeaderServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
super();
this.operation = operation;
this.policySet = policySet;
@@ -53,8 +53,8 @@ public class Axis2BasicAuthenticationServicePolicyInterceptor implements Interce
private void init() {
if (policySet != null) {
for (Object policyObject : policySet.getPolicies()){
- if (policyObject instanceof Axis2BasicAuthenticationPolicy){
- policy = (Axis2BasicAuthenticationPolicy)policyObject;
+ if (policyObject instanceof Axis2HeaderPolicy){
+ policy = (Axis2HeaderPolicy)policyObject;
break;
}
}
@@ -62,9 +62,8 @@ public class Axis2BasicAuthenticationServicePolicyInterceptor implements Interce
}
public Message invoke(Message msg) {
- // TODO - We might use interceptors to do the Axis2 config
- // if we can change the infrastructure split the
- // invoker up
+ // TODO - not yet implemented
+
return getNext().invoke(msg);
}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationServicePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
index 35504fddec..126073beb7 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/basic/Axis2BasicAuthenticationServicePolicyProvider.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;
+package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
import java.util.List;
@@ -27,6 +27,7 @@ import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -34,12 +35,12 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
* @version $Rev$ $Date$
*/
-public class Axis2BasicAuthenticationServicePolicyProvider implements PolicyProvider {
+public class Axis2HeaderServicePolicyProvider implements PolicyProvider {
private RuntimeComponent component;
private RuntimeComponentService service;
private Binding binding;
- public Axis2BasicAuthenticationServicePolicyProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) {
+ public Axis2HeaderServicePolicyProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) {
super();
this.component = component;
this.service = service;
@@ -51,7 +52,7 @@ public class Axis2BasicAuthenticationServicePolicyProvider implements PolicyProv
List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
- if (Axis2BasicAuthenticationPolicy.class.isInstance(p)) {
+ if (Axis2HeaderPolicy.class.isInstance(p)) {
return ps;
}
}
@@ -68,14 +69,13 @@ public class Axis2BasicAuthenticationServicePolicyProvider implements PolicyProv
+ binding.getClass().getName()
+ ")";
}
-
/**
* @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation)
*/
public Interceptor createInterceptor(Operation operation) {
PolicySet ps = findPolicySet();
- return ps == null ? null : new Axis2BasicAuthenticationReferencePolicyInterceptor(getContext(), operation, ps);
+ return ps == null ? null : new Axis2HeaderServicePolicyInterceptor(getContext(), operation, ps);
}
/**
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java
new file mode 100644
index 0000000000..7a1f26bf04
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.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.header;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.policy.Policy;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2SOAPHeader {
+
+ private QName headerName;
+
+ public QName getHeaderName() {
+ return headerName;
+ }
+
+ public void setHeaderName(QName headerName) {
+ this.headerName = headerName;
+ }
+
+ public OMElement getAsSOAPHeaderBlock(OMFactory factory) {
+ OMNamespace ns1 = factory.createOMNamespace(headerName.getNamespaceURI(),
+ headerName.getPrefix());
+ OMElement header = ((SOAPFactory)factory).createSOAPHeaderBlock(headerName.getLocalPart(),ns1);
+ return header;
+ }
+
+ public void setAsSOAPHeaderBlock(OMElement header) {
+ headerName = header.getQName();
+ }
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java
new file mode 100644
index 0000000000..0eefeac87b
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.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.header;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.policy.Policy;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2SOAPHeaderString extends Axis2SOAPHeader {
+
+ private String headerString;
+
+ public String getHeaderString() {
+ return headerString;
+ }
+
+ public void setHeaderString(String headerString) {
+ this.headerString = headerString;
+ }
+
+ public OMElement getAsSOAPHeaderBlock(OMFactory factory) {
+ OMElement header = super.getAsSOAPHeaderBlock(factory);
+ OMText headerText = factory.createOMText(header, headerString);
+ header.addChild(headerText);
+ return header;
+ }
+
+ public void setAsSOAPHeaderBlock(OMElement header) {
+ super.setAsSOAPHeaderBlock(header);
+ headerString = header.getText();
+ }
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index 7a223848fa..96782b74bf 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -17,4 +17,5 @@
# Implementation class for the artifact processor extension
org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wsConfigParam,model=org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy
-org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#axis2BasicAuthentication,model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#axis2TokenAuthentication,model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#axis2Header,model=org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
index 7d7f4299f4..ced48cf236 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -16,4 +16,5 @@
# under the License.
# Implementation class for the policy extension
-org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic.Axis2BasicAuthenticationPolicy \ No newline at end of file
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy \ No newline at end of file