*设为首页
*加入收藏
热门关键字: JAVA
>>当前位置:Java大本营>环境配置>文章内容
Injecting the security token into the SOAP header
作者: 发布时间:2008-09-03 18:51:11
When registering a service context with the Context Registry service, a security token is returned that you can use to refer to the service context that is stored on the server. You can then use the security token in subsequent requests to the service, so the consumer does not have to re‑send service context information over the wire. To utilize this feature, you must inject the security token into the SOAP header before calling the service. To do this, create a WS‑Security compliant header that contains the security token. Once the header is created, you can add it to the SOAP header. The following code sample shows a method that creates the security header given the security token that was returned by the Context Registry Service:
Example 63.
Creating the security header in Axis2
private OMElement getSecurityHeader(String token)
{
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMNamespace wsse = omFactory.createOMNamespace(
"http://docs.oasisopen.
org/wss/2004/01/oasis200401wsswssecuritysecext1.0.
xsd",
"wsse");
OMElement securityElement = omFactory.createOMElement("Security", wsse);
OMElement tokenElement = omFactory.createOMElement("BinarySecurityToken",
wsse);
OMNamespace wsu = tokenElement.declareNamespace(
"http://docs.oasisopen.
org/wss/2004/01/oasis200401wsswssecurityutility1.0.
xsd",
"wsu");
tokenElement.addAttribute("QualificationValueType",
"http://schemas.emc.com/documentum#ResourceAccessToken", wsse);
tokenElement.addAttribute("Id", "RAD", wsu);
tokenElement.setText(token);
securityElement.addChild(tokenElement);
return securityElement;
}
Example 64.
Creating the security header in JAXWS
public Element addTokenToHeader(String token){
Element wsseSecurity = null;
Element wsseToken = null;
try
{
Document document =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
wsseSecurity = document.createElementNS(WSSE_NAMESPACE, "wsse:Security");
wsseToken = (Element) wsseSecurity.appendChild(
document.createElementNS(
WSSE_NAMESPACE, "wsse:BinarySecurityToken"));
wsseToken.setAttribute("QualificationValueType", EMC_RAD);
wsseToken.setAttributeNS(WSU_NAMESPACE, "wsu:Id", "RAD");
wsseToken.setTextContent(token);
}
catch (ParserConfigurationException e)
{
e.printStackTrace();
}
EMC Documentum Foundation Services Version 6.5 Development Guide 71
Consuming DFS without the DFS Productivity Layer
return wsseSecurity;
}
The following snippet of XML is what the security header should look like. The value for the
BinarySecurityToken element is the token that was returned by the Context Registry Service.
<wsse:Security xmlns:wsse=
"http://docs.oasisopen.
org/wss/2004/01/oasis200401wsswssecuritysecext1.0.
xsd">
<wsse:BinarySecurityToken
QualificationValueType="http://schemas.emc.com/documentum#ResourceAccessToken"
xmlns:wsu=
"http://docs.oasisopen.
org/wss/2004/01/oasis200401wsswssecurityutility1.0.
xsd"
wsu:Id="RAD">
hostname/123.4.56.789123456789123456789012345678901
</wsse:BinarySecurityToken>
</wsse:Security>

· hibernate3学习笔记(十八)|关系映射(09-03)
· 扩展DataView实现(MultiSelect)多行(09-02)
· java取系统时间(09-02)
· Ext实现页面表单Enter全键盘导航(09-02)
· ajax和dwr入门学习(09-02)
· 用java写的程序:1-100随机数相加(09-02)
· Struts 2视频开发教程--第二讲,第一(09-02)
· 不同版本MyEclipse生成的HibernateSes(09-02)
· 关于Http和Hibernatet里面Session的区(09-02)
· 从http协议看无法获取网页charset的原(09-02)
·Tomcat安装配置 (01-20)
·Windows下JAVA和ANT的环境变量设置 (01-07)
复制地址发给您的好友: [推荐文章] [返回顶部] [关闭窗口]
版权所有 Java大本营 1999-2007 转载请注明出处