1

状況は次のとおりです。

  1. STS からのセキュリティ トークンを a の形式でGenericXmlSecurityToken持っています (そのための SAML アサーション要素もあります)。
  2. このセキュリティ トークンを使用してサード パーティのサービスを呼び出す必要WS2007FederationHttpBindingがあります。
  3. 実際の SOAP リクエストには、SOAP セキュリティ ヘッダーの SAML アサーション要素に加えてhttp://www.w3.org/2000/09/xmldsig#、timestamp 要素に署名する署名要素 ( namespace から) と、SAML アサーションを含む body 要素も含める必要があります。
  4. WS2007FederationHttpBinding、および多くのカスタム バインディングのバリエーションでは、値の型を持つ署名にキー参照要素を含めることができませんhttp://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID(つまり、SAML アサーション)。
  5. 私が (= true を介してProtectTokens) それらから得ることができたのは、署名された SAML アサーション要素ですが、それ以上ではありません。

基本的に、リクエストで取得する必要があるのは次のとおりです。

<soapenv:Header>
  <wsse:Security>
    <saml:Assertion=""  AssertionID = "ID_56eecf2a-a143-4ec9-ab85-479d8602122f">
      ...
    </saml:Assertion>
    <WSU:Timestamp>
      ...
    </WSU:Timestamp>
    <ds:Signature>
      <ds:SignedInfo>
        <ds:CanonicalizationMethod Algorithm="xml-exc-c14n#"/>
        <ds:SignatureMethod Algorithm="#rsa-sha1"/>

        <!--Body signature-->
        <ds:Reference URI="#id">
          <ds:Transforms>
            < ds: Transform  Algorithm = "xml-exc-c14n #" />
          </ds:Transforms>
          <ds:DigestMethod Algorithm="#sha1"/>
          <ds:DigestValue >
            di3JiPJM90D3P62ChO1d4Sy12 + 4 =
          </ds:DigestValue DigestValue>
        </ds:Reference>

        <!--Timestamp element signature-->
        <ds:Reference  URI = "#Timestamp" >
          <ds:Transforms>
            <ds:Transform  Algorithm = "xml-exc-c14n #" />
          </ds:Transforms>
          <ds:DigestMethod Algorithm="#sha1"/>
          < ds:DigestValue>C+GkwwH5RuXocsD0iphwUvmQpj0=</ds:DigestValue>
        </ds:Reference>
      </ds:SignedInfo>
      <ds:SignatureValue>kq+FG6qqdx...==</ds:SignatureValue>

      <!--Key reference, pointing back to the SAML assertion element-->
      <!--This is the actual problem. Didn't manage to add this at all.-->
      <ds:KeyInfo>
        <wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0 #SAMLAssertionID">
            ID_56eecf2a-a143-4ec9-ab85-479d8602122f</wsse:KeyIdentifier>
        </wsse:SecurityTokenReference>
      </ds:KeyInfo>
    </ds:Signature>
  </wsse:Security>
</soapenv:Header>
<soapenv:Body wsu:Id="id">
  ...
</soapenv:Body>

WS2007FederationHttpBindingただし、署名を追加するために (またはカスタム バインディング) を構成する方法については途方に暮れています。

私が今取り組んでいること:

/**
 * 
 * Federation binding stuff
 * 
 */
var federationBinding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
federationBinding.Security.Message.EstablishSecurityContext = false;
federationBinding.Security.Message.IssuedKeyType = SecurityKeyType.AsymmetricKey;
federationBinding.Security.Message.NegotiateServiceCredential = false;
federationBinding.Security.Message.IssuedTokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID";
federationBinding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Basic256;

/**
 * 
 * Custom binding, the one actually used by the channel
 * 
 */
var binding = new CustomBinding(federationBinding.CreateBindingElements());
binding.Elements.Remove(binding.Elements.FirstOrDefault(i => i is TextMessageEncodingBindingElement));
var messageSecurity = (TransportSecurityBindingElement)binding.Elements.FirstOrDefault(i => i is TransportSecurityBindingElement);

//Remove it, I add another one later
binding.Elements.Remove(messageSecurity);

//Security element configuration
var secBinding = new AsymmetricSecurityBindingElement()
{
    MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10,
    ProtectTokens = true,
    SecurityHeaderLayout = SecurityHeaderLayout.Lax,
    IncludeTimestamp = true,
    EnableUnsecuredResponse = true,
    DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256
};

secBinding.InitiatorTokenParameters = new IssuedSecurityTokenParameters(
        "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
secBinding.RecipientTokenParameters = new IssuedSecurityTokenParameters(
        "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");

secBinding.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;

これに加えて、同じ結果で を使用してみTransportSecurityBindingElementました: リクエストでトークンを取得できますが、署名は取得できません。

これに関するアイデア/ヒントは大歓迎です。

4

1 に答える 1

1

価値のあるものとして、JAX-WS を使用して Java でクライアントを実装することになりました。JAX-WS API は WS-Security SOAP 要素 (wsse:Security) に適切に (場合によっては 1:1 で) マップされるため、これはスムーズに機能しました。

基本的にSOAPHandler<SOAPMessageContext>、STS を呼び出し、wsse:SecuritySAML トークンを使用して要素を構築し、送信リクエストのタイムスタンプと本文にトークンで署名するカスタムを実装しました。

実際にはそうではないので、これを答えとしてマークするつもりはありません。ただの代替案です。この質問の Tumbleweed バッジも取得しました (万歳)。

于 2014-09-17T17:51:50.233 に答える