You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2016/05/24 15:45:09 UTC
cxf git commit: Adding @Ignore'd test-case for policy annotation issue
Repository: cxf
Updated Branches:
refs/heads/3.1.x-fixes 4c64e8b5f -> 8f0f05a7d
Adding @Ignore'd test-case for policy annotation issue
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/8f0f05a7
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/8f0f05a7
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/8f0f05a7
Branch: refs/heads/3.1.x-fixes
Commit: 8f0f05a7deffe4254e82a95b33a5e23aaea0c285
Parents: 4c64e8b
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue May 24 16:41:50 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue May 24 16:42:32 2016 +0100
----------------------------------------------------------------------
.../ws/fault/DoubleItPortTypeImplJavaFirst.java | 62 ++++++++++++++++++++
.../apache/cxf/systest/ws/fault/FaultTest.java | 37 ++++++++++++
.../cxf/systest/ws/fault/DoubleItFault.wsdl | 3 +
.../systest/ws/fault/SignedEncryptedPolicy.xml | 13 ++++
.../cxf/systest/ws/fault/SymmetricUTPolicy.xml | 42 +++++++++++++
.../org/apache/cxf/systest/ws/fault/client.xml | 60 ++++++++++++++++++-
.../org/apache/cxf/systest/ws/fault/server.xml | 6 ++
7 files changed, 221 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/DoubleItPortTypeImplJavaFirst.java
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/DoubleItPortTypeImplJavaFirst.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/DoubleItPortTypeImplJavaFirst.java
new file mode 100644
index 0000000..0d3d6a7
--- /dev/null
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/DoubleItPortTypeImplJavaFirst.java
@@ -0,0 +1,62 @@
+/**
+ * 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.cxf.systest.ws.fault;
+
+import java.security.Principal;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.annotations.Policy;
+import org.apache.cxf.feature.Features;
+import org.example.contract.doubleit.DoubleItFault;
+import org.example.contract.doubleit.DoubleItPortType;
+
+@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt",
+ serviceName = "DoubleItService",
+ endpointInterface = "org.example.contract.doubleit.DoubleItPortType")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+// @Policy(uri = "classpath:/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml")
+public class DoubleItPortTypeImplJavaFirst implements DoubleItPortType {
+ @Resource
+ WebServiceContext wsContext;
+
+ //@Policies({
+ // @Policy(uri = "classpath:/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml")
+ //@Policy(uri = "classpath:/org/apache/cxf/systest/ws/fault/SignedEncryptedPolicy.xml",
+ // placement = Placement.BINDING_OPERATION)
+ //})
+
+ @Policy(uri = "classpath:/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml")
+ public int doubleIt(int numberToDouble) throws DoubleItFault {
+
+ Principal pr = wsContext.getUserPrincipal();
+ if (pr == null || "alice".equals(pr.getName())) {
+ return numberToDouble * 2;
+ }
+
+ org.example.schema.doubleit.DoubleItFault internalFault =
+ new org.example.schema.doubleit.DoubleItFault();
+ internalFault.setMajor((short)124);
+ internalFault.setMinor((short)1256);
+ throw new DoubleItFault("This is a fault", internalFault);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
index 69ad62d..755f11b 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
@@ -259,4 +259,41 @@ public class FaultTest extends AbstractBusClientServerTestBase {
bus.shutdown(true);
}
+ // TODO - There seems to be a bug when a security policy is applied to a method as opposed to the class
+ // See DoubleItPortTypeImplJavaFirst
+ @org.junit.Test
+ @org.junit.Ignore
+ public void testJavaFirst() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = FaultTest.class.getResource("client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItJavaFirstPort");
+ DoubleItPortType utPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(utPort, PORT);
+
+ // Make a successful invocation
+ ((BindingProvider)utPort).getRequestContext().put("security.username", "alice");
+ utPort.doubleIt(25);
+ /*
+ // Now make an invocation using another username
+ ((BindingProvider)utPort).getRequestContext().put("security.username", "bob");
+ ((BindingProvider)utPort).getRequestContext().put("security.password", "password");
+ try {
+ utPort.doubleIt(25);
+ fail("Expected failure on bob");
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().contains("This is a fault"));
+ }
+ */
+ ((java.io.Closeable)utPort).close();
+ bus.shutdown(true);
+ }
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
index df7ffe1..09947df 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl
@@ -128,6 +128,9 @@
<wsp:PolicyReference URI="#DoubleItPlaintextWithPartsPolicy"/>
<soap:address location="http://localhost:9009/DoubleItSoap11PolicyWithParts"/>
</wsdl:port>
+ <wsdl:port name="DoubleItJavaFirstPort" binding="tns:DoubleItSoap11NoPolicyBinding">
+ <soap12:address location="http://localhost:9009/DoubleItJavaFirst"/>
+ </wsdl:port>
</wsdl:service>
<wsp:Policy wsu:Id="DoubleItPlaintextPolicy">
<wsp:ExactlyOne>
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SignedEncryptedPolicy.xml
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SignedEncryptedPolicy.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SignedEncryptedPolicy.xml
new file mode 100644
index 0000000..7ae2212
--- /dev/null
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SignedEncryptedPolicy.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" wsu:Id="SignedEncryptedPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:EncryptedParts>
+ <sp:Body/>
+ </sp:EncryptedParts>
+ <sp:SignedParts>
+ <sp:Body/>
+ </sp:SignedParts>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml
new file mode 100644
index 0000000..049ca51
--- /dev/null
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/SymmetricUTPolicy.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" wsu:Id="SymmetricUTPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SymmetricBinding>
+ <wsp:Policy>
+ <sp:ProtectionToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ <sp:RequireKeyIdentifierReference/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:ProtectionToken>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Lax/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic128/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ </wsp:Policy>
+ </sp:SymmetricBinding>
+ <sp:SupportingTokens>
+ <wsp:Policy>
+ <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssUsernameToken10/>
+ </wsp:Policy>
+ </sp:UsernameToken>
+ </wsp:Policy>
+ </sp:SupportingTokens>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
index b22bb4d..b23a005 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/client.xml
@@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/policy http://cxf.apache.org/schemas/poli
cy.xsd">
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/policy http://cxf.apache.org/schemas/poli
cy.xsd http://www.w3.org/ns/ws-policy http://www.w3.org/2007/02/ws-policy.xsd">
<cxf:bus>
<cxf:features>
<p:policies/>
@@ -57,11 +57,67 @@
</jaxws:properties>
</jaxws:client>
- <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSoap11PolicyWithPartsPort" createdFromAPI="true">
+ <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItSoap11PolicyWithPartsPort" createdFromAPI="true">
<jaxws:properties>
<entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
<entry key="security.encryption.properties" value="bob.properties"/>
<entry key="security.encryption.username" value="bob"/>
</jaxws:properties>
</jaxws:client>
+
+ <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItJavaFirstPort" createdFromAPI="true">
+ <jaxws:properties>
+ <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
+ <entry key="security.encryption.properties" value="bob.properties"/>
+ <entry key="security.encryption.username" value="bob"/>
+ </jaxws:properties>
+ <jaxws:features>
+ <p:policies>
+ <wsp:PolicyReference xmlns:wsp="http://www.w3.org/ns/ws-policy" URI="#SymmetricUTPolicy"/>
+ </p:policies>
+ </jaxws:features>
+ </jaxws:client>
+
+ <wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" wsu:Id="SymmetricUTPolicy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SymmetricBinding>
+ <wsp:Policy>
+ <sp:ProtectionToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ <sp:RequireKeyIdentifierReference/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:ProtectionToken>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Lax/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:Basic128/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ </wsp:Policy>
+ </sp:SymmetricBinding>
+ <sp:SupportingTokens>
+ <wsp:Policy>
+ <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssUsernameToken10/>
+ </wsp:Policy>
+ </sp:UsernameToken>
+ </wsp:Policy>
+ </sp:SupportingTokens>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/8f0f05a7/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
----------------------------------------------------------------------
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
index 6fb8461..6085c50 100644
--- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/fault/server.xml
@@ -56,4 +56,10 @@
<entry key="security.signature.properties" value="bob.properties"/>
</jaxws:properties>
</jaxws:endpoint>
+ <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="JavaFirst" address="http://localhost:${testutil.ports.fault.Server}/DoubleItJavaFirst" serviceName="s:DoubleItService" endpointName="s:DoubleItJavaFirstPort" implementor="org.apache.cxf.systest.ws.fault.DoubleItPortTypeImplJavaFirst" wsdlLocation="org/apache/cxf/systest/ws/fault/DoubleItFault.wsdl">
+ <jaxws:properties>
+ <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
+ <entry key="security.signature.properties" value="bob.properties"/>
+ </jaxws:properties>
+ </jaxws:endpoint>
</beans>