You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2009/04/09 03:39:25 UTC

svn commit: r763490 - in /ode/trunk: axis2-war/src/test/java/org/apache/ode/axis2/rampart/policy/ axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/ axis2/src/main/java/org/apache/ode/axis2/hooks/ il-co...

Author: midon
Date: Thu Apr  9 01:39:24 2009
New Revision: 763490

URL: http://svn.apache.org/viewvc?rev=763490&view=rev
Log:
ODE-415: support the security property for process service

Added:
    ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/
    ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.bpel
    ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.wsdl
    ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/config.endpoint
    ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/deploy.xml
    ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/sample02-policy-for-service.xml
Modified:
    ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/rampart/policy/SecuredProcessesTest.java
    ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
    ode/trunk/il-common/src/main/java/org/apache/ode/il/epr/WSDL11Endpoint.java

Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/rampart/policy/SecuredProcessesTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/rampart/policy/SecuredProcessesTest.java?rev=763490&r1=763489&r2=763490&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/rampart/policy/SecuredProcessesTest.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/rampart/policy/SecuredProcessesTest.java Thu Apr  9 01:39:24 2009
@@ -51,6 +51,7 @@
 public class SecuredProcessesTest extends Axis2TestBase {
 
     private String testDir = "TestRampartPolicy/secured-processes";
+    private String clientRepo = getClass().getClassLoader().getResource(testDir).getFile();
 
 
     @DataProvider(name = "secured-processes-bundles")
@@ -61,7 +62,6 @@
             }
         });
         Object[][] bundles = new Object[samples.length][];
-        String clientRepo = getClass().getClassLoader().getResource(testDir).getFile();
         for (int i = 0; i < samples.length; i++) {
             String sampleIndex = samples[i].getName().replace("process-", "");
             String policyFile = clientRepo + "/" + sampleIndex + "-policy.xml";
@@ -114,6 +114,11 @@
         }
     }
 
+    @Test
+    public void standAlonePolicy() throws Exception {
+        invokeSecuredProcesses(testDir+"/process-sample02_standalone_policy", clientRepo, clientRepo+"/sample02-policy.xml");
+    }
+
     private static Policy loadPolicy(String xmlPath) throws Exception {
         StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
         return PolicyEngine.getPolicy(builder.getDocumentElement());

Added: ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.bpel?rev=763490&view=auto
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.bpel (added)
+++ ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.bpel Thu Apr  9 01:39:24 2009
@@ -0,0 +1,55 @@
+<!--
+  ~ 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.
+  -->
+<process name="HelloWorld2"
+    targetNamespace="http://ode/bpel/unit-test" 
+    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:tns="http://ode/bpel/unit-test"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:test="http://ode/bpel/unit-test.wsdl"
+    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+  <import location="HelloWorld2.wsdl"
+     namespace="http://ode/bpel/unit-test.wsdl"
+     importType="http://schemas.xmlsoap.org/wsdl/" />
+
+   <partnerLinks>
+      <partnerLink name="helloPartnerLink" 
+         partnerLinkType="test:HelloPartnerLinkType" myRole="me" />
+   </partnerLinks>
+    
+   <variables>
+     <variable name="inVar" messageType="test:HelloMessage"/>
+     <variable name="outVar" messageType="test:HelloMessage"/>
+   </variables>
+
+   <sequence>
+       <receive name="start" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+          operation="hello" variable="inVar" createInstance="yes"/>
+
+       <assign>
+           <copy>
+               <from>concat(concat("Hello ", $inVar.TestPart), "!")</from>
+               <to>$outVar.TestPart</to>
+           </copy>
+       </assign>
+       <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+              operation="hello" variable="outVar"/>
+   </sequence>
+</process>

Added: ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.wsdl?rev=763490&view=auto
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.wsdl (added)
+++ ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/HelloWorld2.wsdl Thu Apr  9 01:39:24 2009
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ 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.
+  -->
+
+<wsdl:definitions 
+    targetNamespace="http://ode/bpel/unit-test.wsdl"
+    xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:tns="http://ode/bpel/unit-test.wsdl"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
+
+    <wsdl:message name="HelloMessage">
+        <wsdl:part name="TestPart" type="xsd:string"/>
+    </wsdl:message>
+    
+    <wsdl:portType name="HelloPortType">
+        <wsdl:operation name="hello">
+            <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+            <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+        </wsdl:operation>    
+    </wsdl:portType>
+    
+     <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="hello">
+            <soap:operation soapAction="" style="rpc"/>
+            <wsdl:input>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl"
+                    use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl" 
+                    use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloService">
+        <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+            <soap:address location="http://localhost:8080/ode/processes/helloWorld"/>
+        </wsdl:port>
+    </wsdl:service>
+    
+   <plnk:partnerLinkType name="HelloPartnerLinkType">
+       <plnk:role name="me" portType="tns:HelloPortType"/>
+   </plnk:partnerLinkType>
+</wsdl:definitions>
+

Added: ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/config.endpoint
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/config.endpoint?rev=763490&view=auto
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/config.endpoint (added)
+++ ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/config.endpoint Thu Apr  9 01:39:24 2009
@@ -0,0 +1,4 @@
+
+alias.myns=http://ode/bpel/unit-test.wsdl
+myns.HelloService.ode.security.policy.file=sample02-policy-for-service.xml
+

Added: ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/deploy.xml
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/deploy.xml?rev=763490&view=auto
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/deploy.xml (added)
+++ ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/deploy.xml Thu Apr  9 01:39:24 2009
@@ -0,0 +1,30 @@
+<!--
+  ~ 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.
+  -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+    xmlns:pns="http://ode/bpel/unit-test"
+    xmlns:wns="http://ode/bpel/unit-test.wsdl">
+
+
+    <process name="pns:HelloWorld2">
+        <active>true</active>
+        <provide partnerLink="helloPartnerLink">
+            <service name="wns:HelloService" port="HelloPort"/>
+        </provide>
+    </process>
+</deploy>

Added: ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/sample02-policy-for-service.xml
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/sample02-policy-for-service.xml?rev=763490&view=auto
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/sample02-policy-for-service.xml (added)
+++ ode/trunk/axis2-war/src/test/resources/TestRampartPolicy/secured-processes/process-sample02_standalone_policy/sample02-policy-for-service.xml Thu Apr  9 01:39:24 2009
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsp:Policy wsu:Id="SigOnly" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+    <wsp:ExactlyOne>
+        <wsp:All>
+            <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <wsp:Policy>
+                    <sp:InitiatorToken>
+                        <wsp:Policy>
+                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                                <wsp:Policy>
+                                    <sp:RequireThumbprintReference/>
+                                    <sp:WssX509V3Token10/>
+                                </wsp:Policy>
+                            </sp:X509Token>
+                        </wsp:Policy>
+                    </sp:InitiatorToken>
+                    <sp:RecipientToken>
+                        <wsp:Policy>
+                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+                                <wsp:Policy>
+                                    <sp:RequireThumbprintReference/>
+                                    <sp:WssX509V3Token10/>
+                                </wsp:Policy>
+                            </sp:X509Token>
+                        </wsp:Policy>
+                    </sp:RecipientToken>
+                    <sp:AlgorithmSuite>
+                        <wsp:Policy>
+                            <sp:TripleDesRsa15/>
+                        </wsp:Policy>
+                    </sp:AlgorithmSuite>
+                    <sp:Layout>
+                        <wsp:Policy>
+                            <sp:Strict/>
+                        </wsp:Policy>
+                    </sp:Layout>
+                    <sp:IncludeTimestamp/>
+                    <sp:OnlySignEntireHeadersAndBody/>
+                </wsp:Policy>
+            </sp:AsymmetricBinding>
+            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <wsp:Policy>
+                    <sp:MustSupportRefKeyIdentifier/>
+                    <sp:MustSupportRefIssuerSerial/>
+                </wsp:Policy>
+            </sp:Wss10>
+            <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <sp:Body/>
+            </sp:SignedParts>
+
+            <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+                <ramp:user>service</ramp:user>
+                <ramp:encryptionUser>client</ramp:encryptionUser>
+                <ramp:passwordCallbackClass>org.apache.rampart.samples.policy.sample02.PWCBHandler</ramp:passwordCallbackClass>
+
+                <ramp:signatureCrypto>
+                    <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+                        <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+                        <ramp:property name="org.apache.ws.security.crypto.merlin.file">service.jks</ramp:property>
+                        <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">apache</ramp:property>
+                    </ramp:crypto>
+                </ramp:signatureCrypto>
+            </ramp:RampartConfig>
+
+        </wsp:All>
+    </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file

Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java?rev=763490&r1=763489&r2=763490&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java Thu Apr  9 01:39:24 2009
@@ -38,6 +38,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
 import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.MessageReceiver;
@@ -49,6 +50,8 @@
 import org.apache.ode.axis2.util.Axis2WSDLLocator;
 import org.apache.ode.axis2.util.AxisUtils;
 import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.utils.Properties;
+import org.apache.ode.il.epr.WSDL11Endpoint;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.w3c.dom.Element;
@@ -105,6 +108,13 @@
                 LOG.warn("Exception while configuring service: " + service_file, except);
             }
 
+
+            final WSDL11Endpoint endpoint = new WSDL11Endpoint(wsdlServiceName, portName);
+            Options options = Properties.Axis2.translate(pconf.getEndpointProperties(endpoint));
+            if(options.getProperty(Properties.PROP_SECURITY_POLICY)!=null){
+                AxisUtils.applySecurityPolicy(axisService, (String) options.getProperty(Properties.PROP_SECURITY_POLICY));
+            }
+
             // In doc/lit we need to declare a mapping between operations and message element names
             // to be able to route properly.
             declarePartsElements(wsdlDefinition, wsdlServiceName, axisServiceName, portName);

Modified: ode/trunk/il-common/src/main/java/org/apache/ode/il/epr/WSDL11Endpoint.java
URL: http://svn.apache.org/viewvc/ode/trunk/il-common/src/main/java/org/apache/ode/il/epr/WSDL11Endpoint.java?rev=763490&r1=763489&r2=763490&view=diff
==============================================================================
--- ode/trunk/il-common/src/main/java/org/apache/ode/il/epr/WSDL11Endpoint.java (original)
+++ ode/trunk/il-common/src/main/java/org/apache/ode/il/epr/WSDL11Endpoint.java Thu Apr  9 01:39:24 2009
@@ -39,6 +39,32 @@
   public WSDL11Endpoint() {
   }
 
+    public WSDL11Endpoint(QName serviceQName, String portName, String location) {
+        Document doc = DOMUtils.newDocument();
+        Element serviceRef = doc.createElementNS(SERVICE_REF_QNAME.getNamespaceURI(), SERVICE_REF_QNAME.getLocalPart());
+        doc.appendChild(serviceRef);
+        _serviceElmt = doc.createElementNS(Namespaces.WSDL_11, "service");
+        serviceRef.appendChild(_serviceElmt);
+        if (serviceQName != null) {
+            _serviceElmt.setAttribute("name", serviceQName.getLocalPart());
+            _serviceElmt.setAttribute("targetNamespace", serviceQName.getNamespaceURI());
+        }
+        Element port = doc.createElementNS(Namespaces.WSDL_11, "port");
+        if (portName != null) {
+            port.setAttribute("name", portName);
+        }
+        port.setAttribute("binding", "");
+        Element address = doc.createElementNS(Namespaces.SOAP_NS, "address");
+        if (location != null) address.setAttribute("location", location);
+
+        _serviceElmt.appendChild(port);
+        port.appendChild(address);
+    }
+
+    public WSDL11Endpoint(QName serviceName, String portName) {
+        this(serviceName, portName, null);
+    }
+
     public String getUrl() {
         Element port = (Element) _serviceElmt.getElementsByTagNameNS(Namespaces.WSDL_11, "port").item(0);
         // get soap:address
@@ -56,7 +82,7 @@
 
   public QName getServiceName() {
     return new QName(_serviceElmt.getAttribute("targetNamespace"), _serviceElmt.getAttribute("name"));
-  }
+  } 
 
   public boolean accept(Node node) {
     if (node.getNodeType() == Node.ELEMENT_NODE) {