要素にカスタム SOAP ヘッダー<MyApp:FOO>
要素を追加しました<soap:Header>
が、要件には、この要素に署名する必要があると記載されています。
<MyApp:FOO>
より高いレベルでユーザーを識別する多くのもの (ユーザー名、設定など) が含まれています。私はポリシー ファイルを正常に使用し、wsu:Timestamp、wsu:action、wsu:MessageId などに署名するために CertificateAssertions と SoapFilters を含む policyClass を使用しました。ただし、<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));
}
}