summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2008-12-05 09:33:33 +0000
committeredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2008-12-05 09:33:33 +0000
commit73edd945c4222e07e79df6e471fedb385c966ea4 (patch)
tree66ca22124963b1e3f18c245f147d004c34032935
parent43ac32cddc99869701d0668f06cb1baa6c53eb90 (diff)
Changes to match new 2.0 core interfaces, plus adding back the contents of the /authentication folder which was left out of the migration to the 2.0 stream
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@723690 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF65
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java56
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java113
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java75
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java100
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java90
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java94
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java88
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java4
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java4
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java10
11 files changed, 662 insertions, 37 deletions
diff --git a/java/sca/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF b/java/sca/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF
index 0fe5e5af3e..24f0f4f117 100644
--- a/java/sca/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF
+++ b/java/sca/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF
@@ -1,20 +1,18 @@
Manifest-Version: 1.0
Export-Package: org.apache.tuscany.sca.binding.ws.axis2.policy.configu
- ration;uses:="org.apache.axis2,org.apache.tuscany.sca.runtime,org.apa
- che.tuscany.sca.assembly,org.apache.tuscany.sca.provider,org.apache.t
- uscany.sca.core,org.apache.axis2.context,org.apache.tuscany.sca.monit
- or,org.apache.tuscany.sca.policy,javax.xml.namespace,org.apache.axiom
- .om,org.apache.axis2.description,javax.xml.stream,org.apache.axis2.en
- gine,org.apache.tuscany.sca.contribution.resolver,org.apache.tuscany.
- sca.policy.util,org.apache.tuscany.sca.contribution.processor,org.oso
- a.sca";version="1.4",org.apache.tuscany.sca.binding.ws.axis2.policy.a
- uthentication.basic;uses:="org.apache.tuscany.sca.runtime,org.apache.
- tuscany.sca.assembly,org.apache.tuscany.sca.provider,org.apache.tusca
- ny.sca.core,org.apache.tuscany.sca.policy,org.apache.tuscany.sca.moni
- tor,org.apache.tuscany.sca.interfacedef,javax.xml.namespace,org.apach
- e.tuscany.sca.invocation,javax.xml.stream,org.apache.tuscany.sca.cont
- ribution.resolver,org.apache.tuscany.sca.contribution.processor";vers
- ion="1.4"
+ ration;uses:="org.apache.axis2,org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core,org.apache.axis2.context,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ javax.xml.namespace,org.apache.axiom.om,
+ org.apache.axis2.description,javax.xml.stream,
+ org.apache.axis2.engine,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.policy.util,
+ org.apache.tuscany.sca.contribution.processor,
+ org.osoa.sca";version="1.4"
Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany Policy Model for Axis2 WS binding
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
@@ -24,20 +22,29 @@ Bnd-LastModified: 1225397340328
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany Policy Model for Axis2 WS binding
-Import-Package: javax.xml.namespace;version="1.0",javax.xml.stream;ver
- sion="1.0",org.apache.axiom.om,org.apache.axis2,org.apache.axis2.cont
- ext,org.apache.axis2.description,org.apache.axis2.engine,org.apache.t
- uscany.sca.assembly;version="1.4",org.apache.tuscany.sca.binding.ws.a
- xis2.policy.authentication.basic;version="1.4",org.apache.tuscany.sca
- .binding.ws.axis2.policy.configuration;version="1.4",org.apache.tusca
- ny.sca.contribution.processor;version="1.4",org.apache.tuscany.sca.co
- ntribution.resolver;version="1.4",org.apache.tuscany.sca.core;version
- ="1.4",org.apache.tuscany.sca.interfacedef;version="1.4",org.apache.t
- uscany.sca.invocation;version="1.4",org.apache.tuscany.sca.monitor;ve
- rsion="1.4",org.apache.tuscany.sca.policy;version="1.4",org.apache.tu
- scany.sca.policy.util;version="1.4",org.apache.tuscany.sca.provider;v
- ersion="1.4",org.apache.tuscany.sca.runtime;version="1.4",org.osoa.sc
- a;version="1.4"
+Import-Package: javax.xml.namespace,
+ javax.xml.stream;version="1.0",
+ org.apache.axiom.om,
+ org.apache.axis2,
+ org.apache.axis2.context,
+ org.apache.axis2.description,
+ org.apache.axis2.engine,
+ org.apache.tuscany.sca.assembly;version="1.4",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.basic;v
+ ersion="1.4",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.configuration;version=
+ "1.4",
+ org.apache.tuscany.sca.contribution.processor;version="1.4",
+ org.apache.tuscany.sca.contribution.resolver;version="1.4",
+ org.apache.tuscany.sca.core;version="1.4",
+ org.apache.tuscany.sca.interfacedef;version="1.4",
+ org.apache.tuscany.sca.invocation;version="1.4",
+ org.apache.tuscany.sca.monitor;version="1.4",
+ org.apache.tuscany.sca.policy;version="1.4",
+ org.apache.tuscany.sca.policy.util;version="1.4",
+ org.apache.tuscany.sca.provider;version="1.4",
+ org.apache.tuscany.sca.runtime;version="1.4",
+ org.osoa.sca;version="1.4"
Bundle-SymbolicName: org.apache.tuscany.sca.policy.security.ws
Bundle-DocURL: http://www.apache.org/
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java
new file mode 100644
index 0000000000..c0ef6297a1
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java
@@ -0,0 +1,56 @@
+/*
+ * 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.token;
+
+import javax.xml.namespace.QName;
+
+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: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $
+ */
+public class Axis2TokenAuthenticationPolicy implements Policy {
+ public static final QName AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "axis2TokenAuthentication");
+ public static final String AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME = "tokenName";
+
+ private QName tokenName;
+
+ public QName getTokenName() {
+ return tokenName;
+ }
+
+ public void setTokenName(QName tokenName) {
+ this.tokenName = tokenName;
+ }
+
+ public QName getSchemaName() {
+ return AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java
new file mode 100644
index 0000000000..6cc55255d0
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java
@@ -0,0 +1,113 @@
+/*
+ * 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.token;
+
+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.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ *
+ * Adjusted for 2.0 environment, Mike Edwards, 4th Dec 2008
+ * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $
+ */
+public class Axis2TokenAuthenticationPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Axis2TokenAuthenticationPolicy> {
+
+ public QName getArtifactType() {
+ return Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public Axis2TokenAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ }
+
+
+ public Axis2TokenAuthenticationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ Axis2TokenAuthenticationPolicy policy = new Axis2TokenAuthenticationPolicy();
+ 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.setTokenName(getQName(reader, Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_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(Axis2TokenAuthenticationPolicy 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.getTokenName() != null ) {
+ writer.writeStartElement(prefix,
+ Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME,
+ getArtifactType().getNamespaceURI());
+ writer.writeCharacters(policy.getTokenName().toString());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<Axis2TokenAuthenticationPolicy> getModelType() {
+ return Axis2TokenAuthenticationPolicy.class;
+ }
+
+ public void resolve(Axis2TokenAuthenticationPolicy 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/token/Axis2TokenAuthenticationPolicyProviderFactory.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..805d6f80cb
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.token;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+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;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $
+ */
+public class Axis2TokenAuthenticationPolicyProviderFactory implements PolicyProviderFactory<Axis2TokenAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public Axis2TokenAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ * @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 TokenAuthenticationImplementationPolicyProvider(component, implementation);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createReferencePolicyProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return new Axis2TokenAuthenticationReferencePolicyProvider(component, reference, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding)
+ */
+ public PolicyProvider createServicePolicyProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return new Axis2TokenAuthenticationServicePolicyProvider(component, service, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..cc6708d6fa
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java
@@ -0,0 +1,100 @@
+/*
+ * 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.token;
+
+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.binding.ws.axis2.policy.header.Axis2SOAPHeaderString;
+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;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev: 698457 $ $Date: 2008-09-24 09:13:02 +0100 (Wed, 24 Sep 2008) $
+ */
+public class Axis2TokenAuthenticationReferencePolicyInterceptor implements Interceptor {
+
+ private Invoker next;
+ private Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private Axis2TokenAuthenticationPolicy policy;
+
+ public Axis2TokenAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof Axis2TokenAuthenticationPolicy){
+ policy = (Axis2TokenAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // could call out here to some 3rd party system to get credentials
+
+ if ( policy.getTokenName() != null){
+ // create Axis representation of header
+ Axis2SOAPHeaderString header = new Axis2SOAPHeaderString();
+ header.setHeaderName(policy.getTokenName());
+ header.setHeaderString("SomeWSAuthorizationToken");
+
+ // add header to Tuscany message
+ msg.getHeaders().add(header);
+ }
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java
new file mode 100644
index 0000000000..06a94bfae3
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java
@@ -0,0 +1,90 @@
+/*
+ * 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.token;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+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;
+
+/**
+ * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $
+ */
+public class Axis2TokenAuthenticationReferencePolicyProvider implements PolicyProvider {
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private Binding binding;
+
+ public Axis2TokenAuthenticationReferencePolicyProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ super();
+ this.component = component;
+ this.reference = reference;
+ this.binding = binding;
+ }
+
+ private PolicySet findPolicySet() {
+ if (binding instanceof PolicySetAttachPoint) {
+ List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return "component.reference: " + component.getURI()
+ + "#"
+ + reference.getName()
+ + "("
+ + 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 Axis2TokenAuthenticationReferencePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+ */
+ public String getPhase() {
+ return Phase.REFERENCE_POLICY;
+ }
+
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java
new file mode 100644
index 0000000000..c9833016f0
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java
@@ -0,0 +1,94 @@
+/*
+ * 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.token;
+
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeader;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString;
+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.PolicySet;
+import org.apache.tuscany.sca.policy.SecurityUtil;
+import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev: 721811 $ $Date: 2008-11-30 13:46:51 +0000 (Sun, 30 Nov 2008) $
+ */
+public class Axis2TokenAuthenticationServicePolicyInterceptor implements Interceptor {
+ private Invoker next;
+ private Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private Axis2TokenAuthenticationPolicy policy;
+
+ public Axis2TokenAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof Axis2TokenAuthenticationPolicy){
+ policy = (Axis2TokenAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ Axis2SOAPHeaderString header = (Axis2SOAPHeaderString)Axis2HeaderPolicyUtil.getHeader(msg, policy.getTokenName());
+
+ if (header != null) {
+ System.out.println("Web service received token: " + header.getHeaderString());
+
+ // call out here to some 3rd party system to do whatever you
+ // need to turn header credentials into an authenticated principal
+
+ Subject subject = SecurityUtil.getSubject(msg);
+ Principal principal = new TokenPrincipal(header.getHeaderString());
+ subject.getPrincipals().add(principal);
+ }
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java
new file mode 100644
index 0000000000..e7af6f0ab7
--- /dev/null
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java
@@ -0,0 +1,88 @@
+/*
+ * 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.token;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+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;
+
+/**
+ * @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $
+ */
+public class Axis2TokenAuthenticationServicePolicyProvider implements PolicyProvider {
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private Binding binding;
+
+ public Axis2TokenAuthenticationServicePolicyProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) {
+ super();
+ this.component = component;
+ this.service = service;
+ this.binding = binding;
+ }
+
+ private PolicySet findPolicySet() {
+ if (binding instanceof PolicySetAttachPoint) {
+ List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return "component.service: " + component.getURI()
+ + "#"
+ + service.getName()
+ + "("
+ + 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 Axis2TokenAuthenticationServicePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+ */
+ public String getPhase() {
+ return Phase.SERVICE_POLICY;
+ }
+
+}
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
index fa26fedc9e..8d08a3f78e 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
@@ -24,6 +24,7 @@ import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.xml.Constants;
import org.apache.tuscany.sca.policy.Policy;
/**
@@ -33,8 +34,7 @@ import org.apache.tuscany.sca.policy.Policy;
* @version $Rev$ $Date$
*/
public class Axis2ConfigParamPolicy implements Policy {
- private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
- public static final QName NAME = new QName(SCA10_TUSCANY_NS, "wsConfigParam");
+ public static final QName NAME = new QName(Constants.SCA10_TUSCANY_NS, "wsConfigParam");
private Map<String, OMElement> paramElements = new Hashtable<String, OMElement>();
public Map<String, OMElement> getParamElements() {
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
index 33a1688138..59b103809d 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
@@ -30,6 +30,8 @@ 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.assembly.xml.Constants;
+
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
@@ -64,7 +66,7 @@ public class Axis2ConfigParamPolicyProcessor implements StAXArtifactProcessor<Ax
case START_ELEMENT : {
name = reader.getName();
if ( PARAMETER.equals(name.getLocalPart()) ) {
- paramName = reader.getAttributeValue(null, "name");
+ paramName = reader.getAttributeValue(null, Constants.NAME);
parameterElement = loadElement(reader);
policy.getParamElements().put(paramName, parameterElement);
}
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
index 3466b9def7..c5c4b673bf 100644
--- 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
@@ -29,13 +29,13 @@ 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.core.FactoryExtensionPoint;
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.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.monitor.Monitor;
/**
@@ -48,7 +48,7 @@ public class Axis2HeaderPolicyProcessor extends BaseStAXArtifactProcessor implem
return Axis2HeaderPolicy.AXIS2_HEADER_POLICY_QNAME;
}
- public Axis2HeaderPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ public Axis2HeaderPolicyProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
}