Java Web 服务: WS-Security 的细粒度使用
2009-11-05 00:00:00 来源:WEB开发网Ant build.xml 使用了一个 PolicyTool 程序(包含在代码下载中)将 清单 4 中的策略(即下载中的 rampart-client-policy.xml,位于根目录)合并到 services.xml。修改过的 services.xml 如 清单 5 所示(针对宽度和长度进行了编辑):
清单 5. 合并后的 services.xml<serviceGroup>
<service name="library-granular">
<messageReceivers>
<messageReceiver class=
"com.sosnoski.ws.library.adb.LibraryGranularMessageReceiverInOut"
mep="http://www.w3.org/ns/wsdl/in-out"/>
</messageReceivers>
<parameter name="ServiceClass"
>com.sosnoski.ws.library.adb.LibraryGranularImpl</parameter>
<parameter name="useOriginalwsdl">true</parameter>
<parameter name="modifyUserWSDLPortAddress">true</parameter>
<operation mep="http://www.w3.org/ns/wsdl/in-out" name="getBook"
namespace="http://ws.sosnoski.com/library/wsdl">
<actionMapping>urn:getBook</actionMapping>
<outputActionMapping>.../getBookResponse</outputActionMapping>
</operation>
<operation mep="http://www.w3.org/ns/wsdl/in-out" name="getBooksByType"
namespace="http://ws.sosnoski.com/library/wsdl">
<actionMapping>urn:getBooksByType</actionMapping>
<outputActionMapping>.../getBooksByTypeResponse</outputActionMapping>
<module ref="rampart"/>
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu=
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:user>serverkey</ramp:user>
...
</ramp:RampartConfig>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</operation>
<operation mep="http://www.w3.org/ns/wsdl/in-out" name="addBook"
namespace="http://ws.sosnoski.com/library/wsdl">
<actionMapping>urn:addBook</actionMapping>
<outputActionMapping>
http://ws.sosnoski.com/library/wsdl/Library/addBookResponse
</outputActionMapping>
<module ref="rampart"/>
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu=
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne>
<wsp:All>
<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:user>serverkey</ramp:user>
...
</ramp:RampartConfig>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</operation>
</service>
</serviceGroup>
更多精彩
赞助商链接