2

私は、Geneva フレームワークを使用した独自の STS を持っています。次のように、MutualCertificateBinding を持つエンドポイントがあります。

  • AsymmetricSecurityBindingElement の使用
  • ProtectionLevel は符号です
  • https経由

参照用に以下の wsdl の一部をコピーしました

<sp:AsymmetricBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
    <wsp:Policy>
        <sp:InitiatorToken>
            <wsp:Policy>
                <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                    <wsp:Policy>
                        <sp:WssX509V3Token10/>
                    </wsp:Policy>
                </sp:X509Token>
            </wsp:Policy>
        </sp:InitiatorToken>
        <sp:RecipientToken>
            <wsp:Policy>
                <sp:X509Token sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never">
                    <wsp:Policy>
                        <sp:WssX509V3Token10/>
                    </wsp:Policy>
                </sp:X509Token>
            </wsp:Policy>
        </sp:RecipientToken>
        ...
</sp:AsymmetricBinding>

非対称キーを使用して mySTS からのセキュリティ トークンをネゴシエートする C# クライアント アプリケーションを作成しました。UseKey は X509Certificate です。それはうまく動作します。

また、トークンを発行するために mySTS に直接 Java serlet 呼び出しを行いました。PublicKey タイプを使用し、UseKey は X509 証明書として手動で RST に設定されています。次のコードスニペットでも問題なく動作します

SecurityTokenService sts = new SecurityTokenService(new URL(Constant.StsMexEndpointAddress));
IWSTrust13Sync stsService = sts.getMutualCertificateWithMessageSecurityBindingIWSTrust13Sync();
RequestSecurityTokenType rst = new RequestSecurityTokenType();
rst.getAny().add(getRequestTypeElement());
rst.getAny().add(getTokenTypeElement());
rst.getAny().add(getKeyTypeElement());
rst.getAny().add(getApplyToElement());
rst.getAny().add(getUseKeyElement());
return message;
token = stsService.trust13Issue(rst);

public static Element getUseKeyElement(){
//code to generate UseKey element manually, it is a BinarySecurityToken
}

クライアントは、mySTS によって保護された Java サービスを呼び出す別の Java サーブレットを使用します。Metro は STS 呼び出しを自動的に処理します。以下は、Java サービスの設定方法です (STS 発行の承認トークンを使用)。

  • TokenType: 2.0
  • キータイプ: 公開
  • キーサイズ:256

以下は、Java サービスを呼び出すためのコード スニペットです。

STSIssuedTokenConfiguration config = new MySTSIssuesTokenConfiguration();
STSIssuedTokenFeature feature = new STSIssuedTokenFeature(config);

//Initialize UserContext service with STS configuration above
Service_Service service = new Service_Service();
Service stub = service.getServicePort(new WebServiceFeature[]{feature});
stub.ping();

UseKey 要素を解決しようとすると、STS が例外をスローします。以下のようです

Handling an exception. Exception details: System.IdentityModel.Protocols.WSTrust.InvalidRequestException: ID3092: The specified UseKey 'SecurityKeyIdentifier
    (
    IsReadOnly = False,
    Count = 1,
    Clause[0] = RsaKeyIdentifierClause(Modulus = sH/OHZwDUBExFgbLTslliY4xH3jP63vQ1F3yKxwjcK3jfYeiM3IC6ag6RARLMdX3emhjMu2djCt+/eTB9nq2yMs51kesev23yfywjIkcpZI5c1yb3wL7I+Fh+aa+bDqo0VNjoCeHlevjTVxc82l+q5iPkTZJ7rfe+jZUfZNl+D8=, Exponent = AQAB)
    )
' cannot be resolved to a token that would prove the client's possession of the private key.
   at System.IdentityModel.Protocols.WSTrust.WSTrustSerializationHelper.ReadRSTXml(XmlReader reader, RequestSecurityToken rst, WSTrustSerializationContext context, WSTrustConstantsAdapter trustConstants)
   at System.IdentityModel.Protocols.WSTrust.WSTrust13RequestSerializer.ReadXmlElement(XmlReader reader, RequestSecurityToken rst, WSTrustSerializationContext context)
   at System....

2 つの Java サーブレットから送信された 2 つのメッセージを比較しようとしました。1 つは私のサーブレットによってプログラムによって生成され、もう 1 つはクライアントのサーブレットによって送信された Metro によって生成されます。私が見ることができる唯一の違いは、UseKey 要素についてです

<UseKey>
  <BinarySecurityToken:BinarySecurityToken
    xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:BinarySecurityToken="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:d5p1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">MIIDCTCCAfGgAw.....25C057w==
  </BinarySecurityToken:BinarySecurityToken>
</UseKey>

動作しないクライアントの 1 つ (metro フレームワークによって生成されます)

<trust:UseKey>
   <ns10:KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
       <KeyValue>
           <RSAKeyValue>
               <Modulus>sH/OHZwDUBExFgbLTsll...rfe+jZUfZNl+D8=</Modulus>
                  <Exponent>AQAB</Exponent>
            </RSAKeyValue>
        </KeyValue>
   </ns10:KeyInfo>
 </trust:UseKey>

AFAI は、STS が RSA KeyValue である UseKey 要素を解決できないため失敗したことを確認できますが、その UseKeyResolver には、リクエストの InitiatorToken によって開始された X509SecurityTokenResolver が 1 つしかありません。

だから私の質問は

  1. Javaサービスを呼び出すときにUseKeyをプログラムで設定する方法はありますか?
  2. STS に UseKey 要素を解決させる方法はありますか?
4

0 に答える 0