« Return to Thread: [CONF] Apache CXF Documentation: WS-SecurityPolicy (page edited)
by confluence-2
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View in Thread
|
Page Edited :
CXF20DOC :
WS-SecurityPolicy
WS-SecurityPolicy has been edited by Glen Mazza (Jul 08, 2009). Change summary: Placed a full Spring config file to show how policies are added--concerned this was not obvious for most users. CXF 2.2 introduced support for using WS-SecurityPolicy Note: at this point, WS-SecurityPolicy support is ONLY available for "WSDL first" scenarios. The WS-SecurityPolicy fragments can only be pulled from WSDL. In the future, we plan to enable various code first scenarios as well, but at this time, only WSDL first is available. 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 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 propertiesWith CXF 2.2, there are several extra properties that may need to be set to provide the additional bits of information to the runtime:
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 latter for web service provider configuration: <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}MyService" createdFromAPI="true"> <jaxws:properties> <entry key="ws-security.username" value="Alice"/> <entry key="ws-security.callback-handler" value="interop.client.KeystorePasswordCallback"/> <entry key="ws-security.signature.properties" value="etc/alice.properties"/> <entry key="ws-security.encryption.properties" value="etc/bob.properties"/> </jaxws:properties> </jaxws:client> </beans> <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.username" value="Alice"/> <entry key="ws-security.callback-handler" value="interop.client.UTPasswordCallback"/> </jaxws:properties> </jaxws:endpoint> </beans> Configuring via API'sConfiguring the properties for the client just involves setting the properties in the clients RequestContext: Map<String, Object> ctx = ((BindingProvider)port).getRequestContext(); ctx.put("ws-security.ws-security.encryption.properties", properties); port.echoString("hello"); |
« Return to Thread: [CONF] Apache CXF Documentation: WS-SecurityPolicy (page edited)
| Free embeddable forum powered by Nabble | Forum Help |