This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 2.13.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 13309c1e404ba8f7f27d6983ad080184a20f5fb5 Author: Peter Palaga <[email protected]> AuthorDate: Tue Nov 22 18:01:28 2022 +0100 WS-Trust workaround for #4291 SoapFault: BSP:R3227: A SECURITY_HEADER MUST NOT contain more than one TIMESTAMP --- .../cxf-soap/cxf-soap-ws-trust/pom.xml | 21 ++++++++++- .../soap/it/ws/trust/server/StsLoggingFeature.java | 33 +++++++++++++++++ .../server/cxf/way/TrustHelloServiceCxfWay.java | 34 +++++++++++++++++ .../cxf/way/TrustHelloServiceCxfWayImpl.java | 43 ++++++++++++++++++++++ .../server/cxf/way/WsTrustServerRoutesCxfWay.java | 34 +++++++++++++++++ .../cxf/soap/it/ws/trust/sts/SampleSTS.java | 1 + .../src/main/resources/application.properties | 7 ++-- .../cxf/soap/it/ws/trust/CxfWsTrustTest.java | 2 + .../it/ws/trust/cxf/way/CxfWsTrustCxfWayIT.java | 24 ++++++++++++ .../way/CxfWsTrustCxfWayTest.java} | 19 +++++----- 10 files changed, 203 insertions(+), 15 deletions(-) diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/pom.xml b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/pom.xml index bd2e3516dc..2906f58832 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/pom.xml +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-build-parent-it</artifactId> - <version>2.14.0-SNAPSHOT</version> + <version>2.13.2-SNAPSHOT</version> <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> </parent> @@ -35,6 +35,10 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-cxf-soap</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> <dependency> <groupId>io.quarkiverse.cxf</groupId> <artifactId>quarkus-cxf-services-sts</artifactId> @@ -117,6 +121,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> </profile> <profile> @@ -132,4 +149,4 @@ </profile> </profiles> -</project> \ No newline at end of file +</project> diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/StsLoggingFeature.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/StsLoggingFeature.java new file mode 100644 index 0000000000..c180a4387d --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/StsLoggingFeature.java @@ -0,0 +1,33 @@ +/* + * 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.camel.quarkus.component.cxf.soap.it.ws.trust.server; + +import javax.enterprise.context.ApplicationScoped; + +import io.quarkus.arc.Unremovable; +import org.apache.cxf.ext.logging.LoggingFeature; + +@ApplicationScoped +@Unremovable +public class StsLoggingFeature extends LoggingFeature { + + public StsLoggingFeature() { + super(); + this.setPrettyLogging(true); + } + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/TrustHelloServiceCxfWay.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/TrustHelloServiceCxfWay.java new file mode 100644 index 0000000000..252bfd0ff9 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/TrustHelloServiceCxfWay.java @@ -0,0 +1,34 @@ +/* + * 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.camel.quarkus.component.cxf.soap.it.ws.trust.server.cxf.way; + +import javax.jws.WebMethod; +import javax.jws.WebService; + +import org.apache.cxf.annotations.Policies; +import org.apache.cxf.annotations.Policy; + +@WebService(targetNamespace = "https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust") +@Policy(placement = Policy.Placement.BINDING, uri = "classpath:/AsymmetricSAML2Policy.xml") +public interface TrustHelloServiceCxfWay { + @WebMethod + @Policies({ + @Policy(placement = Policy.Placement.BINDING_OPERATION_INPUT, uri = "classpath:/Input_Policy.xml"), + @Policy(placement = Policy.Placement.BINDING_OPERATION_OUTPUT, uri = "classpath:/Output_Policy.xml") + }) + String sayHello(); +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/TrustHelloServiceCxfWayImpl.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/TrustHelloServiceCxfWayImpl.java new file mode 100644 index 0000000000..c65e173292 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/TrustHelloServiceCxfWayImpl.java @@ -0,0 +1,43 @@ +/* + * 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.camel.quarkus.component.cxf.soap.it.ws.trust.server.cxf.way; + +import javax.inject.Inject; +import javax.jws.WebMethod; +import javax.jws.WebService; + +import org.apache.camel.ProducerTemplate; +import org.apache.cxf.annotations.EndpointProperties; +import org.apache.cxf.annotations.EndpointProperty; + +@WebService(portName = "TrustHelloServicePort", serviceName = "TrustHelloServiceCxfWay", wsdlLocation = "TrustHelloService.wsdl", targetNamespace = "https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust", endpointInterface = "org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.cxf.way.TrustHelloServiceCxfWay") +@EndpointProperties(value = { + @EndpointProperty(key = "ws-security.signature.username", value = "myservicekey"), + @EndpointProperty(key = "ws-security.signature.properties", value = "serviceKeystore.properties"), + @EndpointProperty(key = "ws-security.encryption.properties", value = "serviceKeystore.properties"), + @EndpointProperty(key = "ws-security.callback-handler", value = "org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.ServerCallbackHandler") +}) +public class TrustHelloServiceCxfWayImpl implements TrustHelloServiceCxfWay { + + @Inject + ProducerTemplate producerTemplate; + + @WebMethod + public String sayHello() { + return producerTemplate.requestBody("direct:wsTrustCxfWay", null, String.class); + } +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/WsTrustServerRoutesCxfWay.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/WsTrustServerRoutesCxfWay.java new file mode 100644 index 0000000000..417beb0c82 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/cxf/way/WsTrustServerRoutesCxfWay.java @@ -0,0 +1,34 @@ +/* + * 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.camel.quarkus.component.cxf.soap.it.ws.trust.server.cxf.way; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.builder.RouteBuilder; + +@ApplicationScoped +public class WsTrustServerRoutesCxfWay extends RouteBuilder { + + @Override + public void configure() { + + from("direct:wsTrustCxfWay") + .setBody().constant("WS-Trust Hello World, CXF way!"); + + } + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/sts/SampleSTS.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/sts/SampleSTS.java index 0ad041d4eb..9a983f44ba 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/sts/SampleSTS.java +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/sts/SampleSTS.java @@ -63,6 +63,7 @@ public class SampleSTS extends SecurityTokenServiceProvider { : config.getValue("quarkus.http.port", Integer.class); service.setEndpoints(Arrays.asList( "http://localhost:" + port + "/soapservice/jaxws-samples-wsse-policy-trust/TrustHelloService", + "http://localhost:" + port + "/soapservice/jaxws-samples-wsse-policy-trust-cxf-way/TrustHelloServiceCxfWay", "http://localhost:" + port + "/soapservice/jaxws-samples-wsse-policy-trust-actas/ActAsService", "http://localhost:" + port + "/soapservice/jaxws-samples-wsse-policy-trust-onbehalfof/OnBehalfOfService")); services.add(service); diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/resources/application.properties b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/resources/application.properties index 2652146673..98c1825180 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/resources/application.properties +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/resources/application.properties @@ -17,9 +17,8 @@ quarkus.cxf.path=/soapservice quarkus.cxf.endpoint."/jaxws-samples-wsse-policy-trust-sts".implementor=org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.sts.SampleSTS -quarkus.cxf.endpoint."/jaxws-samples-wsse-policy-trust-sts".features=org.apache.cxf.ext.logging.LoggingFeature +quarkus.cxf.endpoint."/jaxws-samples-wsse-policy-trust-sts".features=org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.StsLoggingFeature -#quarkus.cxf.endpoint."/jaxws-samples-wsse-policy-trust".implementor=org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.TrustHelloServiceImpl -#quarkus.cxf.endpoint."/jaxws-samples-wsse-policy-trust".features=org.apache.cxf.ext.logging.LoggingFeature +quarkus.cxf.endpoint."/jaxws-samples-wsse-policy-trust-cxf-way".implementor=org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.cxf.way.TrustHelloServiceCxfWayImpl -quarkus.native.resources.includes=*.properties,*.jks,*.wsdl,*.xml +quarkus.native.resources.includes=*.properties,*.jks,*.wsdl,*.xml,*.xsd diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java index 0c1b496f66..fddea2dacb 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java @@ -35,6 +35,7 @@ import org.apache.cxf.ws.security.trust.STSClient; import org.assertj.core.api.Assertions; import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.anyNs; @@ -89,6 +90,7 @@ public class CxfWsTrustTest { } @Test + @Disabled("https://github.com/apache/camel-quarkus/issues/4291") public void programmaticSts() throws Exception { Bus bus = BusFactory.newInstance().createBus(); try { diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/cxf/way/CxfWsTrustCxfWayIT.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/cxf/way/CxfWsTrustCxfWayIT.java new file mode 100644 index 0000000000..5e644ea85d --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/cxf/way/CxfWsTrustCxfWayIT.java @@ -0,0 +1,24 @@ +/* + * 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.camel.quarkus.component.cxf.soap.it.ws.trust.cxf.way; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class CxfWsTrustCxfWayIT extends CxfWsTrustCxfWayTest { + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/cxf/way/CxfWsTrustCxfWayTest.java similarity index 92% copy from integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java copy to integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/cxf/way/CxfWsTrustCxfWayTest.java index 0c1b496f66..6753f825e7 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java +++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/cxf/way/CxfWsTrustCxfWayTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.cxf.soap.it.ws.trust; +package org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.cxf.way; import java.net.URL; import java.util.Map; @@ -27,7 +27,8 @@ import io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.config.RestAssuredConfig; -import org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.TrustHelloService; +import org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.ClientCallbackHandler; +import org.apache.camel.quarkus.component.cxf.soap.it.ws.trust.server.cxf.way.TrustHelloServiceCxfWay; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.ws.security.SecurityConstants; @@ -41,7 +42,7 @@ import static io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.anyNs; import static io.restassured.RestAssured.given; @QuarkusTest -public class CxfWsTrustTest { +public class CxfWsTrustCxfWayTest { /** * Make sure the ws-trust-1.4-service.wsdl file is served @@ -68,7 +69,7 @@ public class CxfWsTrustTest { config.getXmlConfig().namespaceAware(false); given() .config(config) - .when().get("/soapservice/jaxws-samples-wsse-policy-trust?wsdl") + .when().get("/soapservice/jaxws-samples-wsse-policy-trust-cxf-way?wsdl") .then() .statusCode(200) .body( @@ -95,11 +96,11 @@ public class CxfWsTrustTest { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust", - "TrustHelloService"); + "TrustHelloServiceCxfWay"); final URL wsdlURL = new URL(io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.getServerUrl() - + "/soapservice/jaxws-samples-wsse-policy-trust/TrustHelloService?wsdl"); + + "/soapservice/jaxws-samples-wsse-policy-trust-cxf-way/TrustHelloServiceCxfWay?wsdl"); Service service = Service.create(wsdlURL, serviceName); - TrustHelloService proxy = (TrustHelloService) service.getPort(TrustHelloService.class); + TrustHelloServiceCxfWay proxy = service.getPort(TrustHelloServiceCxfWay.class); final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"); final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"); @@ -108,14 +109,14 @@ public class CxfWsTrustTest { + "/soapservice/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl"; setupWsseAndSTSClient(proxy, bus, stsURL, stsServiceName, stsPortName); - Assertions.assertThat(proxy.sayHello()).isEqualTo("WS-Trust Hello World!"); + Assertions.assertThat(proxy.sayHello()).isEqualTo("WS-Trust Hello World, CXF way!"); } finally { bus.shutdown(true); } } - public static void setupWsseAndSTSClient(TrustHelloService proxy, Bus bus, String stsWsdlLocation, QName stsService, + public static void setupWsseAndSTSClient(TrustHelloServiceCxfWay proxy, Bus bus, String stsWsdlLocation, QName stsService, QName stsPort) { Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext(); setServiceContextAttributes(ctx);
