WS-SecurityPolicyPage edited by Colm O hEigeartaighChanges (2)
Full ContentWS-SecurityPolicyCXF 2.2 introduced support for using WS-SecurityPolicy to configure WSS4J instead of the custom configuration documented on the WS-Security page. However, all of the "background" material on the WS-Security page still applies and is important to know. WS-SecurityPolicy just provides an easier and more standards based way to configure and control the security requirements. With the security requirements documented in the WSDL as WS-Policy fragments, other tools such as .NET can easily know how to configure themselves to inter-operate with CXF services. Enabling WS-SecurityPolicyIn CXF 2.2, if the cxf-rt-ws-policy and cxf-rt-ws-security modules are available on the classpath, the WS-SecurityPolicy stuff is automatically enabled. Since the entire security runtime is policy driven, the only requirement is that the policy engine and security policies be available. If you are using the full "bundle" jar, all the security and policy stuff is already included. Policy descriptionWith WS-SecurityPolicy, the binding and/or operation in the wsdl references a WS-Policy fragment that describes the basic security requirements for interacting with that service. The WS-SecurityPolicy specification allows for specifying things like asymmetric/symmetric keys, using transports (https) for encryption, which parts/headers to encrypt or sign, whether to sign then encrypt or encrypt then sign, whether to include timestamps, whether to use derived keys, etc... Basically, it describes what actions are necessary to securely interact with the service described in the WSDL. However, the WS-SecurityPolicy fragment does not include "everything" that is required for a runtime to be able to able to create the messages. It does not describe things such as locations of key stores, user names and passwords, etc... Those need to be configured in at runtime to augment the WS-SecurityPolicy fragment. Configuring the extra propertiesThere are several extra properties that may need to be set to provide the additional bits of information to the runtime. Note that you should check that a particular property is supported in the version of CXF you are using. User properties
Callback Class and Crypto properties
Boolean configuration tags, e.g. the value should be "true" or "false".
Other properties
Note: for Symmetric bindings that specify a protection token, the ws-security-encryption properties are used. Configuring via SpringThe properties are easily configured as client or endpoint properties--use the former for the SOAP client, the latter for the web service provider. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <jaxws:client name="{http://cxf.apache.org}MyPortName" createdFromAPI="true"> <jaxws:properties> <entry key="ws-security.callback-handler" value="interop.client.KeystorePasswordCallback"/> <entry key="ws-security.signature.properties" value="etc/client.properties"/> <entry key="ws-security.encryption.properties" value="etc/service.properties"/> <entry key="ws-security.encryption.username" value="servicekeyalias"/> </jaxws:properties> </jaxws:client> </beans> For the jaxws:client's name attribute above, use the namespace of the WSDL along with the name attribute of the desired wsdl:port element under the WSDL's service section. (See here and here for an example.) <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <jaxws:endpoint id="MyService" address="https://localhost:9001/MyService" serviceName="interop:MyService" endpointName="interop:MyServiceEndpoint" implementor="com.foo.MyService"> <jaxws:properties> <entry key="ws-security.callback-handler" value="interop.client.UTPasswordCallback"/> <entry key="ws-security.signature.properties" value="etc/keystore.properties"/> <entry key="ws-security.encryption.properties" value="etc/truststore.properties"/> <entry key="ws-security.encryption.username" value="useReqSigCert"/> </jaxws:properties> </jaxws:endpoint> </beans> See this blog entry for a more end-to-end example of using WS-SecurityPolicy with X.509 keys. Configuring via API'sConfiguring the properties for the client just involves setting the properties in the client's RequestContext: Map<String, Object> ctx = ((BindingProvider)port).getRequestContext(); ctx.put("ws-security.encryption.properties", properties); port.echoString("hello");
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
- [CONF] Apache CXF Documentation > WS-SecurityPolicy confluence
