【发布时间】:2010-09-14 05:22:25
【问题描述】:
我在<soap:Header> 元素中添加了一个自定义soap 标头<MyApp:FOO> 元素,并且要求我必须签署这个元素,如何做到这一点?
<MyApp:FOO> 包含许多可以识别更高级别用户的内容(用户名、首选项等)。
我已经成功地使用了一个策略文件,现在是一个带有 CertificateAssertions 和 SoapFilters 的 policyClass 来签署 wsu:Timestamp、wsu:action、wsu:MessageId 等。但是现在<MyApp:FOO> 元素也需要签名。
到目前为止我所理解的是,需要签名的元素必须使用 wsu:Id 属性进行标识,然后使用 xml-exc-c14n 进行转换。
那么,如何指定soap 标头也应签名? 这是我用于签署消息的当前类。
internal class FOOClientOutFilter: SendSecurityFilter
{
X509SecurityToken clientToken;
public FOOClientOutFilter(SSEKCertificateAssertion parentAssertion)
: base(parentAssertion.ServiceActor, true)
{
// Get the client security token.
clientToken = X509TokenProvider.CreateToken(StoreLocation.CurrentUser, StoreName.My, "CN=TestClientCert");
// Get the server security token.
serverToken = X509TokenProvider.CreateToken(StoreLocation.LocalMachine, StoreName.My, "CN=TestServerCert");
}
public override void SecureMessage(SoapEnvelope envelope, Security security)
{
// Sign the SOAP message with the client's security token.
security.Tokens.Add(clientToken);
security.Elements.Add(new MessageSignature(clientToken));
}
}
【问题讨论】:
标签: c# web-services wse3.0 x509securitytokenmanager