ヘッダーをスキップ
Oracle® Fusion Middleware Oracle Web Services Manager相互運用性ソリューション・ガイド
12c (12.1.3)
E59426-02
  ドキュメント・ライブラリへ移動
ライブラリ
製品リストへ移動
製品
目次へ移動
目次

前
 
次
 

6 Microsoft WCF/.NET 4.5のセキュリティ環境との相互運用性

この章では、Microsoft WCF/.NET 4.5のセキュリティ環境とOracle Web Services Manager (OWSM)の相互運用性について説明します。

この章の内容は次のとおりです。

6.1 Microsoft WCF/.NET 4.5のセキュリティ環境との相互運用性の概要

オラクル社は、OWSM 12cを使用して作成されたWebサービス・セキュリティ・ポリシーと、Microsoft Windows Communication Foundation (WCF)/.NET 4.5 Frameworkを使用して構成されたWebサービス・ポリシーとの相互運用を可能にするための相互運用性テストを実施しました。

Microsoft .NET 4.5 (以前) Frameworkの詳細は、http://msdn.microsoft.com/en-us/library/ff361664%28v=vs.110%29.aspxの「.NET Development」を参照してください。

詳細は、次を参照してください。

  • OWSM事前定義済ポリシーについては、『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』の事前定義済ポリシーに関する説明を参照してください。

  • OWSM 12cポリシーの構成およびアタッチについては、『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のWebサービスの保護に関する説明およびポリシーのアタッチに関する説明を参照してください。


注意:

ほとんどの場合、アプリケーションのデプロイ前にソース・コード内のOWSMポリシーをアタッチするすることも、WLSTまたはFusion Middleware Controlを使用してデプロイメント後にポリシーをアタッチするすることもできます。この章の手順を簡略化するには、デプロイメント後にポリシーをアタッチしていることが前提です。デプロイ前にポリシーをアタッチすることが必要な状況の場合、その方法がこの手順で説明されています。


注意:

この章で説明する手順の一部では、Microsoft ServiceModelメタデータ・ユーティリティ・ツール(SvcUtil.exe)を使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成するよう指示します。ただし、SvcUtil.exeは、OWSMで使用される特定のセキュリティ・ポリシー・アサーションでは動作しません。回避策として、OWSMポリシーによって保護されているWebサービスのWCFプロキシを作成する際に、次のことを行います。
  • ポリシーをデタッチします。

  • SvcUtil.exeを使用してプロキシを作成します。

  • ポリシーを再アタッチします。

SvcUtil.exeの詳細は、http://msdn.microsoft.com/en-us/library/aa347733%28v=vs.110%29.aspxを参照してください。


表6-1および表6-2は、セキュリティ要件(認証、メッセージ保護およびトランスポート)に基づいたMicrosoft .NET 4.5の最も一般的な相互運用性シナリオをまとめたものです。


注意:

以降のシナリオでは、v3証明書付きのキーストアを使用していることを確認してください。JDK 1.5キーツールでは、デフォルトでv1証明書付きのキーストアが生成されます。

また、キーが適切な拡張(DigitalSignature、Non_repudiation、Key_EnciphermentおよびData_Enciphermentなど)を使用していることも確認してください。


表6-1 OWSM 12cサービス・ポリシーとMicrosoft WCF/.NET 4.5クライアント・ポリシーの相互運用性

アイデンティティ・トークン WS-Securityバージョン メッセージ保護 トランスポート・セキュリティ サービス・ポリシー クライアント・ポリシー

MTOM

該当なし

該当なし

該当なし

oracle/wsmtom_policy

表6-4「Microsoft WCF/.NET 4.5クライアントの構成」を参照してください。

ユーザー名またはSAML

1.1

はい

いいえ

oracle/wss11_username_token_with_message_protection_service_policy

または

oracle/wss11_saml_or_username_token_with_message_protection_service_policy

表6-8「Microsoft WCF/.NET 4.5クライアントの構成」表6-12「Microsoft WCF/.NET 4.5クライアントの構成」、および第6.10.6項「ステップ6: ADFS 2.0を使用するWCF/.NET 4.5クライアントの保護」を参照してください。

ユーザー名

1.0および1.1

いいえ

はい

oracle/wss_saml_or_username_token_over_ssl_service_policy

または

oracle/wss_username_token_over_ssl_service_policy

表6-12「Microsoft WCF/.NET 4.5クライアントの構成」を参照してください。

相互認証

1.1

はい

いいえ

oracle/wss11_x509_token_with_message_protection_service_policy

表6-17「Microsoft WCF/.NET 4.5クライアントの構成」を参照してください。

Kerberos

1.1

はい

いいえ

oracle/wss11_kerberos_token_with_message_protection_service_policy

表6-22「Microsoft WCF/.NET 4.5クライアントの構成」を参照してください。

SAMLベアラー

1.0

いいえ

はい

oracle/wss_sts_issued_saml_bearer_token_over_ssl_service_policy

または

oracle/wss_saml_token_bearer_over_ssl_service_policy

第6.10.6項「ステップ6: ADFS 2.0を使用するWCF/.NET 4.5クライアントの保護」を参照してください。


表6-2 Microsoft WCF/.NET 4.5サービス・ポリシーとOWSM 12cクライアント・ポリシーの相互運用性

アイデンティティ・トークン WS-Securityバージョン メッセージ保護 トランスポート・セキュリティ サービス・ポリシー クライアント・ポリシー

MTOM

該当なし

該当なし

該当なし

表6-5「Microsoft WCF/.NET 4.5 Webサービスの構成」を参照してください。

oracle/wsmtom_policy

ユーザー名

1.1

はい

いいえ

表6-9「Microsoft WCF/.NET 4.5 Webサービスの構成」を参照してください。

oracle/wss11_username_token_with_message_protection_client_policy

SSL経由のユーザー名トークン

1.0

いいえ

はい

表6-13「Microsoft WCF/.NET 4.5 Webサービスの構成」を参照してください。

oracle/wss_username_token_over_ssl_client_policy

相互認証

1.1

はい

いいえ

表6-18「Microsoft WCF/.NET 4.5 Webサービスの構成」を参照してください。

oracle/wss11_x509_token_with_message_protection_client_policy


6.2 メッセージ送信最適化メカニズム(MTOM)

この項では、次の相互運用性シナリオにおいてMTOMを実装する方法について説明します。

6.2.1 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、メッセージ送信最適化メカニズム(MTOM)を実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-3 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

Webサービス・アプリケーションを作成してデプロイします。

Webサービスの管理のWebサービス・アプリケーションのデプロイに関する項

2

oracle/wsmtom_policyポリシーをWebサービスにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ


表6-4 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

Microsoft SvcUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成します。例6-1「MTOM相互運用性のためのapp.configファイル」を参照してください。

http://msdn.microsoft.com/en-us/library/aa347733%28v=vs.110%29.aspxの「ServiceModel Metadata Utility Tool (Svcutil.exe)」

2

クライアント・プログラムを実行します。

--


例6-1 MTOM相互運用性のためのapp.configファイル

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>    
        <bindings>
            <customBinding>
                <binding name="CustomBinding_IMTOMService">                
                    <mtomMessageEncoding maxReadPoolSize="64"
                     maxWritePoolSize="16"
                        messageVersion="Soap12" maxBufferSize="65536"
                        writeEncoding="utf-8">
                        <readerQuotas maxDepth="32" maxStringContentLength=
                         "8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    </mtomMessageEncoding>
                    <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                        maxReceivedMessageSize="65536" allowCookies="false"
                           authenticationScheme="Anonymous"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        keepAliveEnabled="true" maxBufferSize="65536"
                           proxyAuthenticationScheme="Anonymous"
                        realm="" transferMode="Buffered" 
                           unsafeConnectionNtlmAuthentication="false"
                        useDefaultWebProxy="true" />
                </binding>
            </customBinding>
        </bindings>
        <client>
          <endpoint address="<endpoint_url>"
              binding="customBinding" bindingConfiguration="CustomBinding_IMTOMService"
              contract="IMTOMService" name="CustomBinding_IMTOMService" >
          </endpoint>         
        </client>          
    </system.serviceModel>
</configuration>

6.2.2 Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントの構成

次の手順では、メッセージ送信最適化メカニズム(MTOM)を実装するために、Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントを構成する方法を示します。

表6-5 Microsoft WCF/.NET 4.5 Webサービスの構成

タスク 説明 参照先

1

.NET Webサービスを作成します。

例については、例6-2「MTOM相互運用性のための.NET Webサービス」を参照してください。

http://msdn.microsoft.com/en-us/library/ms731835.aspxの「How to: Define a Windows Communication Foundation Service Contract」

2

アプリケーションをデプロイします。

--


例6-2 MTOM相互運用性のための.NET Webサービス

static void Main(string[] args)
{
    string uri = "http://host:port/TEST/MTOMService/SOA/MTOMService";
    // Step 1 of the address configuration procedure: Create a URI to serve as the base address.
    Uri baseAddress = new Uri(uri);

    // Step 2 of the hosting procedure: Create ServiceHost
    ServiceHost selfHost = new ServiceHost(typeof(MTOMService), baseAddress);
 
    try {
        HttpTransportBindingElement hb = new HttpTransportBindingElement();
        hb.ManualAddressing = false;
        hb.MaxBufferPoolSize = 2147483647;               
        hb.MaxReceivedMessageSize = 2147483647;
        hb.AllowCookies = false;
        hb.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
        hb.KeepAliveEnabled = true;
        hb.MaxBufferSize = 2147483647;
        hb.ProxyAuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
        hb.Realm = "";
        hb.TransferMode = System.ServiceModel.TransferMode.Buffered;
        hb.UnsafeConnectionNtlmAuthentication = false;
        hb.UseDefaultWebProxy = true;
        MtomMessageEncodingBindingElement me = new MtomMessageEncodingBindingElement();
        me.MaxReadPoolSize=64;
        me.MaxWritePoolSize=16;
        me.MessageVersion=System.ServiceModel.Channels.MessageVersion.Soap12;
        me.WriteEncoding = System.Text.Encoding.UTF8;
        me.MaxWritePoolSize = 2147483647;
        me.MaxBufferSize = 2147483647;
        me.ReaderQuotas.MaxArrayLength = 2147483647;
        CustomBinding binding1 = new CustomBinding();
        binding1.Elements.Add(me);
        binding1.Elements.Add(hb);
        ServiceEndpoint ep = selfHost.AddServiceEndpoint(typeof(IMTOMService), binding1, 
               "MTOMService");
        EndpointAddress myEndpointAdd = new EndpointAddress(new Uri(uri),
        EndpointIdentity.CreateDnsIdentity("WSMCert3"));               
        ep.Address = myEndpointAdd;

        // Step 4 of the hosting procedure: Enable metadata exchange.
        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
        smb.HttpGetEnabled = true;
        selfHost.Description.Behaviors.Add(smb);
        using (ServiceHost host = new ServiceHost(typeof(MTOMService)))
        {
            System.ServiceModel.Description.ServiceDescription svcDesc = 
                 selfHost.Description;
            ServiceDebugBehavior svcDebug = 
                  svcDesc.Behaviors.Find<ServiceDebugBehavior>();
            svcDebug.IncludeExceptionDetailInFaults = true;
        }
 
        // Step 5 of the hosting procedure: Start (and then stop) the service.
        selfHost.Open();
        Console.WriteLine("The service " + uri + " is ready.");
        Console.WriteLine("Press <ENTER> to terminate service.");
        Console.WriteLine();
        Console.ReadLine();
        // Close the ServiceHostBase to shutdown the service.
        selfHost.Close();
    }
    catch (CommunicationException ce)
    {
        Console.WriteLine("An exception occurred: {0}", ce.Message);
        selfHost.Abort();
    }
}

表6-6 OWSM 12cクライアントの構成

タスク 説明 参照先

1

JDeveloperを使用して、.NET Webサービスを使用するSOAコンポジットを作成します。

『Oracle Fusion Middleware Oracle SOA Suite開発者ガイド』

2

oracle/wsmtom_policyポリシーをWebサービス・クライアントにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ


6.3 メッセージ保護付きユーザー名トークン(WS-Security 1.1)

この項では、次の相互運用性シナリオにおいて、セキュアな通信を有効化する場合またはしない場合の、WS-Security 1.1標準に準拠するメッセージ保護付きユーザー名トークンを実装する方法について説明します。

6.3.1 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、セキュアな通信を有効化する場合およびしない場合に、WS-Security 1.1標準に準拠するメッセージ保護付きユーザー名トークンを実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-7 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

SOAP 1.2準拠のWebサービス・アプリケーションを作成します。

--

2

セキュアな通信を有効化するかどうかに基づいて、使用するポリシーを選択します。

セキュアな通信を有効化しない場合、次のいずれかのポリシーのクローンを作成します。

oracle/wss11_username_token_with_message_protection_service_policy

oracle/wss11_saml_or_username_token_with_message_protection_service_policy

セキュアな通信を有効化しない場合、表6-8「Microsoft WCF/.NET 4.5クライアントの構成」の説明に従って、クライアントのestablishSecurityContextプロパティをfalseに設定する必要があります。

セキュアな通信を有効化するには、次のポリシーのクローンを作成します。

oracle/wss11_username_token_with_message_protection_wssc_service_policy

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のWebサービス・ポリシーのクローン作成に関する項

3

前述のステップ2でクローン作成されたポリシーのポリシー構成設定を、次のように編集します。

  1. X509トークン導出キー構成設定を有効化します。

  2. 「署名の暗号化」構成設定を有効化します。

  3. 「署名の確認」構成設定を無効化します。

  4. それ以外の構成設定はすべてデフォルトの構成設定のままにしておきます。

ポリシーをWebサービスにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

4

次のポリシーもアタッチします。

oracle/wsaddr_policy

--

5

次のコマンドを使用して、サービス側のキーストアからX.509証明書ファイルを.cerファイル(alice.cerなど)にエクスポートします。

keytool -export -alias alice -file C:\alice.cer -keystore default-keystore.jks

http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.htmlのkeytool - 鍵および証明書管理ツールに関するトピック


表6-8 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

次のようにして、Microsoft Management Console (mmc)を使用して、(前にエクスポートした)証明書ファイルをクライアント・サーバー上のキーストアにインポートします。

  1. コマンド・プロンプトを開きます。

  2. mmcと入力して[Enter]を押します。

  3. 「File」→「Add/Remove snap-in」を選択します。

  4. 「Add and Choose Certificates」を選択します。

    注意: ローカル・マシン・ストア内の証明書を表示するためには、管理者ロールを持っている必要があります。

  5. 「Add」を選択します。

  6. 「My user account」→「finish」を選択します。

  7. 「OK」をクリックします。

  8. 「Console Root」→「Certificates -Current user」→「Personal」→「Certificates」の順に開きます。

  9. 「Certificates」を右クリックし、「All tasks」→「Import」を選択してCertificate importウィザードを起動します。

  10. 「Next」をクリックし、「Browse」を選択して、前にエクスポートした.cerファイルに移動します。

  11. 「Next」をクリックし、デフォルトを受け入れてウィザードを終了します。

http://msdn.microsoft.com/en-us/library/ms788967.aspxの「How to: View Certificates with the MMC Snap-in」

2

WebサービスのWSDLを使用して、.NETクライアントを生成します。

注意: 『Oracle WebLogic Server JAX-WS Webサービスの開発』のWS-Addressingアクション・プロパティの暗黙的な関連付けに関する項の説明に従って、クライアントが暗黙的なwsa:Actionヘッダーを送信しないように、WS-Addressingアクション・ヘッダーを設定する必要がある場合があります。

http://msdn.microsoft.com/en-us/library/ms733133(v=vs.110).aspxの「How to: Create a Windows Communication Foundation Client」

3

例6-3に示すように、.NETプロジェクトのapp.configファイルを編集して、証明書ファイルを更新し、リプレイを無効化します。(変更部分は太字で示されています。)

デフォルトのキー設定に従う場合は、<certificate_cn>aliceに設定する必要があります。

--

4

セキュアな通信を有効化しているかどうかに従って、app.configファイルのestablishSecurityContextプロパティを設定する必要があります。

デフォルトでは、establishSecurityContexttrue (セキュアな通信を有効化している)に設定されます。セキュアな通信を有効化していない場合、establishSecurityContextfalseに設定します。

例については、例6-3 (太字斜体の行)を参照してください。


5

プロジェクトをコンパイルします。

--

6

コマンド・プロンプトを開いて、プロジェクトのDebugフォルダに移動します。

--

7

<client_project_name>.exeと入力して[Enter]を押します。

--


例6-3 メッセージ保護付きユーザー名トークン(WS-Security 1.1)を実装するためのapp.configファイル

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
         <behavior name="secureBehaviour">
           <clientCredentials>
             <serviceCertificate>
               <defaultCertificate findValue="<certificate_cn>" 
                storeLocation="CurrentUser" storeName="My" 
                x509FindType="FindBySubjectName"/>
             </serviceCertificate>
           </clientCredentials>
         </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <ws2007HttpBinding>
        <binding name="Wss11UsernameTokenWithMessageProtectionWSSCServicePortBinding" >
          <security mode="Message">
            <message clientCredentialType="UserName"
                negotiateServiceCredential="false" 
                algorithmSuite="Basic128"
                establishSecurityContext="true" />
                <!-- extablishSecurityContext is true by default and therefore does not 
                have to be specified to enable secure conversation.
                Set establishSecurityContext to false if secure conversation is not enabled -->
          </security>
        </binding>
      </ws2007HttpBinding>
    </bindings>
  <client>
    <endpoint address="http://10.244.167.70:7003/OWSMTestApp-Project1-context-root/ws11_username_token_with_message_protection_wsscPort?wsdl" 
        behaviorConfiguration="PMCert"
        binding="ws2007HttpBinding" 
        bindingConfiguration="Wss11UsernameTokenWithMessageProtectionWSSCServicePortBinding"   
        contract="ServiceReference1.ws11_username_token_with_message_protection_wssc" 
        name="ws11_username_token_with_message_protection_wsscPort">
      <identity>
        <dns value="orakey" />
      </identity>
    </endpoint>
  </client>
  </system.serviceModel>
</configuration>

6.3.2 Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントの構成

次の手順では、WS-Security 1.1標準に準拠するメッセージ保護付きユーザー名トークンを実装するために、Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントを構成する方法を示します。

表6-9 Microsoft WCF/.NET 4.5 Webサービスの構成

タスク 説明 参照先

1

.NET Webサービスを作成します。

例6-4に示すように、SymmetricSecurityBindingElementを使用して、Webサービスのカスタム・バインディングを作成します。この例は、セキュアな通信を有効化していない場合のWebサービスを示しています。

セキュアな通信を有効化するには、この例のコードに次の調整を行います。

作成されたSymmetricSecurityBindingElement要素(sm)に基づいて、この要素をもう1つ作成します。たとえば次のようになります。

SymmetricSecurityBindingElement scsm = SymmetricSecurityBindingElement.createSecureConversationBindingELement(sm, false)

その後、新しいカスタム・バインディングを作成します。

CustomBinding binding1 = new CustomBinding(scsm);

http://msdn.microsoft.com/en-us/library/ms731835.aspxの「How to: Define a Windows Communication Foundation Service Contract」

2

証明書ファイルを作成して、Webサービス・サーバー上のキーストアにインポートします。

Microsoft Visual Studioを使用する場合、コマンドは次のようになります。

makecert -r -pe -n "CN=wsmcert3" -sky exchange -ss my C:\wsmcert3.cer

このコマンドにより、証明書が作成されてmmcにインポートされます。

コマンドの結果が期待どおりにならない場合は、次のコマンド・シーケンスを試行してください。http://www.microsoft.com/whdc/devtools/WDK/default.mspxのWindows Developer Kit (WDK)をダウンロードする必要があります。

makecert -r -pe -n "CN=wsmcert3" -sky exchange -ss my -sv wscert3.pvk C:\wsmcert3.cer
pvk2pfx.exe -pvk wscert3.pvk -spc wsmcert3.cer -pfx PRF_WSMCert3.pfx -pi welcome1

次に、PRF_WSMCert3.pfxをmmcにインポートします。

--

3

keytoolコマンドを使用して、Webサービス・サーバー上に作成された証明書をクライアント・サーバーにインポートします。次に例を示します。

keytool -import -alias wsmcert3 -file C:\wsmcert3.cer -keystore <owsm_client_keystore>

http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.htmlのkeytool - 鍵および証明書管理ツールに関するトピック

4

Solutions Explorerで「Web service Solution」プロジェクトを右クリックし、「Open Folder In Windows Explorer」をクリックします。

--

5

bin/Debugフォルダに移動します。

--

6

<project>.exeファイルをダブルクリックします。このコマンドにより、指定したURLでWebサービスが実行されます。

--


例6-4 .NET Webサービスの例

static void Main(string[] args)
{
    // Step 1 of the address configuration procedure: Create a URI to serve as the 
    // base address.        
    // Step 2 of the hosting procedure: Create ServiceHost
    string uri = "http://host:port/TEST/NetService";
    Uri baseAddress = new Uri(uri);
 
    ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
 
    try
    {
        SymmetricSecurityBindingElement sm = 
            SymmetricSecurityBindingElement.CreateUserNameForCertificateBindingElement();
        sm.DefaultAlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Basic128;
        sm.SetKeyDerivation(false);
        sm.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
        sm.IncludeTimestamp = true;
        sm.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
        sm.MessageSecurityVersion = 
        MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005
        WSSecurityPolicy11BasicSecurityProfile10;
        sm.LocalClientSettings.CacheCookies = true;
        sm.LocalClientSettings.DetectReplays = true;
        sm.LocalClientSettings.ReplayCacheSize = 900000;
        sm.LocalClientSettings.MaxClockSkew = new TimeSpan(00, 05, 00);
        sm.LocalClientSettings.MaxCookieCachingTime = TimeSpan.MaxValue;
        sm.LocalClientSettings.ReplayWindow = new TimeSpan(00, 05, 00); ;
        sm.LocalClientSettings.SessionKeyRenewalInterval = new TimeSpan(10, 00, 00);
        sm.LocalClientSettings.SessionKeyRolloverInterval = new TimeSpan(00, 05, 00); ;
        sm.LocalClientSettings.ReconnectTransportOnFailure = true;
        sm.LocalClientSettings.TimestampValidityDuration = new TimeSpan(00, 05, 00); ;
        sm.LocalClientSettings.CookieRenewalThresholdPercentage = 60;
        sm.LocalServiceSettings.DetectReplays = false;
        sm.LocalServiceSettings.IssuedCookieLifetime = new TimeSpan(10, 00, 00);
        sm.LocalServiceSettings.MaxStatefulNegotiations = 128;
        sm.LocalServiceSettings.ReplayCacheSize = 900000;
        sm.LocalServiceSettings.MaxClockSkew = new TimeSpan(00, 05, 00);
        sm.LocalServiceSettings.NegotiationTimeout = new TimeSpan(00, 01, 00);
        sm.LocalServiceSettings.ReplayWindow = new TimeSpan(00, 05, 00);
        sm.LocalServiceSettings.InactivityTimeout = new TimeSpan(00, 02, 00);
        sm.LocalServiceSettings.SessionKeyRenewalInterval = new TimeSpan(15, 00, 00);
        sm.LocalServiceSettings.SessionKeyRolloverInterval = new TimeSpan(00, 05, 00);
        sm.LocalServiceSettings.ReconnectTransportOnFailure = true;
        sm.LocalServiceSettings.MaxPendingSessions = 128;
        sm.LocalServiceSettings.MaxCachedCookies = 1000;
        sm.LocalServiceSettings.TimestampValidityDuration = new TimeSpan(15, 00, 00);
        HttpTransportBindingElement hb = new HttpTransportBindingElement();
        hb.ManualAddressing = false;
        hb.MaxBufferPoolSize = 524288;
        hb.MaxReceivedMessageSize = 65536;
        hb.AllowCookies = false;
        hb.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
        hb.KeepAliveEnabled = true;
        hb.MaxBufferSize = 65536;
        hb.ProxyAuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
        hb.Realm = "";
        hb.TransferMode = System.ServiceModel.TransferMode.Buffered;
        hb.UnsafeConnectionNtlmAuthentication = false;
        hb.UseDefaultWebProxy = true;
        TextMessageEncodingBindingElement tb1 = new TextMessageEncodingBindingElement();
        tb1.MaxReadPoolSize = 64;
        tb1.MaxWritePoolSize = 16;
        tb1.MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12;
        tb1.WriteEncoding = System.Text.Encoding.UTF8;
        CustomBinding binding1 = new CustomBinding(sm);
        binding1.Elements.Add(tb1);
        binding1.Elements.Add(hb);
        ServiceEndpoint ep = selfHost.AddServiceEndpoint(typeof(ICalculator), binding1,
          "CalculatorService");
 
        EndpointAddress myEndpointAdd = new EndpointAddress(                    
        new Uri(uri),
        EndpointIdentity.CreateDnsIdentity("WSMCert3"));
        ep.Address = myEndpointAdd;
 
        // Step 4 of the hosting procedure: Enable metadata exchange.
        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
        smb.HttpGetEnabled = true;
        selfHost.Description.Behaviors.Add(smb);
        selfHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, 
           StoreName.My,
        X509FindType.FindBySubjectName, "WSMCert3");
        selfHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode =
            X509CertificateValidationMode.PeerOrChainTrust;
        selfHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode =
            UserNamePasswordValidationMode.Custom;
        CustomUserNameValidator cu = new CustomUserNameValidator();
        selfHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = cu;
        using (ServiceHost host = new ServiceHost(typeof(CalculatorService)))
        {
            System.ServiceModel.Description.ServiceDescription svcDesc = selfHost.Description;
            ServiceDebugBehavior svcDebug = svcDesc.Behaviors.Find<ServiceDebugBehavior>();
            svcDebug.IncludeExceptionDetailInFaults = true;
        }
 
        // Step 5 of the hosting procedure: Start (and then stop) the service.
        selfHost.Open();
        Console.WriteLine("The Calculator service is ready.");
        Console.WriteLine("Press <ENTER> to terminate service.");
        Console.WriteLine();
        Console.ReadLine();
        selfHost.Close();
    }
    catch (CommunicationException ce)
    {
         Console.WriteLine("An exception occurred: {0}", ce.Message);
         selfHost.Abort();
     }
}

表6-10 OWSM 12cクライアントの構成

タスク 説明 参照先

1

JDeveloperを使用して、.NET Webサービスを使用するSOAコンポジットを作成します。

『Oracle Fusion Middleware Oracle SOA Suite開発者ガイド』

2

JDeveloperで、.NETサービスのWSDLを使用してパートナ・リンクを作成します。

--

3

oracle/wss11_username_token_with_message_protection_client_policyポリシーをWebサービス・クライアントにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

4

csf-keyおよびkeystore.recipient.aliasの構成を指定します。

この情報を指定するには、ポリシーをアタッチするときにポリシー構成をオーバーライドします。詳細は、次を参照してください。

必ず、ステップ1でインポートした証明書(wsmcert3)の別名としてkeystore.recipient.aliasを構成してください。次に例を示します。

<wsp:PolicyReference 
      URI="oracle/wss11_username_token_with_message_protection_client_policy"
      orawsp:category="security" 
      orawsp:status="enabled"/>
   <property 
      name="csf-key" 
      type="xs:string" 
      many="false">
      basic.credentials
   </property>
   <property 
      name="keystore.recipient.alias" 
      type="xs:string" 
      many="false">
      wsmcert3
   </property>

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシー構成プロパティのオーバーライド


6.4 SSL経由のユーザー名トークン

この項では、次の相互運用性シナリオにおいてSSL経由のユーザー名トークンを実装する方法について説明します。

6.4.1 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、セキュアな通信を有効化する場合およびしない場合に、SSL経由のユーザー名トークンを実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-11 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

サーバーをSSL用に構成します。

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のトランスポート・レベルのセキュリティ(SSL)の構成に関する項

2

OWSM Webサービスを作成します。

--

3

セキュアな通信を有効化するかどうかに基づいて、使用するポリシーを選択します。

セキュアな通信を有効化しない場合、次のいずれかのポリシーをアタッチします。

oracle/wss_username_token_over_ssl_service_policy

oracle/wss_saml_or_username_token_over_ssl_service_policy

oracle/wss11_saml_or_username_token_with_message_protection_service_policy

セキュアな通信を有効化しない場合、表6-8「Microsoft WCF/.NET 4.5クライアントの構成」の説明に従って、クライアントのestablishSecurityContextプロパティをfalseに設定する必要があります。

セキュアな通信を有効化するには、次のポリシーをアタッチします。

oracle/wss_username_token_over_ssl_wssc_service_policy

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理の事前定義済のポリシー

4

次のようにして、アドレッシングが使用されることを指定します。

Oracle Infrastructure Webサービスの場合:

次のポリシーをアタッチします。

oracle/wssaddr_policy

Java EE Webサービスの場合:

Java EE Webサービスおよびクライアントでは、OWSMセキュリティ・ポリシーのサブセットのみがサポートされるため、oracle/wssaddr_policyをJava EE Webサービスにアタッチできません。そうではなく、例6-5に示すように、サービスのソース・コードで@Addressing注釈を使用して、アドレッシング情報を追加する必要があります。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のJava EE WebサービスおよびクライアントでサポートされているOWSMポリシーに関する項

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』の設計時のJava EE Webサービスおよびクライアントへのポリシーのアタッチに関する項


例6-5 アドレッシングを使用したJava EE Webサービス

package oracle.wsm.qa.wls.service.soap12;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.SOAPBinding;
import weblogic.wsee.jws.jaxws.owsm.SecurityPolicy;
@WebService
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
@Addressing(enabled=true)
public class wss_username_token_over_ssl {
  public wss_username_token_over_ssl() {
    super();
  }
  @WebMethod
  public String sayHello(@WebParam(name = "arg0") String name){
    return "hello "+ name;
  }
}

表6-12 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

WebサービスのWSDLを使用して、.NETクライアントを生成します。

http://msdn.microsoft.com/en-us/library/ms733133(v=vs.110).aspxの「How to: Create a Windows Communication Foundation Client」

2

セキュアな通信を有効化しているかどうかに従って、app.configファイルのestablishSecurityContextプロパティを設定する必要があります。

デフォルトでは、establishSecurityContexttrue (セキュアな通信を有効化している)に設定されます。セキュアな通信を有効化していない場合、establishSecurityContextfalseに設定します。

例については、例6-6 (太字斜体の行)を参照してください。


3

プロジェクトをコンパイルします。

--

4

コマンド・プロンプトを開いて、プロジェクトのDebugフォルダに移動します。

--

5

<client_project_name>.exeと入力して[Enter]を押します。

--


例6-6 app.configファイル

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings> 
      <ws2007HttpBinding> 
        <binding name="wss_username_over_ssl_client"> 
          <security mode="TransportWithMessageCredential"> 
            <transport clientCredentialType="None" /> 
            <message clientCredentialType="UserName" 
                negotiateServiceCredential="false" 
                establishSecurityContext="true" />
                <!-- extablishSecurityContext is true by default and therefore does not 
                have to be specified to enable secure conversation.
                Set establishSecurityContext to false if secure conversation is not enabled -->
          </security> 
        </binding> 
      </ws2007HttpBinding> 
    </bindings> 
    <client> 
      <endpoint address="https://10.244.167.70:7004/OWSMTestApp-Project1-context-root/wss_username_token_over_sslPort" 
          binding="ws2007HttpBinding" 
          bindingConfiguration="wss_username_over_ssl_client" 
          contract="ServiceReference1.wss_username_token_over_ssl" 
          name="wss_username_token_over_sslPort" /> 
    </client>
  </system.serviceModel>
</configuration>

6.4.2 Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントの構成

次の手順では、SSL経由のユーザー名トークンを実装するために、Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントを構成する方法を示します。

表6-13 Microsoft WCF/.NET 4.5 Webサービスの構成

タスク 説明 参照先

1

サーバーをSSL用に構成します。

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のトランスポート・レベルのセキュリティ(SSL)の構成に関する項

1

.NET Webサービスを作成します。

例6-7に示すように、SecurityBindingElementを使用して、Webサービスのカスタム・バインディングを作成します。この例は、セキュアな通信を有効化していない場合のWebサービスを示しています。

セキュアな通信を有効化するには、この例のコードに次の調整を行います。

作成されたSecurityBindingElement要素(sm)に基づいて、この要素をもう1つ作成します。たとえば次のようになります。

SecurityBindingElement scsm = SecurityBindingElement.createSecureConversationBindingElement(sm)

その後、scsmを使用したカスタム・バインディングを作成します。

CustomBinding binding1 = new CustomBinding(scsm);

http://msdn.microsoft.com/en-us/library/ms731835.aspxの「How to: Define a Windows Communication Foundation Service Contract」


例6-7 .NET Webサービスの例

static void Main(string[] args)
{
    // Step 1 of the address configuration procedure: Create a URI to serve as the 
    // base address.        
    // Step 2 of the hosting procedure: Create ServiceHost
    string uri = "http://host:port/TEST/NetService";
    Uri baseAddress = new Uri(uri);
 
    ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
 
    try
    {
        SecurityBindingElement sm =
            SecurityBindingElement.CreateUserNameOverTransportBindingElement();
        sm.DefaultAlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Basic128;
        sm.SetKeyDerivation(false);
        sm.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
        sm.IncludeTimestamp = true;
        sm.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
        sm.MessageSecurityVersion = 
        MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005
        WSSecurityPolicy11BasicSecurityProfile10;
        sm.LocalClientSettings.CacheCookies = true;
        sm.LocalClientSettings.DetectReplays = true;
        sm.LocalClientSettings.ReplayCacheSize = 900000;
        sm.LocalClientSettings.MaxClockSkew = new TimeSpan(00, 05, 00);
        sm.LocalClientSettings.MaxCookieCachingTime = TimeSpan.MaxValue;
        sm.LocalClientSettings.ReplayWindow = new TimeSpan(00, 05, 00); ;
        sm.LocalClientSettings.SessionKeyRenewalInterval = new TimeSpan(10, 00, 00);
        sm.LocalClientSettings.SessionKeyRolloverInterval = new TimeSpan(00, 05, 00); ;
        sm.LocalClientSettings.ReconnectTransportOnFailure = true;
        sm.LocalClientSettings.TimestampValidityDuration = new TimeSpan(00, 05, 00); ;
        sm.LocalClientSettings.CookieRenewalThresholdPercentage = 60;
        sm.LocalServiceSettings.DetectReplays = false;
        sm.LocalServiceSettings.IssuedCookieLifetime = new TimeSpan(10, 00, 00);
        sm.LocalServiceSettings.MaxStatefulNegotiations = 128;
        sm.LocalServiceSettings.ReplayCacheSize = 900000;
        sm.LocalServiceSettings.MaxClockSkew = new TimeSpan(00, 05, 00);
        sm.LocalServiceSettings.NegotiationTimeout = new TimeSpan(00, 01, 00);
        sm.LocalServiceSettings.ReplayWindow = new TimeSpan(00, 05, 00);
        sm.LocalServiceSettings.InactivityTimeout = new TimeSpan(00, 02, 00);
        sm.LocalServiceSettings.SessionKeyRenewalInterval = new TimeSpan(15, 00, 00);
        sm.LocalServiceSettings.SessionKeyRolloverInterval = new TimeSpan(00, 05, 00);
        sm.LocalServiceSettings.ReconnectTransportOnFailure = true;
        sm.LocalServiceSettings.MaxPendingSessions = 128;
        sm.LocalServiceSettings.MaxCachedCookies = 1000;
        sm.LocalServiceSettings.TimestampValidityDuration = new TimeSpan(15, 00, 00);
        HttpTransportBindingElement hb = new HttpTransportBindingElement();
        hb.ManualAddressing = false;
        hb.MaxBufferPoolSize = 524288;
        hb.MaxReceivedMessageSize = 65536;
        hb.AllowCookies = false;
        hb.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
        hb.KeepAliveEnabled = true;
        hb.MaxBufferSize = 65536;
        hb.ProxyAuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
        hb.Realm = "";
        hb.TransferMode = System.ServiceModel.TransferMode.Buffered;
        hb.UnsafeConnectionNtlmAuthentication = false;
        hb.UseDefaultWebProxy = true;
        TextMessageEncodingBindingElement tb1 = new TextMessageEncodingBindingElement();
        tb1.MaxReadPoolSize = 64;
        tb1.MaxWritePoolSize = 16;
        tb1.MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12;
        tb1.WriteEncoding = System.Text.Encoding.UTF8;
        CustomBinding binding1 = new CustomBinding(sm);
        binding1.Elements.Add(tb1);
        binding1.Elements.Add(hb);
        ServiceEndpoint ep = selfHost.AddServiceEndpoint(typeof(ICalculator), binding1,
          "CalculatorService");
 
        EndpointAddress myEndpointAdd = new EndpointAddress(                    
        new Uri(uri),
        EndpointIdentity.CreateDnsIdentity("WSMCert3"));
        ep.Address = myEndpointAdd;
 
        // Step 4 of the hosting procedure: Enable metadata exchange.
        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
        smb.HttpGetEnabled = true;
        selfHost.Description.Behaviors.Add(smb);
        selfHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, 
           StoreName.My,
        X509FindType.FindBySubjectName, "WSMCert3");
        selfHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode =
            X509CertificateValidationMode.PeerOrChainTrust;
        selfHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode =
            UserNamePasswordValidationMode.Custom;
        CustomUserNameValidator cu = new CustomUserNameValidator();
        selfHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = cu;
        using (ServiceHost host = new ServiceHost(typeof(CalculatorService)))
        {
            System.ServiceModel.Description.ServiceDescription svcDesc = selfHost.Description;
            ServiceDebugBehavior svcDebug = svcDesc.Behaviors.Find<ServiceDebugBehavior>();
            svcDebug.IncludeExceptionDetailInFaults = true;
        }
 
        // Step 5 of the hosting procedure: Start (and then stop) the service.
        selfHost.Open();
        Console.WriteLine("The Calculator service is ready.");
        Console.WriteLine("Press <ENTER> to terminate service.");
        Console.WriteLine();
        Console.ReadLine();
        selfHost.Close();
    }
    catch (CommunicationException ce)
    {
         Console.WriteLine("An exception occurred: {0}", ce.Message);
         selfHost.Abort();
     }
}

表6-14 OWSM 12cクライアントの構成

タスク 説明 参照先

1

WebサービスのWSDLを使用して、OWSMクライアントを生成します。

『Oracle Fusion Middleware Oracle SOA Suite開発者ガイド』

2

次のポリシーをクライアントにアタッチします。

oracle/wss_username_token_over_ssl_client_policy

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ


6.5 メッセージ保護付き相互認証(WS-Security 1.1)

この項では、次の相互運用性シナリオにおいて、WS-Security 1.1標準に準拠するメッセージ保護付き相互認証を実装する方法について説明します。

前述のいずれかのシナリオにおいてWebサービスおよびクライアントを構成する前に、「構成の前提条件」の手順に従います。

6.5.1 構成の前提条件

表6-15では、WS-Security 1.1標準に準拠するメッセージ保護付き相互認証を実装するための前提条件の構成タスクを実行する方法について説明します。

表6-15 相互運用性のための構成の前提条件

タスク 説明 参照先

1

次のコマンドを使用して、サービス側のキーストアからX.509証明書ファイルを.cerファイル(alice.cerなど)にエクスポートします。

keytool -export -alias alice -file C:\alice.cer -keystore default-keystore.jks

http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.htmlのkeytool - 鍵および証明書管理ツールに関するトピック

2

Microsoft Management Console (mmc)を使用して、(前にエクスポートした)証明書ファイルをクライアント・サーバー上のキーストアにインポートします。固有の手順については、表6-8「Microsoft WCF/.NET 4.5クライアントの構成」のステップ1を参照してください。

http://msdn.microsoft.com/en-us/library/ms788967.aspxの「How to: View Certificates with the MMC Snap-in」


6.5.2 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、WS-Security 1.1標準に準拠するメッセージ保護付き相互認証を実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-16 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

SOAP 1.2準拠のSOAコンポジットを作成してデプロイします。

--

2

Fusion Middleware Controlを使用して、次のポリシーをWebサービスにアタッチします。

oracle/wss11_x509_token_with_message_protection_service_policy

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

3

wss11_x509_token_with_message_protection_service_policy_netをエクスポートします。encrypted="true""false"に変更し、再びインポートします。

<orasp:x509-token 
   orasp:enc-key-ref-mech="thumbprint" 
   orasp:is-encrypted="false" 
   orasp:is-signed="false" 
   orasp:sign-key-ref-mech="direct"/>
  • 『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のWebサービス・ポリシーのエクスポートに関する項

  • 『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のWebサービス・ポリシーのインポートに関する項

4

ポリシーをWebサービスにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

5

次のポリシーもアタッチします。

oracle/wsaddr_policy

--


表6-17 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

Microsoft SvcUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシ(例6-9「クライアント・プログラム」を参照)および構成ファイルを作成します。

http://msdn.microsoft.com/en-us/library/aa347733%28v=vs.110%29.aspx

2

例6-8「app.configファイル」に示すように、app.config構成ファイルを作成します。

--

3

プロジェクトをコンパイルします。

--

4

コマンド・プロンプトを開いて、プロジェクトのDebugフォルダに移動します。

--

5

<client_project_name>.exeと入力して[Enter]を押します。

--


例6-8 app.configファイル

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="secureBehaviour">
          <clientCredentials>
            <serviceCertificate>
              <defaultCertificate findValue="<certificate_cn>"
                                  storeLocation="CurrentUser"
                                  storeName="My"
                                  x509FindType="FindBySubjectName"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
      <bindings> 
        <ws2007HttpBinding> 
          <binding name="wss_username_over_ssl_client"> 
            <security mode="TransportWithMessageCredential"> 
            <transport clientCredentialType="None" /> 
            <message clientCredentialType="UserName" 
                negotiateServiceCredential="false" 
                establishSecurityContext="false" /> 
            </security> 
          </binding> 
        </ws2007HttpBinding> 
     </bindings> 
        <client>
          <endpoint address="http://<server>:<port>//MyWebService1SoapHttpPort"
                binding="ws2007HttpBinding"
                contract="MyWebService1" 
                name="MyWebService1SoapHttpPort"
                behaviorConfiguration="secureBehaviour" >
            <identity>
              <dns value="<certificate_cn>"/>
            </identity>
          </endpoint>
        </client>
    </system.serviceModel>
</configuration>

例6-9 クライアント・プログラム

 namespace IO_NET10_client
{
    class Program
    {
        static void Main(string[] args)
        {
           
            BPELProcess1Client client = new BPELProcess1Client();
         
            client.ClientCredentials.ClientCertificate.SetCertificate(
                    StoreLocation.CurrentUser,
                    StoreName.My,
                    X509FindType.FindBySubjectName, "WSMCert3");
                     
             client.ClientCredentials.ServiceCertificate.SetDefaultCertificate(
                       StoreLocation.CurrentUser,
                       StoreName.My,
                    X509FindType.FindBySubjectName, "Alice");
 
            process proc = new process();
            proc.input = "Test wss11_x509_token_with_message_protection_policy - ";
            Console.WriteLine(proc.input);
            processResponse response = client.process(proc);
           
            Console.WriteLine(response.result.ToString());
            Console.WriteLine("Press <ENTER> to terminate Client.");
            Console.ReadLine();
          }
    }
}

6.5.3 Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントの構成

次の手順では、WS-Security 1.1標準に準拠するメッセージ保護付き相互認証を実装するために、Microsoft WCF/.NET 4.5 WebサービスおよびOWSM 12cクライアントを構成する方法を示します。

表6-18 Microsoft WCF/.NET 4.5 Webサービスの構成

タスク 説明 参照先

1

.NET Webサービスを作成します。

例については、例6-4「.NET Webサービスの例」を参照してください。

http://msdn.microsoft.com/en-us/library/ms731835%28v=vs.90%29.aspxの「How to: Define a Windows Communication Foundation Service Contract」

2

SymmetricSecurityBindingElementを使用して、Webサービスのカスタム・バインディングを作成します。

SymmetricSecurityBindingElementオブジェクトのサンプルを次に示します。

SymmetricSecurityBindingElement sm =
(SymmetricSecurityBindingElement)SecurityBindingElement.CreateMutualCertificate
BindingElement(); 
 
sm.DefaultAlgorithmSuite =
System.ServiceModel.Security.SecurityAlgorithmSuite.Basic128;sm.SetKeyDerivati
on(false);
sm.SecurityHeaderLayout = SecurityHeaderLayout.Lax;sm.IncludeTimestamp =
true;
sm.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy; 
sm.MessageProtectionOrder =
MessageProtectionOrder.SignBeforeEncrypt;sm.MessageSecurityVersion =
MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversation
February2005WSSecurityPolicy11BasicSecurityProfile10;
sm.RequireSignatureConfirmation =
true;

http://msdn.microsoft.com/en-us/library/ms730305%28v=vs.90%29.aspxの「How to: Create a Custom Binding Using the SecurityBindingElement」

4

アプリケーションをデプロイします。

--


表6-19 OWSM 12cクライアントの構成

タスク 説明 参照先

1

JDeveloperを使用して、.NET Webサービスを使用するSOAコンポジットを作成します。

『Oracle Fusion Middleware Oracle SOA Suite開発者ガイド』

2

JDeveloperで、.NETサービスのWSDLを使用してパートナ・リンクを作成し、次のようにインポートを追加します。

<wsdl:import namespace="<namespace>" location="<WSDL location>"/> 

--

3

Fusion Middleware Controlで、次のポリシーをWebサービス・クライアントにアタッチします。

oracle/wss11_x509_token_with_message_protection_client_policy

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

6

keystore.recipient.aliasの構成を指定します。

この情報を指定するには、ポリシーをアタッチするときにポリシー構成をオーバーライドします。

必ず、ステップ4でインポートした証明書(wsmcert3)の別名としてkeystore.recipient.aliasを構成してください。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシー構成プロパティのオーバーライド

7

クライアントからWebサービス・メソッドを起動します。

--


6.6 メッセージ保護付きKerberos

この項では、次の相互運用性シナリオにおいて、メッセージ保護付きKerberosを実装する方法について説明します。

6.6.1 相互運用性のための前提条件となるタスクの実行

表6-20 相互運用性のための構成の前提条件

タスク 説明 参照先

1

鍵配布センター(KDC)およびアクティブ・ディレクトリ(AD)を構成します。

http://download.oracle.com/docs/cd/E19316-01/820-3746/gisdn/index.htmlのWindowsのアクティブ・ディレクトリおよびドメイン・コントローラの構成方法(ドメイン・コントローラがKDCの役割を果します)に関する項

2

例6-10「Kerberos構成ファイル」に示すように、c:\winntにあるKerberos構成ファイルkrb5.confを設定します。

--


例6-10 Kerberos構成ファイル

[logging]
default = c:\log\krb5libs.log
kdc = c:\log\krb5kdc.log
admin_server = c:\log\kadmind.log
[libdefaults]
default_realm = MYCOMPANY.LOCAL
dns_lookup_realm = false
dns_lookup_kdc = false
default_tkt_enctypes = rc4-hmac
default_tgs_enctypes = rc4-hmac
permitted_enctypes = rc4-hmac
kdc = hostname
[realms]
MYCOMPANY.LOCAL =
{ kdc = host:port  admin_server = host:port
  default_domain = <domainname>
}
 [domain_realm]
.<domainname> = MYCOMPANY.LOCAL
 <domainname> = MYCOMPANY.LOCAL
[appdefaults]
pam =
{   debug = false  ticket_lifetime = 36000  renew_lifetime = 36000  forwardable =
 true  krb4_convert = false }

6.6.2 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、メッセージ保護付きKerberosを実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-21 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

Webサービス・アプリケーションを作成してデプロイします。

Webサービスの管理のWebサービス・アプリケーションのデプロイに関する項

2

oracle/wss11_kerberos_token_with_message_protection_service_policyポリシーのクローンを作成します。

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のWebサービス・ポリシーのクローン作成に関する項

3

ポリシー設定を編集して、アルゴリズム・スイートをBasic128Rsa15に設定します。

--

4

ポリシーをWebサービスにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ


表6-22 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

ADにユーザーを作成して、Webサービスがホストされるホストを指定します。デフォルトでは、ユーザー・アカウントはRC4-HMAC暗号を使用して作成されます。たとえば、ユーザー名付きのfoobarは、HTTP/foobarとなります。

--

2

次のようにktpassコマンドを使用して、KDCが実行されているWindowsのADマシンにkeytabファイルを作成します。

ktpass -princ HTTP/foobar@MYCOMPANY.LOCAL -pass Oracle123 -mapuser foobar -out foobar.keytab -ptype KRB5_NT_PRINCIPAL -kvno 4

HTTP/foobarは、ユーザー「foobar」にマッピングされるSPNです。「/desonly」を指定したり、「/cyrpto」に「des-cbc-crc」は指定しないでください。MYCOMPANY.LOCALはKDCのデフォルトのレルムで、krb5.iniファイルで使用可能です。passに指定するパスワードは、ユーザーの作成時のパスワードと一致している必要があります。

FTPのバイナリ・モードを使用して、生成したキータブ・ファイルをSOAコンポジットWebサービスがホストされているマシンに移動します。

--

3

次のようにsetSpnコマンドを使用して、サービス・プリンシパルをユーザーにマッピングします。

setSpn -A HTTP/foobar@MYCOMPANY.LOCAL foobar

setSpn -L foobar

ユーザーにマッピングするSPNは1つにしてください。複数のSPNがユーザーにマッピングされている場合は、setSpn -D <spname> <username>コマンドを使用して削除します。

--

4

Microsoft SvcUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成します。

Windowsのエクスプローラでアプリケーションを右クリックして、generatedProxy.csファイルおよびapp.configファイルを追加し、既存の項目を追加を選択します。

app.configのendpoint要素に、「HTTP/foobar@MYCOMPANY.LOCAL」というサービス・プリンシパル名(keytabの作成で使用したものと同じ値)の「identity」要素を追加します。

<client>
        <endpoint address="http://host:port/HelloServicePort"
            binding="customBinding" bindingConfiguration="NewHelloSoap12HttpPortBinding"
            contract="NewHello" name="HelloServicePort">
        <identity>
          <servicePrincipalName value ="HTTP/foobar@MYCOMPANY.LOCAL"/>
        </identity>
        </endpoint>
       
      </client>

例6-11「カスタム・バインディング」に、バインディングのサンプルを示します。

http://msdn.microsoft.com/en-us/library/aa347733%28v=vs.110%29.aspx

5

クライアント・プログラムを実行します。

-


例6-11 カスタム・バインディング

<customBinding>
  <binding name="NewHelloSoap12HttpPortBinding">
      <!--Added by User: Begin-->
      <security defaultAlgorithmSuite="Basic128"
        authenticationMode="Kerberos"
        requireDerivedKeys="false" securityHeaderLayout="Lax"
        includeTimestamp="true"
        keyEntropyMode="CombinedEntropy"
        messageProtectionOrder="SignBeforeEncrypt"
        messageSecurityVersion="WSSecurity11WSTrustFebruary2005
        WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurity
          Profile10" 
        requireSignatureConfirmation="true">
      <localClientSettings cacheCookies="true" detectReplays="true"
          replayCacheSize="900000" maxClockSkew="00:05:00"
          maxCookieCachingTime="Infinite"
          replayWindow="00:05:00"
          sessionKeyRenewalInterval="10:00:00"
          sessionKeyRolloverInterval="00:05:00"
          reconnectTransportOnFailure="true"
          timestampValidityDuration="00:05:00"
          cookieRenewalThresholdPercentage="60" />
                <localServiceSettings detectReplays="true"
          issuedCookieLifetime="10:00:00"
          maxStatefulNegotiations="128" replayCacheSize="900000"
          maxClockSkew="00:05:00"
          negotiationTimeout="00:01:00" replayWindow="00:05:00"
          inactivityTimeout="00:02:00"
          sessionKeyRenewalInterval="15:00:00"
          sessionKeyRolloverInterval="00:05:00"
          reconnectTransportOnFailure="true"
          maxPendingSessions="128"
          maxCachedCookies="1000"
          timestampValidityDuration="00:05:00" />
                  <secureConversationBootstrap />
                </security>
              <!--Added by User: End-->
                <textMessageEncoding maxReadPoolSize="64"
                   maxWritePoolSize="16"
                   messageVersion="Soap12" writeEncoding="utf-8">
                <readerQuotas maxDepth="32" maxStringContentLength="8192"
                   maxArrayLength="16384"
                   maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </textMessageEncoding>
              <!--Added by User: Begin-->
              <httpTransport manualAddressing="false"
                   maxBufferPoolSize="524288"
                   maxReceivedMessageSize="65536" allowCookies="false"
                   authenticationScheme="Anonymous"
                   bypassProxyOnLocal="false"
                   hostNameComparisonMode="StrongWildcard"
                   keepAliveEnabled="true" maxBufferSize="65536"
                   proxyAuthenticationScheme="Anonymous"
                   realm="" transferMode="Buffered"
                   unsafeConnectionNtlmAuthentication="false"
                   useDefaultWebProxy="true" />
                <!--Added by User: End-->
           </binding>
</customBinding>

6.7 導出キーを使用したメッセージ保護付きKerberos

この項では、次の相互運用性シナリオにおいて、導出キーを使用したメッセージ保護付きKerberosを実装する方法について説明します。

前述のシナリオにおいてWebサービスおよびクライアントを構成する前に、第6.7.1項「構成の前提条件」の手順に従います。

6.7.1 構成の前提条件

表6-23では、導出キーを使用したメッセージ保護付きKerberosを実装するための前提条件の構成タスクを実行する方法について説明します。

表6-23 相互運用性のための構成の前提条件

タスク 説明 参照先

1

鍵配布センター(KDC)およびアクティブ・ディレクトリ(AD)を構成します。

  • http://download.oracle.com/docs/cd/E19316-01/820-3746/gisdn/index.htmlのWindowsのアクティブ・ディレクトリおよびドメイン・コントローラの構成方法(ドメイン・コントローラがKDCの役割を果します)に関する項

  • 『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のKerberosトークンの構成に関する項

2

例6-12「Kerberos構成ファイル」に示すように、c:\winntにあるKerberos構成ファイルkrb5.confを設定します。

--


例6-12 Kerberos構成ファイル

[logging]
default = c:\log\krb5libs.log
kdc = c:\log\krb5kdc.log
admin_server = c:\log\kadmind.log
[libdefaults]
default_realm = MYCOMPANY.LOCAL
dns_lookup_realm = false
dns_lookup_kdc = false
default_tkt_enctypes = rc4-hmac
default_tgs_enctypes = rc4-hmac
permitted_enctypes = rc4-hmac
kdc = hostname
[realms]
MYCOMPANY.LOCAL =
{ kdc = host:port  admin_server = host:port
  default_domain = <domainname>
}
 [domain_realm]
.<domainname> = MYCOMPANY.LOCAL
 <domainname> = MYCOMPANY.LOCAL
[appdefaults]
pam =
{   debug = false  ticket_lifetime = 36000  renew_lifetime = 36000  forwardable =
 true  krb4_convert = false }

6.7.2 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、メッセージ保護付きKerberosを実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-24 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

Webサービス・アプリケーションを作成してデプロイします。

Webサービスの管理のWebサービス・アプリケーションのデプロイに関する項

2

wss11_kerberos_token_with_message_protection_basic128_service_policyポリシーのクローンを作成します。

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のWebサービス・ポリシーのクローン作成に関する項

3

ポリシー設定を編集して、「Derived Keys」オプションを有効にします。

--

4

ポリシーをWebサービスにアタッチします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ


表6-25 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明

1

ADにユーザーを作成して、Webサービスがホストされるホストを指定します。デフォルトでは、ユーザー・アカウントはRC4-HMAC暗号を使用して作成されます。たとえば、ユーザー名をfoobarとすると、HTTP/foobarとなります。

2

次のようにktpassコマンドを使用して、KDCが実行されているWindowsのADマシンにkeytabファイルを作成します。

ktpass -princ HTTP/foobar@MYCOMPANY.LOCAL -pass Oracle123 -mapuser foobar -out foobar.keytab -ptype KRB5_NT_PRINCIPAL -kvno 4

HTTP/foobarがユーザー「foobar」にマッピングされるSPNです。「/desonly」を指定したり、「/cyrpto」に「des-cbc-crc」は指定しないでください。MYCOMPANY.LOCALはKDCのデフォルトのレルムで、krb5.iniファイルで使用可能です。passに指定するパスワードは、ユーザーの作成時のパスワードと一致している必要があります。

FTPのバイナリ・モードを使用して、生成したキータブ・ファイルをSOAコンポジットWebサービスがホストされているマシンに移動します。

3

次のようにsetSpnコマンドを使用して、サービス・プリンシパルをユーザーにマッピングします。

setSpn -A HTTP/foobar@MYCOMPANY.LOCAL foobar

setSpn -L foobar

ユーザーにマッピングするSPNは1つにしてください。複数のSPNがユーザーにマッピングされている場合は、setSpn -D <spname> <username>コマンドを使用して削除します。

4

Microsoft SvcUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成します。

Windowsのエクスプローラでアプリケーションを右クリックして、generatedProxy.csファイルおよびapp.configファイルを追加し、既存の項目を追加を選択します。

app.configのendpoint要素に、「HTTP/foobar@MYCOMPANY.LOCAL」というサービス・プリンシパル名(keytabの作成で使用したものと同じ値)の「identity」要素を追加します。

<client>
        <endpoint address="http://host:port/HelloServicePort"
            binding="customBinding" bindingConfiguration="NewHelloSoap12HttpPortBinding"
            contract="NewHello" name="HelloServicePort">
        <identity>
          <servicePrincipalName value ="HTTP/foobar@MYCOMPANY.LOCAL"/>
        </identity>
        </endpoint>
       
      </client>

例6-13「カスタム・バインディング」に、バインディングのサンプルを示します。

5

クライアント・プログラムを実行します。


例6-13 カスタム・バインディング

<customBinding>
  <binding name="NewHelloSoap12HttpPortBinding">
    <!--Added by User: Begin-->
    <security defaultAlgorithmSuite="Basic128"
      authenticationMode="Kerberos"
      requireDerivedKeys="true" securityHeaderLayout="Lax"
      includeTimestamp="true"
      keyEntropyMode="CombinedEntropy"
      messageProtectionOrder="SignBeforeEncrypt"
      messageSecurityVersion="WSSecurity11WSTrustFebruary2005
      WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurity
      Profile10" 
      requireSignatureConfirmation="true">
    <localClientSettings cacheCookies="true" detectReplays="true"
        replayCacheSize="900000" maxClockSkew="00:05:00"
        maxCookieCachingTime="Infinite"
        replayWindow="00:05:00"
        sessionKeyRenewalInterval="10:00:00"
        sessionKeyRolloverInterval="00:05:00"
        reconnectTransportOnFailure="true"
        timestampValidityDuration="00:05:00"
        cookieRenewalThresholdPercentage="60" />
      <localServiceSettings detectReplays="true"
        issuedCookieLifetime="10:00:00"
        maxStatefulNegotiations="128" replayCacheSize="900000"
        maxClockSkew="00:05:00"
        negotiationTimeout="00:01:00" replayWindow="00:05:00"
        inactivityTimeout="00:02:00"
        sessionKeyRenewalInterval="15:00:00"
        sessionKeyRolloverInterval="00:05:00"
        reconnectTransportOnFailure="true"
        maxPendingSessions="128"
        maxCachedCookies="1000"
        timestampValidityDuration="00:05:00" />
      <secureConversationBootstrap />
    </security>
  <!--Added by User: End-->
      <textMessageEncoding maxReadPoolSize="64"
        maxWritePoolSize="16"
        messageVersion="Soap12" writeEncoding="utf-8">
          <readerQuotas maxDepth="32" maxStringContentLength="8192"
            maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      </textMessageEncoding>
          <!--Added by User: Begin-->
      <httpTransport manualAddressing="false"
        maxBufferPoolSize="524288"
        maxReceivedMessageSize="65536" allowCookies="false"
        authenticationScheme="Anonymous"
        bypassProxyOnLocal="false"
        hostNameComparisonMode="StrongWildcard"
        keepAliveEnabled="true" maxBufferSize="65536"
        proxyAuthenticationScheme="Anonymous"
        realm="" transferMode="Buffered"
        unsafeConnectionNtlmAuthentication="false"
        useDefaultWebProxy="true" />
      <!--Added by User: End-->
  </binding>
</customBinding>

6.8 SPNEGOネゴシエーションによるKerberos

この項では、次の相互運用性シナリオにおいてSPNEGOネゴシエーションによりKerberosを実装する方法について説明します。

6.8.1 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、SPNEGOネゴシエーションによるKerberosを実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-26 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

Webサービス・アプリケーションを作成してデプロイします。

Webサービスの管理のWebサービス・アプリケーションのデプロイに関する項

2

http_spnego_token_service_templateアサーション・テンプレートを使用するポリシーを作成します。

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のSPNEGOネゴシエーションによるKerberosの構成に関する項

3

ポリシーをWebサービスにアタッチします。

--


表6-27 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

Microsoft SvcUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成します。

http://msdn.microsoft.com/en-us/library/aa347733%28v=vs.110%29.aspx

2

Windowsのエクスプローラでアプリケーションを右クリックして、generatedProxy.csファイルおよびapp.configファイルを追加し、既存の項目を追加を選択します。

--

3

例6-14「app.configファイル」に示すように、app.configファイルを編集します。

このリストでは、エンドポイント要素のcontractおよびname属性の値は、generatedProxy.csファイルから取得されます。

--

4

クライアントをコンパイルします。

--

5

デプロイしたWebサービスにOWSMポリシーをアタッチした後、クライアントを実行します。

--


例6-14 app.configファイル

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BPELProcessBinding">
          <security mode= "TransportCredentialOnly">
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint 
          address="http://host:port/soa-infra/services/default/SOAProxy/bpelpro
cess_client_ep"
          binding="basicHttpBinding" 
          bindingConfiguration="BPELProcessBinding"
          contract="BPELProcess" name="BPELProcess_pt" 
        <identity>
          <servicePrincipalName value ="HTTP/host:port@MYCOMPANY.LOCAL" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

6.9 SPNEGOネゴシエーションおよび資格証明の委任によるKerberos

この項では、次の相互運用性シナリオにおいてSPNEGOネゴシエーションおよび資格証明の委任によりKerberosを実装する方法について説明します。

6.9.1 OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントの構成

次の手順では、SPNEGOネゴシエーションおよび資格証明の委任によるKerberosを実装するために、OWSM 12c WebサービスおよびMicrosoft WCF/.NET 4.5クライアントを構成する方法を示します。

表6-28 OWSM 12c Webサービスの構成

タスク 説明 参照先

1

Webサービス・アプリケーションを作成してデプロイします。

Webサービスの管理のWebサービス・アプリケーションのデプロイに関する項

2

http_spnego_token_service_templateアサーション・テンプレートを使用するポリシーを作成します。

--

3

ポリシーをWebサービスにアタッチします。

--

4

credential.delegation構成設定の値をtrueに設定します。

この情報を指定するには、ポリシーをアタッチするときにポリシー構成をオーバーライドします。

Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシー構成プロパティのオーバーライド


表6-29 Microsoft WCF/.NET 4.5クライアントの構成

タスク 説明 参照先

1

Microsoft SvcUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成します。

http://msdn.microsoft.com/en-us/library/aa347733%28v=vs.110%29.aspx

2

Windowsのエクスプローラでアプリケーションを右クリックして、generatedProxy.csファイルおよびapp.configファイルを追加し、既存の項目を追加を選択します。

--

3

例6-15「app.configファイル」に示すように、app.configファイルを編集します。

例では、エンドポイント要素のcontractおよびname属性の値は、generatedProxy.csファイルから取得されます。

--

4

クライアントをコンパイルします。

--

5

デプロイしたWebサービスにOWSMポリシーをアタッチした後、クライアントを実行します。

--


例6-15 app.configファイル

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BPELProcess1Binding">
          <security mode= "TransportCredentialOnly">
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint 
          address="http://host:port/soa-infra/services/default/SOAProxy/bpelpro
cess1_client_ep"
          binding="basicHttpBinding" 
          bindingConfiguration="BPELProcess1Binding"
          contract="BPELProcess1" name="BPELProcess1_pt" 
          behaviorConfiguration="CredentialDelegation">
        <identity>
          <servicePrincipalName value ="HTTP/host:port@MYCOMPANY.LOCAL" />
        </identity>
      </endpoint>
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="CredentialDelegation">
          <clientCredentials>
            <windows allowedImpersonationLevel="Delegation"
              allowNtlm="false"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

6.10 Microsoft Active Directory Federation Services 2.0 (ADFS 2.0) STSを使用するWCF/.NET 4.5クライアント

この項では、次のポリシーを使用して、Microsoft Active Directory Federation Services 2.0 (ADFS 2.0)セキュア・トークン・サービス(STS)を使用するWCF/.NET 4.5クライアントを保護する方法を示します。

  • oracle/wss_sts_issued_saml_bearer_token_over_ssl_service_policy

  • oracle/wss_saml_token_bearer_over_ssl_service_policy

  • oracle/wss11_saml_or_username_token_with_message_protection_service_policy


注意:

SAML送信者保証トークンは、この使用例ではサポートされません。

この項で説明する手順は、Windows Server 2008またはWindows Server 2008 R2へのADFS 2.0のインストールに基づいています。

この項の内容は、次のとおりです。

6.10.1 ステップ1: Active Directory Federation Services (ADFS) 2.0のインストールおよび構成

ADFS 2.0をWindows Server 2008またはWindows Server 2008 R2システムにインストールして構成します。

表6-30に示すように、Active DirectoryおよびADFSを構成します。

表6-30 Active Directory Federation Services (ADFS) 2.0のインストールおよび構成

タスク 説明 参照先

1

  1. STSロールでシステムを設定します。

http://technet.microsoft.com/en-us/library/dd349801%28v=ws.10%29.aspxの「Windows Server 2008 R2 and Windows Server 2008」

http://technet.microsoft.com/en-us/library/dd578336%28v=ws.10%29.aspxの「Active Directory Services」

http://technet.microsoft.com/library/cc772128%28WS.10%29.aspxの「Active Directory フェデレーション サービス」

http://technet.microsoft.com/en-us/library/cc731443%28v=ws.10%29.aspxの「AD FS Step-by-Step Guide」

http://technet.microsoft.com/en-us/library/dd807092%28v=ws.10%29.aspxの「AD FS 2.0 Deployment Guide」

2

インターネット インフォメーション サービス (IIS) マネージャ・コンソールを使用して、IISで自己署名入りサーバー認証証明書を作成して構成し、デフォルトのWebサイトにバインドします。完了したら、SSLサーバー認証を有効にします。

注意: ADFS 2.0設定ウィザードによって、Webサーバー(IIS)サーバー・ロールがシステムに自動的にインストールされます。

前述を参照してください。

3

スタンドアロン・フェデレーション・サーバーとしてADFS 2.0を構成します。

前述を参照してください。

4

ADFS 2.0トークン署名証明書をエクスポートします。

自己署名入り証明書の場合は、「DER encoded binary X.509 (.cer)」を選択します。

署名証明書が自己署名入りでない場合は、「Cryptographic Message Syntax Standard - PKCS #7 証明書 (.P7B)」を選択し、証明のパスにある証明書をすべて含めることを指定します。

前述を参照してください。

5

ユーザーを作成し、電子メール・アドレスを含めます。後でSTSを有効にして、サービス用の送信SAMLアサーションのサブジェクト名IDとして電子メール・アドレスを送信します。

前述を参照してください。


6.10.2 ステップ2: ADFS 2.0 STSによって発行されたSAMLアサーションを信頼するためのOWSMの構成

表6-31の説明に従って、ADFS 2.0 STSによって発行されたSAMLアサーションを信頼するようにOWSMを構成します。

表6-31 ADFS 2.0 STSによって発行されたSAMLアサーションを信頼するためのOWSMの構成

タスク 説明 参照先

1

「ステップ1: Active Directory Federation Services (ADFS) 2.0のインストールおよび構成」でエクスポートしたSTS署名証明書を取得します。

証明書チェーンの.p7bファイルの場合、IEでファイルを開き、各証明書を.cerファイルのチェーンにコピーします。

--

2

keytoolを使用して証明書をデフォルトのキーストアの場所にインポートします。

keytool –importcert –file <sts-signing-certs-file> –trustcacerts –alias <alias> –keystore default-keystore.jks

http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.htmlのkeytool - 鍵および証明書管理ツールに関するトピック

3

http://domain-name/adfs/services/trustをSAMLの信頼できる発行者として追加します。

--

4

信頼できるSTSサーバー・セクションにSTS証明書のサブジェクトDN (RFC 2253で定義)を追加します。CN=abcなど、RFC 2253に準拠する文字列を使用してください。keytoolなどの任意のメカニズムを使用して、証明書を表示し、サブジェクトDNを決定できます。

『Oracle Web Services ManagerによるWebサービスの保護とポリシーの管理』のSAMLの信頼できる発行者およびDNリストの構成に関する項

http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.htmlのkeytool - 鍵および証明書管理ツールに関するトピック


6.10.3 ステップ3: Oracle Internet Directoryのユーザーの構成

各ユーザーに、ADFSに設定されるユーザー電子メール・アドレスと一致するメール属性を構成します。

Oracle Internet Directoryのユーザーの構成の詳細は、『Oracle Fusion Middleware Oracle Internet Directory管理者ガイド』のユーザー作成のためのディレクトリ・エントリの管理に関する説明を参照してください。

6.10.4 ステップ4: Webサービスへのポリシーのアタッチ

次のOWSMポリシーのいずれかをWebサービスにアタッチします。

  • oracle/wss_sts_issued_saml_bearer_token_over_ssl_service_policy

  • oracle/wss_saml_token_bearer_over_ssl_service_policy

  • oracle/wss11_saml_or_username_token_with_message_protection_service_policy

詳細は、次を参照してください:

  • Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理のポリシーのアタッチ

  • Oracle Web Services ManagerによるWebサービスの保護およびポリシーの管理の事前定義済のポリシー

6.10.5 ステップ5: ADFS 2.0のリライイング・パーティとしてのWebサービスの登録

表6-32の説明に従って、電子メール・アドレスまたは名前ID (SAM-Account-Name)をサブジェクト名IDとして使用してWebサービスにSAMLアサーションを発行するようにADFS 2.0を構成します。

表6-32 ADFS 2.0のリライイング・パーティとしてのWebサービスの登録

タスク 説明 参照先

1

Webサービスをリライイング・パーティとして追加します。

http://technet.microsoft.com/en-us/library/dd807108.aspxの「Create a Relying Party Trust Manually」

2

サービスの要求規則を構成します。

STSを有効にして、サービス用の送信SAMLアサーションのsubject name idとして電子メール・アドレスまたは名前IDを送信し、テンプレートの異なる2つの要求規則のチェーンを作成します。

STSを有効にして、サービス用の送信SAMLアサーションのsubject name idとして電子メール・アドレスまたは名前IDを送信するには、この項の手順を使用して、テンプレートの異なる2つの要求規則のチェーンを作成します。

http://technet.microsoft.com/en-us/library/ee913578%28v=ws.10%29.aspxの「Checklist: Creating Claim Rules for a Relying Party Trust」

http://technet.microsoft.com/en-us/library/dd807115%28v=ws.10%29.aspxの「Create a Rule to Send LDAP Attributes as Claims」


6.10.6 ステップ6: ADFS 2.0を使用するWCF/.NET 4.5クライアントの保護

表6-33の説明に従って、ADFS 2.0を使用するWCF/.NET 4.5クライアントを保護します。

表6-33 ADFS 2.0を使用するWCF/.NET 4.5クライアントの保護

タスク 説明 参照先

1

STSおよびサービス用のSSLサーバー証明書をWindowsにインポートします。

STSまたはサービス用のSSLサーバー証明書が、信頼できるCAから発行されていない、または自己署名入りである場合は、表6-8「Microsoft WCF/.NET 4.5クライアントの構成」のステップ1の説明に従って、MMCツールを使用してインポートする必要があります。

http://msdn.microsoft.com/en-us/library/ms788967.aspxの「How to: View Certificates with the MMC Snap-in」

2

後述のステップ3および4の説明に従って、WCF/.NETクライアントを作成および構成します。

ADFS 2.0 STSにより、トークンに対する保険としての複数のセキュリティおよび認証メカニズムがサポートされます。これらはそれぞれ個別のエンドポイントとして公開されます。ユーザー名/パスワード認証では、2つのエンドポイントが提供されます。

  • http://<adfs.domain>/adfs/services/trust/13/username - このエンドポイントはメッセージ保護付きユーザー名トークン用です。

  • https://<adfs.domain>/adfs/services/trust/13/usernamemixed - このエンドポイントはトランスポート保護(SSL)付きユーザー名トークン用です。

WCFクライアントは、SSLのユーザー名トークン用のhttps://<adfs.domain>/adfs/services/trust/13/usernamemixedエンドポイントを使用して、サービスのSAMLベアラー・トークンを取得します。

--

3

サービスWSDLを使用して、WCFクライアントを生成します。

http://msdn.microsoft.com/en-us/library/ms733133(v=vs.110).aspxの「How to: Create a Windows Communication Foundation Client」

4

次のようにして、ws2007FederationHttpBindingを使用するクライアントを構成し、app.configファイルを編集します。

例6-16に、次のポリシーを使用したWebサービスで使用するapp.configのサンプルを示します。

oracle/wss_sts_issued_saml_bearer_token_over_ssl_service_policy

oracle/wss_saml_token_bearer_over_ssl_service_policy

oracle/wss11_saml_or_username_token_with_message_protection_service_policy

http://msdn.microsoft.com/en-us/library/bb472490.aspxの「WS 2007 Federation HTTP Binding」

5

program.csファイルを編集し、サービスの呼出しを行います。

まだ存在していない場合は、プロジェクトに.csファイルを作成し、program.csという名前(または任意の名前)を付けます。例6-17のコードと一致するように編集します。

この例では、次のようになります。

joeはユーザー名、eojはパスワードであり、STSに対して認証するためにクライアントによって使用されます。

System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);は、サーバー側の自己署名入り証明書を検証するために追加されています。サーバー証明書が信頼できるCAから発行されている場合、これは不要です。テスト用に自己署名入り証明書を使用している場合、この方法を追加してクライアント側の証明書を検証します。

--


例6-16 様々なSAMLベースの認証を実装するためのapp.configファイル

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="secureBehaviour">
          <clientCredentials>
            <serviceCertificate>
              <defaultCertificate findValue="weblogic"  
                  storeLocation="LocalMachine" 
                  storeName="My" 
                  x509FindType="FindBySubjectName"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <ws2007FederationHttpBinding>
        <binding name="JaxWsWss11SamlOrUsernameOrSamlBearerOverSSLSoapHttp">
          <security mode="TransportWithMessageCredential">
            <message negotiateServiceCredential="false"
                 algorithmSuite="Basic128"
                 issuedTokenType ="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
                 issuedKeyType="BearerKey">
              <issuer address ="https://domain-name/adfs/services/trust/13/usernamemixed"
                      binding ="ws2007HttpBinding"
                                                              bindingConfiguration="ADFSUsernameMixed"/>
             </message>
          </security>
        </binding>
      </ws2007FederationHttpBinding>
      <ws2007HttpBinding>
        <binding name="ADFSUsernameMixed">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" 
                     establishSecurityContext="false" />
          </security>
        </binding>
      </ws2007HttpBinding>
    </bindings>
    <client>
      <endpoint address="https://host:8002/JaxWsWss11SamlOrUsernameOrSamlBearerOverSSL/JaxWsWss11SamlOrUsernameOrSamlBearerOverSSLService"
          binding="ws2007FederationHttpBinding" 
          bindingConfiguration="JaxWsWss11SamlOrUsernameOrSamlBearerOverSSLSoapHttp"
          contract="JaxWsWss11SamlOrUsernameOrSamlBearerOverSSL" 
          name="JaxWsWss11SamlOrUsernameOrSamlBearerOverSSLPort">
            <identity>
              <dns value="weblogic" />
            </identity>
          </endpoint>
    </client>
  </system.serviceModel>
</configuration>

例6-17 pregram.csファイル

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
 
namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            JaxWsWss11SamlOrUsernameOrSamlBearerOverSSLClient client = 
               New JaxWsWss11SamlOrUsernameOrSamlBearerOverSSLClient();
 
            client.ClientCredentials.UserName.UserName = "joe";
            client.ClientCredentials.UserName.Password = "eoj";
 
                  
 
 
System.Net.ServicePointManager.ServerCertificateValidationCallback =
               ((sender, certificate, chain, sslPolicyErrors) => true);
            
 
            Console.WriteLine(client.echo("Hello"));
            Console.Read();
        }
 
    }
}