This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-27373-cxf-ws-security-options in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4af3fa4a3702fb2596d2ff049cc7006b65d9a83e Author: Claus Ibsen <[email protected]> AuthorDate: Sun Nov 22 10:14:43 2026 +0100 CAMEL-27373: camel-cxf - first-class WS-Security UsernameToken options New endpoint options wsSecurityUsername, wsSecurityPassword, wsSecurityPasswordType (Text/Digest), wsSecurityCallbackHandler and wsSecurityCredentials (a map bean of users) set up a WS-Security UsernameToken for the producer and the consumer without Java code. A new WsSecurityUsernameTokenConfigurer in the chained configurer sets the CXF security properties, which a WS-SecurityPolicy in the WSDL uses, and adds a WSS4JOutInterceptor or WSS4JInInterceptor only when the WSDL has no WS-SecurityPolicy. CxfConsumer now applies the chained configurer, so the configurer also runs on the server side. RAW mode is rejected, and a missing cxf-rt-ws-security dependency gives a clear error. #bean: references in properties.* are already resolved on main; tests pin that, and the docs mention it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../org/apache/camel/catalog/components/cxf.json | 17 +- .../apache/camel/catalog/docs/cxf-component.adoc | 76 ++++ components/camel-cxf/camel-cxf-soap/pom.xml | 7 + .../component/cxf/jaxws/CxfEndpointConfigurer.java | 32 ++ .../component/cxf/jaxws/CxfEndpointUriFactory.java | 11 +- .../org/apache/camel/component/cxf/jaxws/cxf.json | 17 +- .../src/main/docs/cxf-component.adoc | 76 ++++ .../camel/component/cxf/jaxws/CxfConsumer.java | 6 +- .../camel/component/cxf/jaxws/CxfEndpoint.java | 110 +++++- .../jaxws/WsSecurityUsernameTokenConfigurer.java | 250 ++++++++++++ .../cxf/jaxws/CxfWsSecurityUsernameTokenTest.java | 321 ++++++++++++++++ .../component/cxf/jaxws/CxfWsSecurityYamlTest.java | 78 ++++ .../src/test/resources/wssec/orders-ut.wsdl | 101 +++++ .../src/test/resources/wssec/orders.wsdl | 80 ++++ .../src/test/resources/wssec/wssec.camel.yaml | 64 ++++ .../endpoint/dsl/CxfEndpointBuilderFactory.java | 417 +++++++++++++++++++++ 16 files changed, 1644 insertions(+), 19 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json index 7851f4f5e994..6ce341fc9082 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/cxf.json @@ -81,11 +81,16 @@ "skipFaultLogging": { "index": 30, "kind": "parameter", "displayName": "Skip Fault Logging", "group": "logging", "label": "logging", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip the log entry that the PhaseInterceptorChain writes when an interceptor throws an exception, for example the exception of a failed exchange of the consumer. Sets the CXF property or [...] "password": { "index": 31, "kind": "parameter", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The password for HTTP Basic authentication. The producer puts it, together with the user name, in the protocol header Authorization of its HTTP requests. Only used when the username option is set. Not used f [...] "username": { "index": 32, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The user name for HTTP Basic authentication. The producer puts it, together with the password, in the protocol header Authorization of its HTTP requests. Only used when the password option is set. Not used f [...] - "bindingId": { "index": 33, "kind": "parameter", "displayName": "Binding Id", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of the CXF binding, which is a namespace URI, for example http:\/\/cxf.apache.org\/bindings\/xformat for the XML binding without a SOAP envelope. If not set, CXF uses the binding of the wsdl:port. The id http:\/\/schemas [...] - "portName": { "index": 34, "kind": "parameter", "displayName": "Port Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL port, which is the name attribute of the wsdl:port element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderPort." }, - "publishedEndpointUrl": { "index": 35, "kind": "parameter", "displayName": "Published Endpoint Url", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The address to publish in the WSDL that the consumer serves at the service address followed by ?wsdl. It replaces the location of the address element in the wsdl:port. Use it when clients reach the servic [...] - "serviceClass": { "index": 36, "kind": "parameter", "displayName": "Service Class", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.Class<java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, "description": "The Java class of the service, for example a service endpoint interface or a class that implements one. Written as a fully qualified class name, for example org.example.orders.OrderService. Required when [...] - "serviceName": { "index": 37, "kind": "parameter", "displayName": "Service Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL service, which is the name attribute of the wsdl:service element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderService. If not set and wsdlURL points to a W [...] - "wsdlURL": { "index": 38, "kind": "parameter", "displayName": "Wsdl URL", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The location of the WSDL. Can be on the classpath, file system, or be hosted remotely." } + "wsSecurityCallbackHandler": { "index": 33, "kind": "parameter", "displayName": "WS-Security Callback Handler", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.security.auth.callback.CallbackHandler", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom javax.security.auth.callback.CallbackHandler for the WS-Security UsernameToken. CXF calls it with an org.apache.wss4j.common.ext.WSPasswordCallback [...] + "wsSecurityCredentials": { "index": 34, "kind": "parameter", "displayName": "WS-Security Credentials", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A map of user name to password with the users that the consumer accepts in a WS-Security UsernameToken, as a reference to a java.util.Map bean, for example #bean:users [...] + "wsSecurityPassword": { "index": 35, "kind": "parameter", "displayName": "WS-Security Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The password of a WS-Security UsernameToken. The producer sends it in the UsernameToken, and the consumer requires it for the user of the wsSecurityUsername option." }, + "wsSecurityPasswordType": { "index": 36, "kind": "parameter", "displayName": "WS-Security Password Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "Text", "Digest" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Text", "description": "The type of the password in a WS-Security UsernameToken: Text for PasswordText, or Digest for PasswordDigest. The producer sends this type, and t [...] + "wsSecurityUsername": { "index": 37, "kind": "parameter", "displayName": "WS-Security Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The user name of a WS-Security UsernameToken. The producer sends a UsernameToken with this user name in the SOAP header of its requests. The consumer accepts only this user, with the pa [...] + "bindingId": { "index": 38, "kind": "parameter", "displayName": "Binding Id", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of the CXF binding, which is a namespace URI, for example http:\/\/cxf.apache.org\/bindings\/xformat for the XML binding without a SOAP envelope. If not set, CXF uses the binding of the wsdl:port. The id http:\/\/schemas [...] + "portName": { "index": 39, "kind": "parameter", "displayName": "Port Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL port, which is the name attribute of the wsdl:port element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderPort." }, + "publishedEndpointUrl": { "index": 40, "kind": "parameter", "displayName": "Published Endpoint Url", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The address to publish in the WSDL that the consumer serves at the service address followed by ?wsdl. It replaces the location of the address element in the wsdl:port. Use it when clients reach the servic [...] + "serviceClass": { "index": 41, "kind": "parameter", "displayName": "Service Class", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.Class<java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, "description": "The Java class of the service, for example a service endpoint interface or a class that implements one. Written as a fully qualified class name, for example org.example.orders.OrderService. Required when [...] + "serviceName": { "index": 42, "kind": "parameter", "displayName": "Service Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL service, which is the name attribute of the wsdl:service element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderService. If not set and wsdlURL points to a W [...] + "wsdlURL": { "index": 43, "kind": "parameter", "displayName": "Wsdl URL", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The location of the WSDL. Can be on the classpath, file system, or be hosted remotely." } } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc index 025de9a0256c..4ae5e343d1c9 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/cxf-component.adoc @@ -121,6 +121,82 @@ Using CXF with Spring Boot or Quarkus comes automatic integrated with the embedd See more details in the https://cxf.apache.org/docs/http-transport.html[CXF Transport] documentation. +== WS-Security UsernameToken + +The `wsSecurity` options set up a WS-Security UsernameToken without Java code. The producer sends a UsernameToken in +the SOAP header of its requests, and the consumer rejects a request without a valid UsernameToken with a SOAP fault. +The options need the `org.apache.cxf:cxf-rt-ws-security` dependency, which `camel-cxf-soap` does not bring by itself. + +NOTE: The `username` and `password` options are for HTTP Basic authentication, not for WS-Security. + +[cols="1,2,2",options="header"] +|=== +| Option | Producer | Consumer +| `wsSecurityUsername` | The user name to send. | The one user that is accepted. +| `wsSecurityPassword` | The password to send. | The password of that user. +| `wsSecurityPasswordType` | `Text` (default) sends a PasswordText, `Digest` a PasswordDigest. | The password type that is required. +| `wsSecurityCredentials` | Not used. | A `java.util.Map` bean of user name to password, to accept more than one user. +| `wsSecurityCallbackHandler` | A `CallbackHandler` bean that sets the password, instead of `wsSecurityPassword`. | A `CallbackHandler` bean that looks up the password of any user, for example from a vault. +|=== + +When the WSDL of the service has a WS-SecurityPolicy, the policy decides how the UsernameToken is sent and checked, +including the password type, and the options give the user name, the password and the callback handler to the policy. +When the WSDL has no WS-SecurityPolicy, or there is no WSDL, the endpoint adds the CXF `WSS4JOutInterceptor` (producer) +or `WSS4JInInterceptor` (consumer) for the UsernameToken. + +The consumer sets the authenticated user in the `CamelAuthentication` header, as a `javax.security.auth.Subject`. + +The options are not supported with `dataFormat=RAW`, as CXF does not process the SOAP envelope in this mode. + +WARNING: A UsernameToken with a plain text password must only be sent over HTTPS. `Digest` is no replacement for +HTTPS: it uses SHA-1, and the consumer needs the plain password to check it. + +A consumer that accepts two users with a PasswordDigest: + +[source,yaml] +---- +- beans: + - name: users + type: java.util.HashMap + properties: + alice: "{{alice.password}}" + bob: "{{bob.password}}" +- route: + from: + uri: cxf://https://0.0.0.0:8443/orders + parameters: + wsdlURL: classpath:orders.wsdl + dataFormat: PAYLOAD + wsSecurityCredentials: "#bean:users" + wsSecurityPasswordType: Digest + steps: + - log: "Order request from ${header.CamelAuthentication}" +---- + +A producer that calls this service: + +[source,yaml] +---- +- route: + from: + uri: direct:getOrder + steps: + - to: + uri: cxf://https://orders.example.com/orders + parameters: + wsdlURL: classpath:orders.wsdl + dataFormat: PAYLOAD + defaultOperationName: getOrder + wsSecurityUsername: alice + wsSecurityPassword: "{{alice.password}}" + wsSecurityPasswordType: Digest +---- + +Other WS-Security features, such as a Timestamp, a signature or encryption, are set up with the CXF properties in +`properties.*`, or with CXF interceptors or a `cxfConfigurer` in Java code. A value of `properties.*` that is a +`#bean:name` reference is resolved from the registry, for example +`properties.security.callback-handler=#bean:myCallbackHandler`. A plain `#name` is not resolved. + == Usage === RAW Mode diff --git a/components/camel-cxf/camel-cxf-soap/pom.xml b/components/camel-cxf/camel-cxf-soap/pom.xml index aa898ee9c79b..085902c184d3 100644 --- a/components/camel-cxf/camel-cxf-soap/pom.xml +++ b/components/camel-cxf/camel-cxf-soap/pom.xml @@ -114,6 +114,13 @@ <scope>test</scope> </dependency> + <!-- WS-Security options set from a YAML route --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-yaml-dsl</artifactId> + <scope>test</scope> + </dependency> + <!-- test for cxf failover feature --> <dependency> diff --git a/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointConfigurer.java b/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointConfigurer.java index 4bac1c85b440..069bf587d39d 100644 --- a/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointConfigurer.java +++ b/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointConfigurer.java @@ -90,6 +90,16 @@ public class CxfEndpointConfigurer extends PropertyConfigurerSupport implements case "wrapped": target.setWrapped(property(camelContext, boolean.class, value)); return true; case "wrappedstyle": case "wrappedStyle": target.setWrappedStyle(property(camelContext, java.lang.Boolean.class, value)); return true; + case "wssecuritycallbackhandler": + case "wsSecurityCallbackHandler": target.setWsSecurityCallbackHandler(property(camelContext, javax.security.auth.callback.CallbackHandler.class, value)); return true; + case "wssecuritycredentials": + case "wsSecurityCredentials": target.setWsSecurityCredentials(property(camelContext, java.util.Map.class, value)); return true; + case "wssecuritypassword": + case "wsSecurityPassword": target.setWsSecurityPassword(property(camelContext, java.lang.String.class, value)); return true; + case "wssecuritypasswordtype": + case "wsSecurityPasswordType": target.setWsSecurityPasswordType(property(camelContext, java.lang.String.class, value)); return true; + case "wssecurityusername": + case "wsSecurityUsername": target.setWsSecurityUsername(property(camelContext, java.lang.String.class, value)); return true; case "wsdlurl": case "wsdlURL": target.setWsdlURL(property(camelContext, java.lang.String.class, value)); return true; default: return false; @@ -165,6 +175,16 @@ public class CxfEndpointConfigurer extends PropertyConfigurerSupport implements case "wrapped": return boolean.class; case "wrappedstyle": case "wrappedStyle": return java.lang.Boolean.class; + case "wssecuritycallbackhandler": + case "wsSecurityCallbackHandler": return javax.security.auth.callback.CallbackHandler.class; + case "wssecuritycredentials": + case "wsSecurityCredentials": return java.util.Map.class; + case "wssecuritypassword": + case "wsSecurityPassword": return java.lang.String.class; + case "wssecuritypasswordtype": + case "wsSecurityPasswordType": return java.lang.String.class; + case "wssecurityusername": + case "wsSecurityUsername": return java.lang.String.class; case "wsdlurl": case "wsdlURL": return java.lang.String.class; default: return null; @@ -241,6 +261,16 @@ public class CxfEndpointConfigurer extends PropertyConfigurerSupport implements case "wrapped": return target.isWrapped(); case "wrappedstyle": case "wrappedStyle": return target.getWrappedStyle(); + case "wssecuritycallbackhandler": + case "wsSecurityCallbackHandler": return target.getWsSecurityCallbackHandler(); + case "wssecuritycredentials": + case "wsSecurityCredentials": return target.getWsSecurityCredentials(); + case "wssecuritypassword": + case "wsSecurityPassword": return target.getWsSecurityPassword(); + case "wssecuritypasswordtype": + case "wsSecurityPasswordType": return target.getWsSecurityPasswordType(); + case "wssecurityusername": + case "wsSecurityUsername": return target.getWsSecurityUsername(); case "wsdlurl": case "wsdlURL": return target.getWsdlURL(); default: return null; @@ -253,6 +283,8 @@ public class CxfEndpointConfigurer extends PropertyConfigurerSupport implements case "properties": return java.lang.Object.class; case "serviceclass": case "serviceClass": return java.lang.Object.class; + case "wssecuritycredentials": + case "wsSecurityCredentials": return java.lang.String.class; default: return null; } } diff --git a/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointUriFactory.java b/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointUriFactory.java index 5fc4c2799284..44af904133af 100644 --- a/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointUriFactory.java +++ b/components/camel-cxf/camel-cxf-soap/src/generated/java/org/apache/camel/component/cxf/jaxws/CxfEndpointUriFactory.java @@ -24,7 +24,7 @@ public class CxfEndpointUriFactory extends org.apache.camel.support.component.En private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES; private static final Map<String, String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(39); + Set<String> props = new HashSet<>(44); props.add("address"); props.add("allowStreaming"); props.add("beanId"); @@ -63,11 +63,18 @@ public class CxfEndpointUriFactory extends org.apache.camel.support.component.En props.add("username"); props.add("wrapped"); props.add("wrappedStyle"); + props.add("wsSecurityCallbackHandler"); + props.add("wsSecurityCredentials"); + props.add("wsSecurityPassword"); + props.add("wsSecurityPasswordType"); + props.add("wsSecurityUsername"); props.add("wsdlURL"); PROPERTY_NAMES = Collections.unmodifiableSet(props); - Set<String> secretProps = new HashSet<>(2); + Set<String> secretProps = new HashSet<>(4); secretProps.add("password"); secretProps.add("username"); + secretProps.add("wsSecurityPassword"); + secretProps.add("wsSecurityUsername"); SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps); ENDPOINT_IDENTITY_PROPERTY_NAMES = Collections.emptySet(); Map<String, String> prefixes = new HashMap<>(1); diff --git a/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json b/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json index 7851f4f5e994..6ce341fc9082 100644 --- a/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json +++ b/components/camel-cxf/camel-cxf-soap/src/generated/resources/META-INF/org/apache/camel/component/cxf/jaxws/cxf.json @@ -81,11 +81,16 @@ "skipFaultLogging": { "index": 30, "kind": "parameter", "displayName": "Skip Fault Logging", "group": "logging", "label": "logging", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to skip the log entry that the PhaseInterceptorChain writes when an interceptor throws an exception, for example the exception of a failed exchange of the consumer. Sets the CXF property or [...] "password": { "index": 31, "kind": "parameter", "displayName": "Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The password for HTTP Basic authentication. The producer puts it, together with the user name, in the protocol header Authorization of its HTTP requests. Only used when the username option is set. Not used f [...] "username": { "index": 32, "kind": "parameter", "displayName": "Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The user name for HTTP Basic authentication. The producer puts it, together with the password, in the protocol header Authorization of its HTTP requests. Only used when the password option is set. Not used f [...] - "bindingId": { "index": 33, "kind": "parameter", "displayName": "Binding Id", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of the CXF binding, which is a namespace URI, for example http:\/\/cxf.apache.org\/bindings\/xformat for the XML binding without a SOAP envelope. If not set, CXF uses the binding of the wsdl:port. The id http:\/\/schemas [...] - "portName": { "index": 34, "kind": "parameter", "displayName": "Port Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL port, which is the name attribute of the wsdl:port element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderPort." }, - "publishedEndpointUrl": { "index": 35, "kind": "parameter", "displayName": "Published Endpoint Url", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The address to publish in the WSDL that the consumer serves at the service address followed by ?wsdl. It replaces the location of the address element in the wsdl:port. Use it when clients reach the servic [...] - "serviceClass": { "index": 36, "kind": "parameter", "displayName": "Service Class", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.Class<java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, "description": "The Java class of the service, for example a service endpoint interface or a class that implements one. Written as a fully qualified class name, for example org.example.orders.OrderService. Required when [...] - "serviceName": { "index": 37, "kind": "parameter", "displayName": "Service Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL service, which is the name attribute of the wsdl:service element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderService. If not set and wsdlURL points to a W [...] - "wsdlURL": { "index": 38, "kind": "parameter", "displayName": "Wsdl URL", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The location of the WSDL. Can be on the classpath, file system, or be hosted remotely." } + "wsSecurityCallbackHandler": { "index": 33, "kind": "parameter", "displayName": "WS-Security Callback Handler", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "javax.security.auth.callback.CallbackHandler", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom javax.security.auth.callback.CallbackHandler for the WS-Security UsernameToken. CXF calls it with an org.apache.wss4j.common.ext.WSPasswordCallback [...] + "wsSecurityCredentials": { "index": 34, "kind": "parameter", "displayName": "WS-Security Credentials", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.String>", "deprecated": false, "autowired": false, "secret": false, "description": "A map of user name to password with the users that the consumer accepts in a WS-Security UsernameToken, as a reference to a java.util.Map bean, for example #bean:users [...] + "wsSecurityPassword": { "index": 35, "kind": "parameter", "displayName": "WS-Security Password", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The password of a WS-Security UsernameToken. The producer sends it in the UsernameToken, and the consumer requires it for the user of the wsSecurityUsername option." }, + "wsSecurityPasswordType": { "index": 36, "kind": "parameter", "displayName": "WS-Security Password Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "Text", "Digest" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Text", "description": "The type of the password in a WS-Security UsernameToken: Text for PasswordText, or Digest for PasswordDigest. The producer sends this type, and t [...] + "wsSecurityUsername": { "index": 37, "kind": "parameter", "displayName": "WS-Security Username", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "description": "The user name of a WS-Security UsernameToken. The producer sends a UsernameToken with this user name in the SOAP header of its requests. The consumer accepts only this user, with the pa [...] + "bindingId": { "index": 38, "kind": "parameter", "displayName": "Binding Id", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of the CXF binding, which is a namespace URI, for example http:\/\/cxf.apache.org\/bindings\/xformat for the XML binding without a SOAP envelope. If not set, CXF uses the binding of the wsdl:port. The id http:\/\/schemas [...] + "portName": { "index": 39, "kind": "parameter", "displayName": "Port Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL port, which is the name attribute of the wsdl:port element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderPort." }, + "publishedEndpointUrl": { "index": 40, "kind": "parameter", "displayName": "Published Endpoint Url", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The address to publish in the WSDL that the consumer serves at the service address followed by ?wsdl. It replaces the location of the address element in the wsdl:port. Use it when clients reach the servic [...] + "serviceClass": { "index": 41, "kind": "parameter", "displayName": "Service Class", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.Class<java.lang.Object>", "deprecated": false, "autowired": false, "secret": false, "description": "The Java class of the service, for example a service endpoint interface or a class that implements one. Written as a fully qualified class name, for example org.example.orders.OrderService. Required when [...] + "serviceName": { "index": 42, "kind": "parameter", "displayName": "Service Name", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The WSDL service, which is the name attribute of the wsdl:service element. Written as a QName in the form {namespaceURI}localPart, for example {http:\/\/example.org\/orders}OrderService. If not set and wsdlURL points to a W [...] + "wsdlURL": { "index": 43, "kind": "parameter", "displayName": "Wsdl URL", "group": "service", "label": "service", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The location of the WSDL. Can be on the classpath, file system, or be hosted remotely." } } } diff --git a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc index 025de9a0256c..4ae5e343d1c9 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc +++ b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc @@ -121,6 +121,82 @@ Using CXF with Spring Boot or Quarkus comes automatic integrated with the embedd See more details in the https://cxf.apache.org/docs/http-transport.html[CXF Transport] documentation. +== WS-Security UsernameToken + +The `wsSecurity` options set up a WS-Security UsernameToken without Java code. The producer sends a UsernameToken in +the SOAP header of its requests, and the consumer rejects a request without a valid UsernameToken with a SOAP fault. +The options need the `org.apache.cxf:cxf-rt-ws-security` dependency, which `camel-cxf-soap` does not bring by itself. + +NOTE: The `username` and `password` options are for HTTP Basic authentication, not for WS-Security. + +[cols="1,2,2",options="header"] +|=== +| Option | Producer | Consumer +| `wsSecurityUsername` | The user name to send. | The one user that is accepted. +| `wsSecurityPassword` | The password to send. | The password of that user. +| `wsSecurityPasswordType` | `Text` (default) sends a PasswordText, `Digest` a PasswordDigest. | The password type that is required. +| `wsSecurityCredentials` | Not used. | A `java.util.Map` bean of user name to password, to accept more than one user. +| `wsSecurityCallbackHandler` | A `CallbackHandler` bean that sets the password, instead of `wsSecurityPassword`. | A `CallbackHandler` bean that looks up the password of any user, for example from a vault. +|=== + +When the WSDL of the service has a WS-SecurityPolicy, the policy decides how the UsernameToken is sent and checked, +including the password type, and the options give the user name, the password and the callback handler to the policy. +When the WSDL has no WS-SecurityPolicy, or there is no WSDL, the endpoint adds the CXF `WSS4JOutInterceptor` (producer) +or `WSS4JInInterceptor` (consumer) for the UsernameToken. + +The consumer sets the authenticated user in the `CamelAuthentication` header, as a `javax.security.auth.Subject`. + +The options are not supported with `dataFormat=RAW`, as CXF does not process the SOAP envelope in this mode. + +WARNING: A UsernameToken with a plain text password must only be sent over HTTPS. `Digest` is no replacement for +HTTPS: it uses SHA-1, and the consumer needs the plain password to check it. + +A consumer that accepts two users with a PasswordDigest: + +[source,yaml] +---- +- beans: + - name: users + type: java.util.HashMap + properties: + alice: "{{alice.password}}" + bob: "{{bob.password}}" +- route: + from: + uri: cxf://https://0.0.0.0:8443/orders + parameters: + wsdlURL: classpath:orders.wsdl + dataFormat: PAYLOAD + wsSecurityCredentials: "#bean:users" + wsSecurityPasswordType: Digest + steps: + - log: "Order request from ${header.CamelAuthentication}" +---- + +A producer that calls this service: + +[source,yaml] +---- +- route: + from: + uri: direct:getOrder + steps: + - to: + uri: cxf://https://orders.example.com/orders + parameters: + wsdlURL: classpath:orders.wsdl + dataFormat: PAYLOAD + defaultOperationName: getOrder + wsSecurityUsername: alice + wsSecurityPassword: "{{alice.password}}" + wsSecurityPasswordType: Digest +---- + +Other WS-Security features, such as a Timestamp, a signature or encryption, are set up with the CXF properties in +`properties.*`, or with CXF interceptors or a `cxfConfigurer` in Java code. A value of `properties.*` that is a +`#bean:name` reference is resolved from the registry, for example +`properties.security.callback-handler=#bean:myCallbackHandler`. A plain `#name` is not resolved. + == Usage === RAW Mode diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java index 1423dde3dafe..66d36e7e3b31 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java +++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java @@ -88,10 +88,8 @@ public class CxfConsumer extends DefaultConsumer implements Suspendable { ServerFactoryBean svrBean = cxfEndpoint.createServerFactoryBean(); svrBean.setInvoker(new CxfConsumerInvoker(cxfEndpoint)); final Server ret = svrBean.create(); - // Apply the server configurer if it is possible - if (cxfEndpoint.getCxfConfigurer() != null) { - cxfEndpoint.getCxfConfigurer().configureServer(ret); - } + // apply the server configurers: the custom cxfConfigurer, and the ones of the endpoint options (WS-Security) + cxfEndpoint.getChainedCxfConfigurer().configureServer(ret); ret.getEndpoint().getEndpointInfo().setProperty("serviceClass", cxfEndpoint.getServiceClass()); if (ObjectHelper.isNotEmpty(cxfEndpoint.getPublishedEndpointUrl())) { ret.getEndpoint().getEndpointInfo().setProperty("publishedEndpointUrl", cxfEndpoint.getPublishedEndpointUrl()); diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java index 648eb94e4623..517df0cd790a 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java +++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java @@ -32,6 +32,7 @@ import jakarta.xml.ws.WebServiceProvider; import jakarta.xml.ws.handler.Handler; import javax.net.ssl.HostnameVerifier; +import javax.security.auth.callback.CallbackHandler; import javax.wsdl.Definition; import javax.wsdl.WSDLException; import javax.xml.namespace.QName; @@ -399,6 +400,37 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade + " the protocol header Authorization of its HTTP requests. Only used when the username option is" + " set. Not used for reading the WSDL that wsdlURL points to. The consumer does not use it.") private String password; + @UriParam(label = "security", displayName = "WS-Security Username", security = "secret", + description = "The user name of a WS-Security UsernameToken. The producer sends a UsernameToken with this user" + + " name in the SOAP header of its requests. The consumer accepts only this user, with the" + + " password of the wsSecurityPassword option, unless wsSecurityCallbackHandler or" + + " wsSecurityCredentials is set. Needs the org.apache.cxf:cxf-rt-ws-security dependency." + + " Send a UsernameToken with a plain text password over HTTPS only.") + private String wsSecurityUsername; + @UriParam(label = "security", displayName = "WS-Security Password", security = "secret", + description = "The password of a WS-Security UsernameToken. The producer sends it in the UsernameToken, and" + + " the consumer requires it for the user of the wsSecurityUsername option.") + private String wsSecurityPassword; + @UriParam(label = "security", displayName = "WS-Security Password Type", enums = "Text,Digest", defaultValue = "Text", + description = "The type of the password in a WS-Security UsernameToken: Text for PasswordText, or Digest for" + + " PasswordDigest. The producer sends this type, and the consumer requires it. Not used when" + + " the WSDL of the service has a WS-SecurityPolicy, which then decides the type. Digest is no" + + " replacement for HTTPS: it uses SHA-1, and the consumer needs the plain password.") + private String wsSecurityPasswordType = "Text"; + @UriParam(label = "security", displayName = "WS-Security Callback Handler", + description = "To use a custom javax.security.auth.callback.CallbackHandler for the WS-Security" + + " UsernameToken. CXF calls it with an org.apache.wss4j.common.ext.WSPasswordCallback that" + + " names the user, and the handler sets the password of that user. The producer uses it" + + " instead of wsSecurityPassword. The consumer uses it to look up the password of any user," + + " for example from a vault, instead of wsSecurityUsername, wsSecurityPassword and" + + " wsSecurityCredentials.") + private CallbackHandler wsSecurityCallbackHandler; + @UriParam(label = "security", displayName = "WS-Security Credentials", + description = "A map of user name to password with the users that the consumer accepts in a WS-Security" + + " UsernameToken, as a reference to a java.util.Map bean, for example #bean:users. Used instead" + + " of wsSecurityUsername and wsSecurityPassword to accept more than one user without Java" + + " code. Not used when wsSecurityCallbackHandler is set. The producer does not use it.") + private Map<String, String> wsSecurityCredentials; @UriParam(label = "advanced", prefix = "properties.", multiValue = true) private Map<String, Object> properties; @UriParam(label = "producer", @@ -1305,6 +1337,28 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade if (cxfBinding instanceof HeaderFilterStrategyAware headerFilterStrategyAware) { headerFilterStrategyAware.setHeaderFilterStrategy(getHeaderFilterStrategy()); } + if (isWsSecurityUsernameTokenEnabled()) { + validateWsSecurityOptions(); + } + } + + private void validateWsSecurityOptions() { + if (getDataFormat().dealias() == DataFormat.RAW) { + // CXF does not process the SOAP envelope in RAW mode, so no token would be sent or checked + throw new IllegalArgumentException( + "The wsSecurity options are not supported with dataFormat=RAW. Use PAYLOAD, POJO or CXF_MESSAGE instead."); + } + if (!"Text".equals(wsSecurityPasswordType) && !"Digest".equals(wsSecurityPasswordType)) { + throw new IllegalArgumentException( + "The option wsSecurityPasswordType must be Text or Digest, was: " + wsSecurityPasswordType); + } + try { + getCamelContext().getClassResolver() + .resolveMandatoryClass("org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"); + } catch (ClassNotFoundException e) { + throw new IllegalStateException( + "The wsSecurity options need the org.apache.cxf:cxf-rt-ws-security dependency on the classpath", e); + } } @Override @@ -1351,11 +1405,65 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade this.username = username; } + public String getWsSecurityUsername() { + return wsSecurityUsername; + } + + public void setWsSecurityUsername(String wsSecurityUsername) { + this.wsSecurityUsername = wsSecurityUsername; + } + + public String getWsSecurityPassword() { + return wsSecurityPassword; + } + + public void setWsSecurityPassword(String wsSecurityPassword) { + this.wsSecurityPassword = wsSecurityPassword; + } + + public String getWsSecurityPasswordType() { + return wsSecurityPasswordType; + } + + public void setWsSecurityPasswordType(String wsSecurityPasswordType) { + this.wsSecurityPasswordType = wsSecurityPasswordType; + } + + public CallbackHandler getWsSecurityCallbackHandler() { + return wsSecurityCallbackHandler; + } + + public void setWsSecurityCallbackHandler(CallbackHandler wsSecurityCallbackHandler) { + this.wsSecurityCallbackHandler = wsSecurityCallbackHandler; + } + + public Map<String, String> getWsSecurityCredentials() { + return wsSecurityCredentials; + } + + public void setWsSecurityCredentials(Map<String, String> wsSecurityCredentials) { + this.wsSecurityCredentials = wsSecurityCredentials; + } + + /** + * Whether a WS-Security UsernameToken option (wsSecurityUsername, wsSecurityPassword, wsSecurityCallbackHandler or + * wsSecurityCredentials) is set. + */ + public boolean isWsSecurityUsernameTokenEnabled() { + return ObjectHelper.isNotEmpty(wsSecurityUsername) || ObjectHelper.isNotEmpty(wsSecurityPassword) + || wsSecurityCallbackHandler != null || wsSecurityCredentials != null; + } + public CxfConfigurer getChainedCxfConfigurer() { - return ChainedCxfConfigurer + ChainedCxfConfigurer answer = ChainedCxfConfigurer .create(getNullSafeCxfConfigurer(), SslCxfConfigurer.create(sslContextParameters, getCamelContext())) .addChild(HostnameVerifierCxfConfigurer.create(hostnameVerifier)); + if (isWsSecurityUsernameTokenEnabled()) { + // only loaded when an option is set, as it needs the optional cxf-rt-ws-security dependency + answer = answer.addChild(WsSecurityUsernameTokenConfigurer.create(this)); + } + return answer; } private CxfConfigurer getNullSafeCxfConfigurer() { diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/WsSecurityUsernameTokenConfigurer.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/WsSecurityUsernameTokenConfigurer.java new file mode 100644 index 000000000000..2695ffd1c093 --- /dev/null +++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/WsSecurityUsernameTokenConfigurer.java @@ -0,0 +1,250 @@ +/* + * 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.component.cxf.jaxws; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.camel.util.ObjectHelper; +import org.apache.cxf.Bus; +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.endpoint.Endpoint; +import org.apache.cxf.endpoint.Server; +import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.rt.security.SecurityConstants; +import org.apache.cxf.service.model.BindingOperationInfo; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.ws.policy.PolicyEngine; +import org.apache.cxf.ws.policy.PolicyEngineImpl; +import org.apache.cxf.ws.policy.PolicyProvider; +import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor; +import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; +import org.apache.neethi.Assertion; +import org.apache.neethi.PolicyComponent; +import org.apache.neethi.PolicyContainingAssertion; +import org.apache.neethi.PolicyOperator; +import org.apache.wss4j.common.ConfigurationConstants; +import org.apache.wss4j.common.WSS4JConstants; +import org.apache.wss4j.common.ext.WSPasswordCallback; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Sets up a WS-Security UsernameToken from the wsSecurity options of the {@link CxfEndpoint}. + * <p> + * It always sets the CXF security properties (user name, password and callback handler), which the WS-SecurityPolicy + * interceptors use when the WSDL of the service has a WS-SecurityPolicy. When it has none, it also adds a + * {@link WSS4JOutInterceptor} (producer) or a {@link WSS4JInInterceptor} (consumer) for the UsernameToken. It does not + * add both, as the security header would then be processed twice. + * <p> + * This is the only class of the endpoint options that uses the optional cxf-rt-ws-security dependency, and it is loaded + * only when one of the options is set. + */ +final class WsSecurityUsernameTokenConfigurer implements CxfConfigurer { + + private static final Logger LOG = LoggerFactory.getLogger(WsSecurityUsernameTokenConfigurer.class); + + // the namespaces of WS-SecurityPolicy 1.1, 1.2 and 1.3 + private static final Set<String> SECURITY_POLICY_NAMESPACES = Set.of( + "http://schemas.xmlsoap.org/ws/2005/07/securitypolicy", + "http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702", + "http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200802"); + + private final CxfEndpoint endpoint; + + private WsSecurityUsernameTokenConfigurer(CxfEndpoint endpoint) { + this.endpoint = endpoint; + } + + static CxfConfigurer create(CxfEndpoint endpoint) { + return new WsSecurityUsernameTokenConfigurer(endpoint); + } + + @Override + public void configure(AbstractWSDLBasedEndpointFactory factoryBean) { + // the client and server are configured once created, as the policy of the WSDL is known only then + } + + @Override + public void configureClient(Client client) { + String username = endpoint.getWsSecurityUsername(); + String password = endpoint.getWsSecurityPassword(); + CallbackHandler callbackHandler = endpoint.getWsSecurityCallbackHandler(); + if (ObjectHelper.isEmpty(username)) { + throw new IllegalArgumentException( + "The option wsSecurityUsername must be set to send a WS-Security UsernameToken"); + } + if (ObjectHelper.isEmpty(password) && callbackHandler == null) { + throw new IllegalArgumentException( + "The option wsSecurityPassword or wsSecurityCallbackHandler must be set to send a WS-Security" + + " UsernameToken"); + } + CallbackHandler handler = callbackHandler != null ? callbackHandler : new PasswordCallbackHandler(username, password); + + Endpoint ep = client.getEndpoint(); + ep.put(SecurityConstants.USERNAME, username); + if (ObjectHelper.isNotEmpty(password)) { + ep.put(SecurityConstants.PASSWORD, password); + } + ep.put(SecurityConstants.CALLBACK_HANDLER, handler); + + if (hasSecurityPolicy(client.getBus(), ep.getEndpointInfo())) { + LOG.debug("The WSDL of {} has a WS-SecurityPolicy, which sends the UsernameToken", endpoint); + } else { + Map<String, Object> props = new HashMap<>(); + props.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN); + props.put(ConfigurationConstants.USER, username); + props.put(ConfigurationConstants.PASSWORD_TYPE, passwordType()); + props.put(ConfigurationConstants.PW_CALLBACK_REF, handler); + ep.getOutInterceptors().add(new WSS4JOutInterceptor(props)); + LOG.debug("Added a WSS4JOutInterceptor that sends a UsernameToken to {}", endpoint); + } + } + + @Override + public void configureServer(Server server) { + CallbackHandler handler = serverCallbackHandler(); + + Endpoint ep = server.getEndpoint(); + ep.put(SecurityConstants.CALLBACK_HANDLER, handler); + + if (hasSecurityPolicy(endpoint.getBus(), ep.getEndpointInfo())) { + LOG.debug("The WSDL of {} has a WS-SecurityPolicy, which checks the UsernameToken", endpoint); + } else { + Map<String, Object> props = new HashMap<>(); + props.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN); + // on the inbound side the password type is the type that is required + props.put(ConfigurationConstants.PASSWORD_TYPE, passwordType()); + props.put(ConfigurationConstants.PW_CALLBACK_REF, handler); + ep.getInInterceptors().add(new WSS4JInInterceptor(props)); + LOG.debug("Added a WSS4JInInterceptor that requires a UsernameToken to {}", endpoint); + } + } + + private CallbackHandler serverCallbackHandler() { + if (endpoint.getWsSecurityCallbackHandler() != null) { + return endpoint.getWsSecurityCallbackHandler(); + } + if (endpoint.getWsSecurityCredentials() != null) { + return new PasswordCallbackHandler(endpoint.getWsSecurityCredentials()); + } + String username = endpoint.getWsSecurityUsername(); + String password = endpoint.getWsSecurityPassword(); + if (ObjectHelper.isEmpty(username) || ObjectHelper.isEmpty(password)) { + throw new IllegalArgumentException( + "The options wsSecurityUsername and wsSecurityPassword, or wsSecurityCredentials, or" + + " wsSecurityCallbackHandler must be set to check a WS-Security" + + " UsernameToken"); + } + return new PasswordCallbackHandler(username, password); + } + + private String passwordType() { + return "Digest".equals(endpoint.getWsSecurityPasswordType()) ? WSS4JConstants.PW_DIGEST : WSS4JConstants.PW_TEXT; + } + + /** + * Whether the WSDL of the endpoint has a WS-SecurityPolicy, on the service, the port, the binding, or an operation + * or message of the binding. + */ + static boolean hasSecurityPolicy(Bus bus, EndpointInfo ei) { + PolicyEngine engine = bus != null ? bus.getExtension(PolicyEngine.class) : null; + if (engine == null || !engine.isEnabled() || ei == null) { + return false; + } + if (!(engine instanceof PolicyEngineImpl engineImpl)) { + LOG.debug("Cannot check the WS-SecurityPolicy with the policy engine {}", engine); + return false; + } + Message message = new MessageImpl(); + for (PolicyProvider provider : engineImpl.getPolicyProviders()) { + if (isSecurityPolicy(provider.getEffectivePolicy(ei.getService(), message)) + || isSecurityPolicy(provider.getEffectivePolicy(ei, message))) { + return true; + } + if (ei.getBinding() == null) { + continue; + } + for (BindingOperationInfo boi : ei.getBinding().getOperations()) { + if (isSecurityPolicy(provider.getEffectivePolicy(boi, message)) + || boi.getInput() != null && isSecurityPolicy(provider.getEffectivePolicy(boi.getInput(), message)) + || boi.getOutput() != null + && isSecurityPolicy(provider.getEffectivePolicy(boi.getOutput(), message))) { + return true; + } + } + } + return false; + } + + private static boolean isSecurityPolicy(PolicyComponent component) { + if (component instanceof Assertion assertion) { + if (assertion.getName() != null + && SECURITY_POLICY_NAMESPACES.contains(assertion.getName().getNamespaceURI())) { + return true; + } + return assertion instanceof PolicyContainingAssertion pca && isSecurityPolicy(pca.getPolicy()); + } + if (component instanceof PolicyOperator operator) { + for (PolicyComponent child : operator.getPolicyComponents()) { + if (isSecurityPolicy(child)) { + return true; + } + } + } + return false; + } + + /** + * Sets the password of the user in a {@link WSPasswordCallback}, from a map of user name to password. It sets no + * password for an unknown user, so that the UsernameToken of that user is rejected. + */ + static final class PasswordCallbackHandler implements CallbackHandler { + + // a map bean may hold values that are not String, such as a number in YAML + private final Map<?, ?> passwords; + + PasswordCallbackHandler(String username, String password) { + this(Map.of(username, password)); + } + + PasswordCallbackHandler(Map<?, ?> passwords) { + this.passwords = passwords; + } + + @Override + public void handle(Callback[] callbacks) throws UnsupportedCallbackException { + for (Callback callback : callbacks) { + if (callback instanceof WSPasswordCallback pc) { + Object password = pc.getIdentifier() != null ? passwords.get(pc.getIdentifier()) : null; + if (password != null) { + pc.setPassword(password.toString()); + } + } else { + throw new UnsupportedCallbackException(callback); + } + } + } + } +} diff --git a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfWsSecurityUsernameTokenTest.java b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfWsSecurityUsernameTokenTest.java new file mode 100644 index 000000000000..eb1f4746d2ff --- /dev/null +++ b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfWsSecurityUsernameTokenTest.java @@ -0,0 +1,321 @@ +/* + * 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.component.cxf.jaxws; + +import java.security.Principal; +import java.util.List; +import java.util.Map; + +import javax.security.auth.Subject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.FailedToStartRouteException; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.cxf.common.message.CxfConstants; +import org.apache.camel.test.AvailablePortFinder; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.apache.cxf.binding.soap.SoapFault; +import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor; +import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; +import org.apache.wss4j.common.ext.WSPasswordCallback; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * WS-Security UsernameToken with the wsSecurity options of the endpoint, for a WSDL without and with a + * WS-SecurityPolicy, and #bean: references in properties.*. + */ +class CxfWsSecurityUsernameTokenTest extends CamelTestSupport { + + private static final String REQUEST + = "<getOrder xmlns=\"http://camel.apache.org/wssec/orders\"><orderId>1</orderId></getOrder>"; + + private static AvailablePortFinder.Port port; + + @BeforeAll + static void allocatePort() { + port = AvailablePortFinder.find(); + } + + @AfterAll + static void releasePort() { + if (port != null) { + port.release(); + } + } + + private static String address(String path) { + return "http://localhost:" + port.getPort() + "/CxfWsSecurityUsernameTokenTest/" + path; + } + + private static String server(String path, String wsdl, String options) { + return "cxf://" + address(path) + "?wsdlURL=classpath:wssec/" + wsdl + "&dataFormat=PAYLOAD" + options; + } + + private static String client(String path, String wsdl, String options) { + return "cxf://" + address(path) + "?wsdlURL=classpath:wssec/" + wsdl + + "&dataFormat=PAYLOAD&defaultOperationName=getOrder" + options; + } + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + context.getRegistry().bind("users", Map.of("bob", "builder", "carol", "secret")); + context.getRegistry().bind("serverCallback", new FixedPasswordCallbackHandler("alice", "wonderland")); + context.getRegistry().bind("clientCallback", new FixedPasswordCallbackHandler("alice", "wonderland")); + return context; + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + // no WS-Policy in the WSDL: one user, PasswordText + from(server("text", "orders.wsdl", "&wsSecurityUsername=alice&wsSecurityPassword=wonderland")) + .routeId("text").process(CxfWsSecurityUsernameTokenTest::reply); + // no WS-Policy in the WSDL: several users from a map bean, PasswordDigest + from(server("digest", "orders.wsdl", "&wsSecurityCredentials=#bean:users&wsSecurityPasswordType=Digest")) + .routeId("digest").process(CxfWsSecurityUsernameTokenTest::reply); + // a WS-SecurityPolicy in the WSDL: the policy asks for the UsernameToken, the handler checks it + from(server("policy", "orders-ut.wsdl", "&wsSecurityCallbackHandler=#bean:serverCallback")) + .routeId("policy").process(CxfWsSecurityUsernameTokenTest::reply); + // the CXF property set in properties.* with a #bean: reference + from(server("properties", "orders-ut.wsdl", "&properties.security.callback-handler=#bean:serverCallback")) + .routeId("properties").process(CxfWsSecurityUsernameTokenTest::reply); + } + }; + } + + private static void reply(Exchange exchange) { + Subject subject = exchange.getIn().getHeader(CxfConstants.AUTHENTICATION, Subject.class); + String user = subject == null + ? "none" + : subject.getPrincipals().stream().map(Principal::getName).findFirst().orElse("none"); + exchange.getMessage().setBody("<getOrderResponse xmlns=\"http://camel.apache.org/wssec/orders\">" + + "<orderId>1</orderId><user>" + user + "</user></getOrderResponse>"); + } + + private String call(String uri) { + Exchange exchange = template.request(uri, e -> e.getIn().setBody(REQUEST)); + if (exchange.getException() != null) { + throw new AssertionError("Unexpected exception", exchange.getException()); + } + return exchange.getMessage().getBody(String.class); + } + + private void callRejected(String uri) { + Exchange exchange = template.request(uri, e -> e.getIn().setBody(REQUEST)); + SoapFault fault = assertInstanceOf(SoapFault.class, exchange.getException()); + assertTrue(fault.getMessage().contains("security"), fault.getMessage()); + } + + @Test + void textWithoutPolicy() { + String reply = call(client("text", "orders.wsdl", "&wsSecurityUsername=alice&wsSecurityPassword=wonderland")); + assertTrue(reply.contains("<user>alice</user>"), reply); + } + + @Test + void textWithoutPolicyWrongPassword() { + callRejected(client("text", "orders.wsdl", "&wsSecurityUsername=alice&wsSecurityPassword=wrong")); + } + + @Test + void textWithoutPolicyNoToken() { + callRejected(client("text", "orders.wsdl", "")); + } + + @Test + void textWithoutPolicyClientCallbackHandler() { + String reply = call( + client("text", "orders.wsdl", "&wsSecurityUsername=alice&wsSecurityCallbackHandler=#bean:clientCallback")); + assertTrue(reply.contains("<user>alice</user>"), reply); + } + + @Test + void digestWithoutPolicy() { + String uri = client("digest", "orders.wsdl", + "&wsSecurityUsername=bob&wsSecurityPassword=builder&wsSecurityPasswordType=Digest"); + String reply = call(uri); + assertTrue(reply.contains("<user>bob</user>"), reply); + + String uri2 = client("digest", "orders.wsdl", + "&wsSecurityUsername=carol&wsSecurityPassword=secret&wsSecurityPasswordType=Digest"); + reply = call(uri2); + assertTrue(reply.contains("<user>carol</user>"), reply); + } + + @Test + void digestWithoutPolicyWrongPassword() { + callRejected(client("digest", "orders.wsdl", + "&wsSecurityUsername=bob&wsSecurityPassword=wrong&wsSecurityPasswordType=Digest")); + } + + @Test + void digestWithoutPolicyUnknownUser() { + callRejected(client("digest", "orders.wsdl", + "&wsSecurityUsername=mallory&wsSecurityPassword=builder&wsSecurityPasswordType=Digest")); + } + + @Test + void digestRequiredTextRejected() { + // the consumer requires PasswordDigest + callRejected(client("digest", "orders.wsdl", "&wsSecurityUsername=bob&wsSecurityPassword=builder")); + } + + @Test + void withPolicy() throws Exception { + String uri = client("policy", "orders-ut.wsdl", "&wsSecurityUsername=alice&wsSecurityPassword=wonderland"); + String reply = call(uri); + assertTrue(reply.contains("<user>alice</user>"), reply); + + // the policy sends and checks the token: no plain WSS4J interceptors as well + CxfProducer producer = (CxfProducer) context.getEndpoint(uri).createProducer(); + producer.start(); + try { + assertFalse(hasInterceptor(producer.getClient().getEndpoint().getOutInterceptors(), WSS4JOutInterceptor.class)); + } finally { + producer.stop(); + } + CxfConsumer consumer = (CxfConsumer) context.getRoute("policy").getConsumer(); + assertFalse(hasInterceptor(consumer.getServer().getEndpoint().getInInterceptors(), WSS4JInInterceptor.class)); + } + + @Test + void withoutPolicyAddsInterceptors() throws Exception { + String uri = client("text", "orders.wsdl", "&wsSecurityUsername=alice&wsSecurityPassword=wonderland"); + CxfProducer producer = (CxfProducer) context.getEndpoint(uri).createProducer(); + producer.start(); + try { + assertTrue(hasInterceptor(producer.getClient().getEndpoint().getOutInterceptors(), WSS4JOutInterceptor.class)); + } finally { + producer.stop(); + } + CxfConsumer consumer = (CxfConsumer) context.getRoute("text").getConsumer(); + assertTrue(hasInterceptor(consumer.getServer().getEndpoint().getInInterceptors(), WSS4JInInterceptor.class)); + } + + @Test + void withPolicyWrongPassword() { + callRejected(client("policy", "orders-ut.wsdl", "&wsSecurityUsername=alice&wsSecurityPassword=wrong")); + } + + @Test + void withPolicyPropertiesBeanReference() { + CxfEndpoint endpoint = (CxfEndpoint) context.getRoute("properties").getEndpoint(); + assertSame(context.getRegistry().lookupByName("serverCallback"), + endpoint.getProperties().get("security.callback-handler")); + + // the client side with the CXF properties of before, which work as the WSDL has a policy + String reply = call(client("properties", "orders-ut.wsdl", + "&properties.security.username=alice&properties.security.password=wonderland")); + assertTrue(reply.contains("<user>alice</user>"), reply); + + callRejected(client("properties", "orders-ut.wsdl", + "&properties.security.username=alice&properties.security.password=wrong")); + } + + @Test + void propertiesOnlyBeanPrefixResolved() { + // a value that only starts with # is free-form CXF configuration, and not a bean lookup + CxfEndpoint endpoint = context.getEndpoint( + client("text", "orders.wsdl", "&properties.security.password=#secret"), CxfEndpoint.class); + assertEquals("#secret", endpoint.getProperties().get("security.password")); + } + + @Test + void propertiesUnknownBean() { + Exception e = assertThrows(Exception.class, () -> context.getEndpoint( + client("text", "orders.wsdl", "&properties.security.callback-handler=#bean:doesNotExist"))); + assertTrue(e.getMessage().contains("doesNotExist"), e.getMessage()); + } + + @Test + void clientWithoutUsername() { + Exception e = assertThrows(Exception.class, () -> { + CxfProducer producer = (CxfProducer) context.getEndpoint( + client("text", "orders.wsdl", "&wsSecurityPassword=wonderland")).createProducer(); + producer.start(); + }); + assertTrue(e.getMessage().contains("wsSecurityUsername"), e.getMessage()); + } + + @Test + void rawNotSupported() { + Exception e = assertThrows(Exception.class, () -> context.getEndpoint( + "cxf://" + address("raw") + "?wsdlURL=classpath:wssec/orders.wsdl&dataFormat=RAW" + + "&wsSecurityUsername=alice&wsSecurityPassword=wonderland") + .createProducer().start()); + assertTrue(e.getMessage().contains("RAW"), e.getMessage()); + } + + @Test + void serverWithoutPassword() throws Exception { + FailedToStartRouteException e = assertThrows(FailedToStartRouteException.class, () -> { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from(server("nopassword", "orders.wsdl", "&wsSecurityUsername=alice")).routeId("nopassword") + .process(CxfWsSecurityUsernameTokenTest::reply); + } + }); + }); + Throwable cause = e; + while (cause.getCause() != null) { + cause = cause.getCause(); + } + assertTrue(cause.getMessage().contains("wsSecurityCredentials"), cause.getMessage()); + } + + private static boolean hasInterceptor(List<?> interceptors, Class<?> type) { + return interceptors.stream().anyMatch(type::isInstance); + } + + /** + * Sets the password of one user, as a server or a client password callback handler. + */ + static final class FixedPasswordCallbackHandler implements CallbackHandler { + private final String user; + private final String password; + + FixedPasswordCallbackHandler(String user, String password) { + this.user = user; + this.password = password; + } + + @Override + public void handle(Callback[] callbacks) { + for (Callback cb : callbacks) { + if (cb instanceof WSPasswordCallback pc && user.equals(pc.getIdentifier())) { + pc.setPassword(password); + } + } + } + } +} diff --git a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfWsSecurityYamlTest.java b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfWsSecurityYamlTest.java new file mode 100644 index 000000000000..e937b22e5913 --- /dev/null +++ b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfWsSecurityYamlTest.java @@ -0,0 +1,78 @@ +/* + * 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.component.cxf.jaxws; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.support.PluginHelper; +import org.apache.camel.support.ResourceHelper; +import org.apache.camel.test.AvailablePortFinder; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.apache.cxf.binding.soap.SoapFault; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * A YAML route that sets up a WS-Security UsernameToken client and server with endpoint options only. + */ +class CxfWsSecurityYamlTest extends CamelTestSupport { + + private static final String REQUEST + = "<getOrder xmlns=\"http://camel.apache.org/wssec/orders\"><orderId>1</orderId></getOrder>"; + + private static AvailablePortFinder.Port port; + + @BeforeAll + static void allocatePort() { + port = AvailablePortFinder.find(); + } + + @AfterAll + static void releasePort() { + if (port != null) { + port.release(); + } + } + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + context.getPropertiesComponent().addInitialProperty("wssec.port", Integer.toString(port.getPort())); + PluginHelper.getRoutesLoader(context) + .loadRoutes(ResourceHelper.resolveMandatoryResource(context, "classpath:wssec/wssec.camel.yaml")); + return context; + } + + @Test + void usernameTokenFromYaml() { + Exchange exchange = template.request("direct:yaml", e -> e.getIn().setBody(REQUEST)); + assertNull(exchange.getException()); + String reply = exchange.getMessage().getBody(String.class); + assertTrue(reply.contains("<user>ok</user>"), reply); + } + + @Test + void wrongPasswordFromYaml() { + Exchange exchange = template.request("direct:yamlBad", e -> e.getIn().setBody(REQUEST)); + assertInstanceOf(SoapFault.class, exchange.getException()); + } +} diff --git a/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/orders-ut.wsdl b/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/orders-ut.wsdl new file mode 100644 index 000000000000..033402cc40c4 --- /dev/null +++ b/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/orders-ut.wsdl @@ -0,0 +1,101 @@ +<?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. + +--> +<!-- The same service as orders.wsdl, with a WS-SecurityPolicy that asks for a UsernameToken (plain text: use it over https) --> +<wsdl:definitions name="OrderService" + targetNamespace="http://camel.apache.org/wssec/orders" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://camel.apache.org/wssec/orders" + xmlns:wsp="http://www.w3.org/ns/ws-policy" + xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" + xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> + + <!-- WS-SecurityPolicy: every request carries a WS-Security UsernameToken --> + <wsp:Policy wsu:Id="UsernameTokenPolicy"> + <wsp:ExactlyOne> + <wsp:All> + <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> + + <wsdl:types> + <xs:schema targetNamespace="http://camel.apache.org/wssec/orders" elementFormDefault="qualified"> + <xs:element name="getOrder"> + <xs:complexType> + <xs:sequence> + <xs:element name="orderId" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="getOrderResponse"> + <xs:complexType> + <xs:sequence> + <xs:element name="orderId" type="xs:string"/> + <xs:element name="user" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:schema> + </wsdl:types> + + <wsdl:message name="getOrderRequest"> + <wsdl:part name="parameters" element="tns:getOrder"/> + </wsdl:message> + <wsdl:message name="getOrderResponse"> + <wsdl:part name="parameters" element="tns:getOrderResponse"/> + </wsdl:message> + + <wsdl:portType name="OrderPortType"> + <wsdl:operation name="getOrder"> + <wsdl:input message="tns:getOrderRequest"/> + <wsdl:output message="tns:getOrderResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="OrderSoapBinding" type="tns:OrderPortType"> + <wsp:PolicyReference URI="#UsernameTokenPolicy"/> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getOrder"> + <soap:operation soapAction="http://camel.apache.org/wssec/orders/getOrder"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="OrderService"> + <wsdl:port name="OrderPort" binding="tns:OrderSoapBinding"> + <soap:address location="http://localhost:9000/orders"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/orders.wsdl b/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/orders.wsdl new file mode 100644 index 000000000000..856c77d72ee9 --- /dev/null +++ b/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/orders.wsdl @@ -0,0 +1,80 @@ +<?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. + +--> +<!-- A small document/literal wrapped SOAP 1.1 service without a WS-Policy, for the WS-Security UsernameToken tests --> +<wsdl:definitions name="OrderService" + targetNamespace="http://camel.apache.org/wssec/orders" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://camel.apache.org/wssec/orders"> + + <wsdl:types> + <xs:schema targetNamespace="http://camel.apache.org/wssec/orders" elementFormDefault="qualified"> + <xs:element name="getOrder"> + <xs:complexType> + <xs:sequence> + <xs:element name="orderId" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="getOrderResponse"> + <xs:complexType> + <xs:sequence> + <xs:element name="orderId" type="xs:string"/> + <xs:element name="user" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:schema> + </wsdl:types> + + <wsdl:message name="getOrderRequest"> + <wsdl:part name="parameters" element="tns:getOrder"/> + </wsdl:message> + <wsdl:message name="getOrderResponse"> + <wsdl:part name="parameters" element="tns:getOrderResponse"/> + </wsdl:message> + + <wsdl:portType name="OrderPortType"> + <wsdl:operation name="getOrder"> + <wsdl:input message="tns:getOrderRequest"/> + <wsdl:output message="tns:getOrderResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="OrderSoapBinding" type="tns:OrderPortType"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getOrder"> + <soap:operation soapAction="http://camel.apache.org/wssec/orders/getOrder"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="OrderService"> + <wsdl:port name="OrderPort" binding="tns:OrderSoapBinding"> + <soap:address location="http://localhost:9000/orders"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/wssec.camel.yaml b/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/wssec.camel.yaml new file mode 100644 index 000000000000..d2f1632507eb --- /dev/null +++ b/components/camel-cxf/camel-cxf-soap/src/test/resources/wssec/wssec.camel.yaml @@ -0,0 +1,64 @@ +# +# 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. +# + +# WS-Security UsernameToken with endpoint options only, no Java code +- beans: + - name: users + type: java.util.HashMap + properties: + dave: lister + kryten: "4000" +- route: + id: yaml-server + from: + uri: "cxf://http://localhost:{{wssec.port}}/CxfWsSecurityYamlTest/orders" + parameters: + wsdlURL: classpath:wssec/orders.wsdl + dataFormat: PAYLOAD + wsSecurityCredentials: "#bean:users" + wsSecurityPasswordType: Digest + steps: + - setBody: + constant: '<getOrderResponse xmlns="http://camel.apache.org/wssec/orders"><orderId>1</orderId><user>ok</user></getOrderResponse>' +- route: + id: yaml-client + from: + uri: direct:yaml + steps: + - to: + uri: "cxf://http://localhost:{{wssec.port}}/CxfWsSecurityYamlTest/orders" + parameters: + wsdlURL: classpath:wssec/orders.wsdl + dataFormat: PAYLOAD + defaultOperationName: getOrder + wsSecurityUsername: dave + wsSecurityPassword: lister + wsSecurityPasswordType: Digest +- route: + id: yaml-client-bad + from: + uri: direct:yamlBad + steps: + - to: + uri: "cxf://http://localhost:{{wssec.port}}/CxfWsSecurityYamlTest/orders" + parameters: + wsdlURL: classpath:wssec/orders.wsdl + dataFormat: PAYLOAD + defaultOperationName: getOrder + wsSecurityUsername: dave + wsSecurityPassword: wrong + wsSecurityPasswordType: Digest diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java index 943ea8a0beb0..b4a3e7d26ee5 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java @@ -309,6 +309,145 @@ public interface CxfEndpointBuilderFactory { doSetProperty("username", username); return this; } + /** + * To use a custom javax.security.auth.callback.CallbackHandler for the + * WS-Security UsernameToken. CXF calls it with an + * org.apache.wss4j.common.ext.WSPasswordCallback that names the user, + * and the handler sets the password of that user. The producer uses it + * instead of wsSecurityPassword. The consumer uses it to look up the + * password of any user, for example from a vault, instead of + * wsSecurityUsername, wsSecurityPassword and wsSecurityCredentials. + * + * The option is a: + * <code>javax.security.auth.callback.CallbackHandler</code> type. + * + * Group: security + * + * @param wsSecurityCallbackHandler the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityCallbackHandler(javax.security.auth.callback.CallbackHandler wsSecurityCallbackHandler) { + doSetProperty("wsSecurityCallbackHandler", wsSecurityCallbackHandler); + return this; + } + /** + * To use a custom javax.security.auth.callback.CallbackHandler for the + * WS-Security UsernameToken. CXF calls it with an + * org.apache.wss4j.common.ext.WSPasswordCallback that names the user, + * and the handler sets the password of that user. The producer uses it + * instead of wsSecurityPassword. The consumer uses it to look up the + * password of any user, for example from a vault, instead of + * wsSecurityUsername, wsSecurityPassword and wsSecurityCredentials. + * + * The option will be converted to a + * <code>javax.security.auth.callback.CallbackHandler</code> type. + * + * Group: security + * + * @param wsSecurityCallbackHandler the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityCallbackHandler(String wsSecurityCallbackHandler) { + doSetProperty("wsSecurityCallbackHandler", wsSecurityCallbackHandler); + return this; + } + /** + * A map of user name to password with the users that the consumer + * accepts in a WS-Security UsernameToken, as a reference to a + * java.util.Map bean, for example #bean:users. Used instead of + * wsSecurityUsername and wsSecurityPassword to accept more than one + * user without Java code. Not used when wsSecurityCallbackHandler is + * set. The producer does not use it. + * + * The option is a: <code>java.util.Map<java.lang.String, + * java.lang.String></code> type. + * + * Group: security + * + * @param wsSecurityCredentials the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityCredentials(Map<java.lang.String, java.lang.String> wsSecurityCredentials) { + doSetProperty("wsSecurityCredentials", wsSecurityCredentials); + return this; + } + /** + * A map of user name to password with the users that the consumer + * accepts in a WS-Security UsernameToken, as a reference to a + * java.util.Map bean, for example #bean:users. Used instead of + * wsSecurityUsername and wsSecurityPassword to accept more than one + * user without Java code. Not used when wsSecurityCallbackHandler is + * set. The producer does not use it. + * + * The option will be converted to a + * <code>java.util.Map<java.lang.String, java.lang.String></code> + * type. + * + * Group: security + * + * @param wsSecurityCredentials the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityCredentials(String wsSecurityCredentials) { + doSetProperty("wsSecurityCredentials", wsSecurityCredentials); + return this; + } + /** + * The password of a WS-Security UsernameToken. The producer sends it in + * the UsernameToken, and the consumer requires it for the user of the + * wsSecurityUsername option. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param wsSecurityPassword the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityPassword(String wsSecurityPassword) { + doSetProperty("wsSecurityPassword", wsSecurityPassword); + return this; + } + /** + * The type of the password in a WS-Security UsernameToken: Text for + * PasswordText, or Digest for PasswordDigest. The producer sends this + * type, and the consumer requires it. Not used when the WSDL of the + * service has a WS-SecurityPolicy, which then decides the type. Digest + * is no replacement for HTTPS: it uses SHA-1, and the consumer needs + * the plain password. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: Text + * Group: security + * + * @param wsSecurityPasswordType the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityPasswordType(String wsSecurityPasswordType) { + doSetProperty("wsSecurityPasswordType", wsSecurityPasswordType); + return this; + } + /** + * The user name of a WS-Security UsernameToken. The producer sends a + * UsernameToken with this user name in the SOAP header of its requests. + * The consumer accepts only this user, with the password of the + * wsSecurityPassword option, unless wsSecurityCallbackHandler or + * wsSecurityCredentials is set. Needs the + * org.apache.cxf:cxf-rt-ws-security dependency. Send a UsernameToken + * with a plain text password over HTTPS only. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param wsSecurityUsername the value to set + * @return the dsl builder + */ + default CxfEndpointConsumerBuilder wsSecurityUsername(String wsSecurityUsername) { + doSetProperty("wsSecurityUsername", wsSecurityUsername); + return this; + } /** * The id of the CXF binding, which is a namespace URI, for example * http://cxf.apache.org/bindings/xformat for the XML binding without a @@ -1443,6 +1582,145 @@ public interface CxfEndpointBuilderFactory { doSetProperty("username", username); return this; } + /** + * To use a custom javax.security.auth.callback.CallbackHandler for the + * WS-Security UsernameToken. CXF calls it with an + * org.apache.wss4j.common.ext.WSPasswordCallback that names the user, + * and the handler sets the password of that user. The producer uses it + * instead of wsSecurityPassword. The consumer uses it to look up the + * password of any user, for example from a vault, instead of + * wsSecurityUsername, wsSecurityPassword and wsSecurityCredentials. + * + * The option is a: + * <code>javax.security.auth.callback.CallbackHandler</code> type. + * + * Group: security + * + * @param wsSecurityCallbackHandler the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityCallbackHandler(javax.security.auth.callback.CallbackHandler wsSecurityCallbackHandler) { + doSetProperty("wsSecurityCallbackHandler", wsSecurityCallbackHandler); + return this; + } + /** + * To use a custom javax.security.auth.callback.CallbackHandler for the + * WS-Security UsernameToken. CXF calls it with an + * org.apache.wss4j.common.ext.WSPasswordCallback that names the user, + * and the handler sets the password of that user. The producer uses it + * instead of wsSecurityPassword. The consumer uses it to look up the + * password of any user, for example from a vault, instead of + * wsSecurityUsername, wsSecurityPassword and wsSecurityCredentials. + * + * The option will be converted to a + * <code>javax.security.auth.callback.CallbackHandler</code> type. + * + * Group: security + * + * @param wsSecurityCallbackHandler the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityCallbackHandler(String wsSecurityCallbackHandler) { + doSetProperty("wsSecurityCallbackHandler", wsSecurityCallbackHandler); + return this; + } + /** + * A map of user name to password with the users that the consumer + * accepts in a WS-Security UsernameToken, as a reference to a + * java.util.Map bean, for example #bean:users. Used instead of + * wsSecurityUsername and wsSecurityPassword to accept more than one + * user without Java code. Not used when wsSecurityCallbackHandler is + * set. The producer does not use it. + * + * The option is a: <code>java.util.Map<java.lang.String, + * java.lang.String></code> type. + * + * Group: security + * + * @param wsSecurityCredentials the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityCredentials(Map<java.lang.String, java.lang.String> wsSecurityCredentials) { + doSetProperty("wsSecurityCredentials", wsSecurityCredentials); + return this; + } + /** + * A map of user name to password with the users that the consumer + * accepts in a WS-Security UsernameToken, as a reference to a + * java.util.Map bean, for example #bean:users. Used instead of + * wsSecurityUsername and wsSecurityPassword to accept more than one + * user without Java code. Not used when wsSecurityCallbackHandler is + * set. The producer does not use it. + * + * The option will be converted to a + * <code>java.util.Map<java.lang.String, java.lang.String></code> + * type. + * + * Group: security + * + * @param wsSecurityCredentials the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityCredentials(String wsSecurityCredentials) { + doSetProperty("wsSecurityCredentials", wsSecurityCredentials); + return this; + } + /** + * The password of a WS-Security UsernameToken. The producer sends it in + * the UsernameToken, and the consumer requires it for the user of the + * wsSecurityUsername option. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param wsSecurityPassword the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityPassword(String wsSecurityPassword) { + doSetProperty("wsSecurityPassword", wsSecurityPassword); + return this; + } + /** + * The type of the password in a WS-Security UsernameToken: Text for + * PasswordText, or Digest for PasswordDigest. The producer sends this + * type, and the consumer requires it. Not used when the WSDL of the + * service has a WS-SecurityPolicy, which then decides the type. Digest + * is no replacement for HTTPS: it uses SHA-1, and the consumer needs + * the plain password. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: Text + * Group: security + * + * @param wsSecurityPasswordType the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityPasswordType(String wsSecurityPasswordType) { + doSetProperty("wsSecurityPasswordType", wsSecurityPasswordType); + return this; + } + /** + * The user name of a WS-Security UsernameToken. The producer sends a + * UsernameToken with this user name in the SOAP header of its requests. + * The consumer accepts only this user, with the password of the + * wsSecurityPassword option, unless wsSecurityCallbackHandler or + * wsSecurityCredentials is set. Needs the + * org.apache.cxf:cxf-rt-ws-security dependency. Send a UsernameToken + * with a plain text password over HTTPS only. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param wsSecurityUsername the value to set + * @return the dsl builder + */ + default CxfEndpointProducerBuilder wsSecurityUsername(String wsSecurityUsername) { + doSetProperty("wsSecurityUsername", wsSecurityUsername); + return this; + } /** * The id of the CXF binding, which is a namespace URI, for example * http://cxf.apache.org/bindings/xformat for the XML binding without a @@ -2353,6 +2631,145 @@ public interface CxfEndpointBuilderFactory { doSetProperty("username", username); return this; } + /** + * To use a custom javax.security.auth.callback.CallbackHandler for the + * WS-Security UsernameToken. CXF calls it with an + * org.apache.wss4j.common.ext.WSPasswordCallback that names the user, + * and the handler sets the password of that user. The producer uses it + * instead of wsSecurityPassword. The consumer uses it to look up the + * password of any user, for example from a vault, instead of + * wsSecurityUsername, wsSecurityPassword and wsSecurityCredentials. + * + * The option is a: + * <code>javax.security.auth.callback.CallbackHandler</code> type. + * + * Group: security + * + * @param wsSecurityCallbackHandler the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityCallbackHandler(javax.security.auth.callback.CallbackHandler wsSecurityCallbackHandler) { + doSetProperty("wsSecurityCallbackHandler", wsSecurityCallbackHandler); + return this; + } + /** + * To use a custom javax.security.auth.callback.CallbackHandler for the + * WS-Security UsernameToken. CXF calls it with an + * org.apache.wss4j.common.ext.WSPasswordCallback that names the user, + * and the handler sets the password of that user. The producer uses it + * instead of wsSecurityPassword. The consumer uses it to look up the + * password of any user, for example from a vault, instead of + * wsSecurityUsername, wsSecurityPassword and wsSecurityCredentials. + * + * The option will be converted to a + * <code>javax.security.auth.callback.CallbackHandler</code> type. + * + * Group: security + * + * @param wsSecurityCallbackHandler the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityCallbackHandler(String wsSecurityCallbackHandler) { + doSetProperty("wsSecurityCallbackHandler", wsSecurityCallbackHandler); + return this; + } + /** + * A map of user name to password with the users that the consumer + * accepts in a WS-Security UsernameToken, as a reference to a + * java.util.Map bean, for example #bean:users. Used instead of + * wsSecurityUsername and wsSecurityPassword to accept more than one + * user without Java code. Not used when wsSecurityCallbackHandler is + * set. The producer does not use it. + * + * The option is a: <code>java.util.Map<java.lang.String, + * java.lang.String></code> type. + * + * Group: security + * + * @param wsSecurityCredentials the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityCredentials(Map<java.lang.String, java.lang.String> wsSecurityCredentials) { + doSetProperty("wsSecurityCredentials", wsSecurityCredentials); + return this; + } + /** + * A map of user name to password with the users that the consumer + * accepts in a WS-Security UsernameToken, as a reference to a + * java.util.Map bean, for example #bean:users. Used instead of + * wsSecurityUsername and wsSecurityPassword to accept more than one + * user without Java code. Not used when wsSecurityCallbackHandler is + * set. The producer does not use it. + * + * The option will be converted to a + * <code>java.util.Map<java.lang.String, java.lang.String></code> + * type. + * + * Group: security + * + * @param wsSecurityCredentials the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityCredentials(String wsSecurityCredentials) { + doSetProperty("wsSecurityCredentials", wsSecurityCredentials); + return this; + } + /** + * The password of a WS-Security UsernameToken. The producer sends it in + * the UsernameToken, and the consumer requires it for the user of the + * wsSecurityUsername option. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param wsSecurityPassword the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityPassword(String wsSecurityPassword) { + doSetProperty("wsSecurityPassword", wsSecurityPassword); + return this; + } + /** + * The type of the password in a WS-Security UsernameToken: Text for + * PasswordText, or Digest for PasswordDigest. The producer sends this + * type, and the consumer requires it. Not used when the WSDL of the + * service has a WS-SecurityPolicy, which then decides the type. Digest + * is no replacement for HTTPS: it uses SHA-1, and the consumer needs + * the plain password. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: Text + * Group: security + * + * @param wsSecurityPasswordType the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityPasswordType(String wsSecurityPasswordType) { + doSetProperty("wsSecurityPasswordType", wsSecurityPasswordType); + return this; + } + /** + * The user name of a WS-Security UsernameToken. The producer sends a + * UsernameToken with this user name in the SOAP header of its requests. + * The consumer accepts only this user, with the password of the + * wsSecurityPassword option, unless wsSecurityCallbackHandler or + * wsSecurityCredentials is set. Needs the + * org.apache.cxf:cxf-rt-ws-security dependency. Send a UsernameToken + * with a plain text password over HTTPS only. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + * + * @param wsSecurityUsername the value to set + * @return the dsl builder + */ + default CxfEndpointBuilder wsSecurityUsername(String wsSecurityUsername) { + doSetProperty("wsSecurityUsername", wsSecurityUsername); + return this; + } /** * The id of the CXF binding, which is a namespace URI, for example * http://cxf.apache.org/bindings/xformat for the XML binding without a
