You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2008/09/15 14:24:32 UTC

svn commit: r695452 - in /tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy: authentication/token/ header/

Author: slaws
Date: Mon Sep 15 05:24:31 2008
New Revision: 695452

URL: http://svn.apache.org/viewvc?rev=695452&view=rev
Log:
Add files missed from previous policy commit

Added:
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java   (with props)
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java   (with props)
Modified:
    tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java

Modified: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java?rev=695452&r1=695451&r2=695452&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java (original)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java Mon Sep 15 05:24:31 2008
@@ -22,10 +22,7 @@
 import java.security.Principal;
 
 import javax.security.auth.Subject;
-import javax.xml.namespace.QName;
 
-import org.apache.axiom.om.OMElement;
-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;
@@ -33,7 +30,6 @@
 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.basic.BasicAuthenticationPrincipal;
 import org.apache.tuscany.sca.policy.authentication.token.TokenPrincipal;
 
 /**

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java Mon Sep 15 05:24:31 2008
@@ -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.header;
+
+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$ $Date$
+ */
+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 QName headerName;
+
+    public QName getHeaderName() {
+        return headerName;
+    }
+    
+    public void setHeaderName(QName headerName) {
+        this.headerName = headerName;
+    }
+    
+    public QName getSchemaName() {
+        return AXIS2_HEADER_POLICY_QNAME;
+    }
+
+    public boolean isUnresolved() {
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+    }
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java Mon Sep 15 05:24:31 2008
@@ -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 {
+
+    }
+    
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java Mon Sep 15 05:24:31 2008
@@ -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.header;
+
+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$ $Date$
+ */
+public class Axis2HeaderPolicyProviderFactory implements PolicyProviderFactory<Axis2HeaderPolicy> {
+    private ExtensionPointRegistry registry;
+    
+    public Axis2HeaderPolicyProviderFactory(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 Axis2HeaderReferencePolicyProvider(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 Axis2HeaderServicePolicyProvider(component, service, binding);
+    }
+
+    /**
+     * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+     */
+    public Class getModelType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java Mon Sep 15 05:24:31 2008
@@ -0,0 +1,104 @@
+/*
+ * 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 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;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderReferencePolicyInterceptor implements Interceptor {
+    private Invoker next;
+    private Operation operation;
+    private PolicySet policySet = null;
+    private String context;
+    private Axis2HeaderPolicy policy;
+
+    public Axis2HeaderReferencePolicyInterceptor(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 Axis2HeaderPolicy){
+                    policy = (Axis2HeaderPolicy)policyObject;
+                    break;
+                }
+            }
+        }
+    }
+
+    public Message invoke(Message msg) {
+        // could call out here to some 3rd party system to get credentials
+        
+        if ( policy.getHeaderName() != null){
+            // create Axis representation of header
+            //OMElement header = SOAPFactory
+            
+            OMFactory factory = OMAbstractFactory.getOMFactory();
+            OMNamespace ns1 = factory.createOMNamespace(policy.getHeaderName().getNamespaceURI(),
+                                                        policy.getHeaderName().getPrefix());
+            OMElement header = factory.createOMElement(policy.getHeaderName().getLocalPart(),ns1);
+            OMText headerText = factory.createOMText(header,"SomeAuthTokenText");
+            header.addChild(headerText);
+    
+            // add header to Tuscany message
+            msg.getHeaders().put(policy.getHeaderName().toString(),
+                                 policy);  
+        }
+        
+        return getNext().invoke(msg);
+    }
+
+    public Invoker getNext() {
+        return next;
+    }
+
+    public void setNext(Invoker next) {
+        this.next = next;
+    }
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java Mon Sep 15 05:24:31 2008
@@ -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.header;
+
+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$ $Date$
+ */
+public class Axis2HeaderReferencePolicyProvider implements PolicyProvider {
+    private RuntimeComponent component;
+    private RuntimeComponentReference reference;
+    private Binding binding;
+
+    public Axis2HeaderReferencePolicyProvider(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 (Axis2HeaderPolicy.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 Axis2HeaderReferencePolicyInterceptor(getContext(), operation, ps);
+    }
+
+    /**
+     * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+     */
+    public String getPhase() {
+        return Phase.REFERENCE_POLICY;
+    }
+
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java Mon Sep 15 05:24:31 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.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;
+import org.apache.tuscany.sca.invocation.Message;
+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$ $Date$
+ */
+public class Axis2HeaderServicePolicyInterceptor implements Interceptor {
+    private Invoker next;
+    private Operation operation;
+    private PolicySet policySet = null;
+    private String context;
+    private Axis2HeaderPolicy policy;
+
+    public Axis2HeaderServicePolicyInterceptor(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 Axis2HeaderPolicy){
+                    policy = (Axis2HeaderPolicy)policyObject;
+                    break;
+                }
+            }
+        }
+    }
+
+    public Message invoke(Message msg) {
+        
+        OMElement header = (OMElement)msg.getHeaders().get(policy.getHeaderName().toString());
+        
+        if (header != null) {
+            
+            System.out.println("Token: " + header.getText());
+            // could call out here to some 3rd part system to do whatever you 
+            // need to turn credentials into a principal            
+            
+            msg.getQoSContext().put(Message.QOS_CTX_SECURITY_PRINCIPAL, header.getText());             
+        }
+    
+        return getNext().invoke(msg);
+    }
+
+    public Invoker getNext() {
+        return next;
+    }
+
+    public void setNext(Invoker next) {
+        this.next = next;
+    }
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java Mon Sep 15 05:24:31 2008
@@ -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.header;
+
+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$ $Date$
+ */
+public class Axis2HeaderServicePolicyProvider implements PolicyProvider {
+    private RuntimeComponent component;
+    private RuntimeComponentService service;
+    private Binding binding;
+
+    public Axis2HeaderServicePolicyProvider(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 (Axis2HeaderPolicy.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 Axis2HeaderServicePolicyInterceptor(getContext(), operation, ps);
+    }
+
+    /**
+     * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase()
+     */
+    public String getPhase() {
+        return Phase.SERVICE_POLICY;
+    }
+
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java Mon Sep 15 05:24:31 2008
@@ -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();
+    }
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java?rev=695452&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java (added)
+++ tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java Mon Sep 15 05:24:31 2008
@@ -0,0 +1,59 @@
+/*
+ * 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) {
+        headerString = header.getText();
+    }
+}

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date