Oracle® Fusion Middleware Oracle Web Services Manager相互運用ガイド 11g リリース1(11.1.1) B61391-02 |
|
前 |
次 |
この章の内容は次のとおりです。
オラクル社はMicrosoft社と協力して、Oracle WSM 11gを使用して作成されたWebサービス・セキュリティ・ポリシーと、Microsoft Windows Communication Foundation (WCF)/.NET 3.5 Frameworkを使用して構成されたWebサービス・セキュリティとの相互運用を可能にするための相互運用性テストを実施しました。
Microsoft WCF/.NET 3.5 Frameworkの詳細は、http://msdn.microsoft.com/en-us/netframework/aa663324.aspx
を参照してください。
事前定義済のOracle WSM 11gポリシーの詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』の次の項を参照してください。
Webサービスへのポリシーのアタッチに関する項
ポリシーの構成に関する項
事前定義済ポリシーに関する項
表5-1は、セキュリティ要件(認証、メッセージ保護およびトランスポート)に基づいたMicrosoft .NET 3.5の最も一般的な相互運用性シナリオをまとめたものです。
注意: 以降のシナリオでは、v3証明書付きのキーストアを使用していることを確認してください。JDK 1.5キーツールでは、デフォルトでv1証明書付きのキーストアが生成されます。また、キーが適切な拡張(DigitalSignature、Non_repudiation、Key_EnciphermentおよびData_Enciphermentなど)を使用していることも確認してください。 |
表5-1 Microsoft WCF/.NET 3.5のセキュリティ環境との相互運用性
相互運用性シナリオ | クライアント→Webサービス | Oracle WSM 11gのポリシー | Microsoft WCF/.NET 3.5のポリシー |
---|---|---|---|
|
Microsoft WCF/.NET 3.5→Oracle WSM 11g |
oracle/wsmtom_service_policy |
|
|
Oracle WSM 11g→Microsoft WCF/.NET 3.5 |
oracle/wsmtom_client_policy |
|
「メッセージ保護付きユーザー名トークン(WS-Security 1.1)」 |
Microsoft WCF/.NET 3.5→Oracle WSM 11g |
oracle/wss11_username_token_with_message_protection_service_policy または oracle/wss11_saml_or_username_token_with_message_protection_service_policy |
|
「メッセージ保護付きユーザー名トークン(WS-Security 1.1)」 |
Oracle WSM 11g→Microsoft WCF/.NET 3.5 |
oracle/wss11_username_token_with_message_protection_client_policy |
|
|
Microsoft WCF/.NET 3.5→Oracle WSM 11g |
oracle/wss_saml_or_username_token_over_ssl_service_policy または oracle/wss_username_token_over_ssl_service_policy |
|
「メッセージ保護付き相互認証(WS-Security 1.1)」 |
Microsoft WCF/.NET 3.5→Oracle WSM 11g |
oracle/wss11_x509_token_with_message_protection_service_policy |
|
「メッセージ保護付き相互認証(WS-Security 1.1)」 |
Oracle WSM 11g→Microsoft WCF/.NET 3.5 |
oracle/wss11_x509_token_with_message_protection_client_policy |
|
|
Microsoft WCF/.NET 3.5→Oracle WSM 11g |
oracle/wss11_kerberos_with_message_protection_service_policy |
この項では、次の相互運用性シナリオにおいてMTOMを実装する方法について説明します。
Microsoft WCF/.NET 3.5クライアントおよびOracle WSM 11g Webサービスを構成するには、次の各項で説明する手順を実行します。
Webサービス・アプリケーションを作成します。
oracle/wsmotom_service_policyポリシーをWebサービスにアタッチします。
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービスへのポリシーのアタッチに関する項を参照してください。
アプリケーションをデプロイします。
SVCUtilユーティリティを使用して、デプロイされたWebサービスからクライアント・プロキシおよび構成ファイルを作成します。「MTOM相互運用性のためのapp.configファイルの例」を参照してください。
クライアント・プログラムを実行します。
MTOM相互運用性のためのapp.configファイルの例
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>
Oracle WSM 11gクライアントおよびMicrosoft WCF/.NET 3.5 Webサービスを構成するには、次の各項で説明する手順を実行します。
.NET Webサービスを作成します。
詳細は、http://msdn.microsoft.com/en-us/library/ms731835.aspx
の『How to: Define a Windows Communication Foundation Service Contract』を参照してください。
.NET Webサービスの例については、「MTOM相互運用性のための.NET Webサービスの例」を参照してください。
アプリケーションをデプロイします。
JDeveloperを使用して、.NET Webサービスを使用するSOAコンポジットを作成します。詳細は、SOA Suiteの開発者ガイドを参照してください。
oracle/wsmtom_client_policyポリシーをWebサービス・クライアントにアタッチします。
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービス・クライアントへのポリシーのアタッチに関する項を参照してください。
MTOM相互運用性のための.NET Webサービスの例
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(); } }
この項では、次の相互運用性シナリオにおいてWS-Security 1.1に準拠するメッセージ保護付きユーザー名トークンを実装する方法について説明します。
Microsoft WCF/.NET 3.5クライアントおよびOracle WSM 11g Webサービスを構成するには、次の各項で説明する手順を実行します。
Webサービス・アプリケーションを作成します。
次のポリシーの1つをWebサービスにアタッチします。
oracle/wss11_username_token_with_message_protection_service_policy
oracle/wss11_saml_or_username_token_with_message_protection_service_policy
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービスへのポリシーのアタッチに関する項を参照してください。
次のコマンドを使用して、サービス側のキーストアからX.509証明書ファイルを.cerファイル(alice.cerなど)にエクスポートします。
keytool -export -alias alice -file C:\alice.cer -keystore default-keystore.jks
Microsoft Management Console (mmc)を使用して、(前にエクスポートした)証明書ファイルをクライアント・サーバー上のキーストアにインポートします。詳細は、http://msdn.microsoft.com/en-us/library/ms788967.aspx
の『How to: View Certificates with the MMC Snap-in』を参照してください。
コマンド・プロンプトを開きます。
mmcと入力して[Enter]を押します。
「File」→「Add/Remove snap-in」を選択します。
「Add and Choose Certificates」を選択します。
注意: ローカル・マシン・ストア内の証明書を表示するためには、管理者ロールを持っている必要があります。 |
「Add」を選択します。
「My user account」→「finish」を選択します。
「OK」をクリックします。
「Console Root」→「Certificates -Current user」→「Personal」→「Certificates」の順に開きます。
「Certificates」を右クリックし、「All tasks」→「Import」を選択してCertificate importウィザードを起動します。
「Next」をクリックし、「Browse」を選択して、前にエクスポートした.cerファイルに移動します。
「Next」をクリックし、デフォルトを受け入れてウィザードを終了します。
WebサービスのWSDLを使用して、.NETクライアントを生成します。
詳細は、http://msdn.microsoft.com/en-us/library/ms733133.aspx
の『How to: Create a Windows Communication Foundation Client』を参照してください。
注意: SVCUtilは、<sp:SignedParts>のようなセキュリティ・ポリシー・アサーションをサポートしていません。回避策として、次のようにします。
|
クライアント・プロジェクトのSolution Explorerで、「references」を右クリックして「Add reference」を選択し、C:\Windows\Microsoft .NET framework\v3.0\Windows Communication Framework\System.Runtime.Serialization.dllを参照することにより、参照を追加します。
「app.configファイルの編集」の説明に従って、.NETプロジェクト内のapp.configを編集して証明書ファイルを更新し、リプレイを無効化します。
プロジェクトをコンパイルします。
コマンド・プロンプトを開いて、プロジェクトのDebugフォルダに移動します。
<client_project_name>.exeと入力して[Enter]を押します。
app.configファイルの編集
次の例に示すようにapp.configファイルを編集して、証明書ファイルを更新し、リプレイを無効化します(変更部分は太字で示されています)。デフォルトのキー設定に従う場合は、<certificate_cn>をaliceに設定する必要があります。
<?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> <customBinding> <binding name="HelloWorldSoapHttp"> <security defaultAlgorithmSuite="Basic128" authenticationMode="UserNameForCertificate" requireDerivedKeys="false" securityHeaderLayout="Lax" includeTimestamp="true" keyEntropyMode="CombinedEntropy" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion= "WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSignatureConfirmation="true"> <localClientSettings cacheCookies="true" detectReplays="false" 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> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </textMessageEncoding> <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="HelloWorldSoapHttp" contract="HelloWorld" name="HelloWorldPort" behaviorConfiguration="secureBehaviour" > <identity> <dns value="<certificate_cn>"/> </identity> </endpoint> </client> </system.serviceModel> </configuration>
Oracle WSM 11gクライアントおよびMicrosoft WCF/.NET 3.5 Webサービスを構成するには、次の各項で説明する手順を実行します。
.NET Webサービスを作成します。
詳細は、http://msdn.microsoft.com/en-us/library/ms731835.aspx
の『How to: Define a Windows Communication Foundation Service Contract』を参照してください。
必ず、SymmetricSecurityBindingElementを使用してWebサービスのカスタム・バインディングを作成してください。例は、「.NET Webサービス・クライアントの例」を参照してください。
証明書ファイルを作成して、Webサービス・サーバー上のキーストアにインポートします。
VisualStudioを使用する場合、コマンドは次のようになります。
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にインポートします。
keytoolコマンドを使用して、Webサービス・サーバー上に作成された証明書をクライアント・サーバーにインポートします。例:
keytool -import -alias wsmcert3 -file C:\wsmcert3.cer -keystore <owsm_client_keystore>
Solutions Explorerで「Web service Solution」プロジェクトを右クリックし、「Open Folder In Windows Explorer」をクリックします。
bin/Debugフォルダに移動します。
<project>.exeファイルをダブルクリックします。このコマンドにより、指定したURLでWebサービスが実行されます。
JDeveloperを使用して、.NET Webサービスを使用するSOAコンポジットを作成します。詳細は、SOA Suiteの開発者ガイドを参照してください。
JDeveloperで、.NETサービスのWSDLを使用してパートナ・リンクを作成します。
oracle/wss11_username_token_with_message_protection_client_policyポリシーをWebサービス・クライアントにアタッチします。
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービス・クライアントへのポリシーのアタッチに関する項を参照してください。
csf-keyおよびkeystore.recipient.aliasの構成を指定します。
この情報を指定するには、ポリシーをアタッチするときにポリシー構成をオーバーライドします。詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のオーバーライド可能なクライアントのアタッチに関する項を参照してください。
必ず、手順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>
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.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt; sm.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005 WSSecurityPolicy11BasicSecurityProfile10; sm.RequireSignatureConfirmation = true; 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(); } }
この項では、次の相互運用性シナリオにおいてSSL経由のユーザー名トークンを実装する方法について説明します。
Microsoft WCF/.NET 3.5クライアントおよびOracle WSM 11g Webサービスを構成するには、次の各項で説明する手順を実行します。
サーバーをSSL用に構成します。
詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebLogic ServerへのSSLの構成(一方向)およびWebLogic ServerへのSSLの構成(双方向)に関する項を参照してください。
次のポリシーの1つのコピーを作成します。
oracle/wss_username_token_over_ssl_service_policy
oracle/wss_saml_or_username_token_over_ssl_service_policy
注意: 使用できることがわかっている有効なポリシー・セットが常にあるように、事前定義済ポリシーは変更しないことをお薦めします。 |
次のようにして、ポリシー設定を編集します。
必要な作成時間構成設定を無効化します。
Nonceが必要構成設定を無効化します。
それ以外の構成設定はすべてデフォルトの構成設定のままにしておきます。
詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』の既存のポリシーからのWebサービス・ポリシーの作成に関する項を参照してください。
ポリシーをアタッチします。
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービスへのポリシーのアタッチに関する項を参照してください。
WebサービスのWSDLを使用して、.NETクライアントを生成します。
詳細は、http://msdn.microsoft.com/en-us/library/ms733133.aspx
の『How to: Create a Windows Communication Foundation Client』を参照してください。
クライアント・プロジェクトのSolution Explorerで、「references」を右クリックして「Add reference」を選択し、C:\Windows\Microsoft .NET framework\v3.0\Windows Communication Framework\System.Runtime.Serialization.dllを参照することにより、参照を追加します。
「app.configファイルの編集」の説明に従って、app.configファイルを編集します。
プロジェクトをコンパイルします。
コマンド・プロンプトを開いて、プロジェクトのDebugフォルダに移動します。
<client_project_name>.exeと入力して[Enter]を押します。
app.configファイルの編集
次の例に示すようにapp.configファイルを編集して、証明書ファイルを更新し、リプレイを無効化します(変更部分は太字で示されています)。
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <customBinding> <binding name="BPELProcess1Binding"> <security defaultAlgorithmSuite="Basic128" authenticationMode="UserNameOverTransport" requireDerivedKeys="false" securityHeaderLayout="Lax" includeTimestamp="true" keyEntropyMode="CombinedEntropy" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversation February2005WSSecurityPolicy11BasicSecurityProfile10" 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> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </textMessageEncoding> <httpsTransport 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" requireClientCertificate="false"/> </binding> </customBinding> </bindings> <client> <endpoint address=" https://host:port/soa-infra/services/default/IO_NET6/bpelprocess1_client_ep" binding="customBinding" bindingConfiguration="BPELProcess1Binding" contract="BPELProcess1" name="BPELProcess1_pt" /> </client> </system.serviceModel> </configuration>
次の各項では、WS-Security 1.1標準に準拠するメッセージ保護付き相互認証を実装する方法について説明します。
相互運用性のための構成の前提条件
次のコマンドを使用して、サービス側のキーストアからX.509証明書ファイルを.cerファイル(alice.cerなど)にエクスポートします。
keytool -export -alias alice -file C:\alice.cer -keystore default-keystore.jks
Microsoft Management Console (mmc)を使用して、(前にエクスポートした)証明書ファイルをクライアント・サーバー上のキーストアにインポートします。詳細は、http://msdn.microsoft.com/en-us/library/ms788967.aspx
の『How to: View Certificates with the MMC Snap-in』を参照してください。
コマンド・プロンプトを開きます。
mmcと入力して[Enter]を押します。
「File」→「Add/Remove snap-in」を選択します。
「Add and Choose Certificates」を選択します。
注意: ローカル・マシン・ストア内の証明書を表示するためには、管理者ロールを持っている必要があります。 |
「Add」を選択します。
「My user account」→「finish」を選択します。
「OK」をクリックします。
「Console Root」→「Certificates -Current user」→「Personal」→「Certificates」の順に開きます。
「Certificates」を右クリックし、「All tasks」→「Import」を選択してCertificate importウィザードを起動します。
「Next」をクリックし、「Browse」を選択して、前にエクスポートした.cerファイルに移動します。
「Next」をクリックし、デフォルトを受け入れてウィザードを終了します。
Microsoft WCF/.NET 3.5クライアントおよびOracle WSM 11g Webサービスを構成するには、次の各項で説明する手順を実行します。
SOAコンポジットを作成してデプロイします。
Enterprise Managerで、次のポリシーをクローニングします。
oracle/wss11_x509_token_with_message_protection_service_policy
ポリシー名をwss11_x509_token_with_message_protection_service_policy_netに変更します。
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"/>
Enterprise Managerを使用して、ポリシーをWebサービスにアタッチします。
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービスへのポリシーのアタッチに関する項を参照してください。
SVCUtilユーティリティを使用して、クライアント・プロキシを作成し(「サンプルのクライアント・プログラム」を参照)、デプロイされたWebサービスから構成ファイルを作成します。
クライアント・プロジェクトのSolution Explorerで、「references」を右クリックして「Add reference」を選択し、C:\Windows\Microsoft .NET framework\v3.0\Windows Communication Framework\System.Runtime.Serialization.dllを参照することにより、参照を追加します。
app.config構成ファイルを作成します。次のコードを<system.serviceModel>要素の後に追加します。
<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> <customBinding>
次のようにエンドポイント動作を変更します。
<endpoint address="http://<server>:<port>//MyWebService1SoapHttpPort" binding="customBinding" bindingConfiguration="MyWebService1SoapHttp" contract="MyWebService1" name="MyWebService1SoapHttpPort" behaviorConfiguration="secureBehaviour" > <identity> <dns value="<certificate_cn>"/> </identity> </endpoint>
次のようにしてメッセージ・リプレイ検出を無効化します。
<localClientSettings cacheCookies="true" detectReplays="false" replayCacheSize="900000" maxClockSkew="00:05:00" maxCookieCachingTime="Infinite"
次に示すようにカスタム・バインディングを作成します。
<security defaultAlgorithmSuite="Basic128" authenticationMode="MutualCertificate"
構成ファイルの例は、「サンプルのapp.configファイル」を参照してください。
プロジェクトをコンパイルします。
コマンド・プロンプトを開いて、プロジェクトのDebugフォルダに移動します。
<client_project_name>.exeと入力して[Enter]を押します。
サンプルのapp.configファイル
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> <customBinding> <binding name="BPELProcess1Binding"> <security defaultAlgorithmSuite="Basic128" authenticationMode="MutualCertificate" requireDerivedKeys="false" securityHeaderLayout="Lax" includeTimestamp="true" keyEntropyMode="CombinedEntropy" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversation February2005WSSecurityPolicy11BasicSecurityProfile10" requireSignatureConfirmation="true"> <localClientSettings cacheCookies="true" detectReplays="false" 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> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </textMessageEncoding> <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="BPELProcess1Binding" contract="BPELProcess1" name="BPELProcess1_pt" > <identity> <dns value=<certificate_cn>/> </identity> </endpoint> </client> </system.serviceModel> </configuration>
サンプルのクライアント・プログラム
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(); } } }
Oracle WSM 11gクライアントおよびMicrosoft WCF/.NET 3.5 Webサービスを構成するには、次の各項で説明する手順を実行します。
.NET Webサービスを作成します。
詳細は、http://msdn.microsoft.com/en-us/library/ms731835.aspx
の『How to: Define a Windows Communication Foundation Service Contract』を参照してください。
.NET Webサービスの例については、「.NET Webサービス・クライアントの例」を参照してください。
SymmetricSecurityBindingElementを使用して、Webサービスのカスタム・バインディングを作成します。
詳細は、http://msdn.microsoft.com/en-us/library/ms730305.aspx
の『How to: Create a Custom Binding Using the SecurityBindingElement』を参照してください。
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;
アプリケーションをデプロイします。
JDeveloperを使用して、.NET Webサービスを使用するSOAコンポジットを作成します。詳細は、SOA Suiteの開発者ガイドを参照してください。
JDeveloperで、.NETサービスのWSDLを使用してパートナ・リンクを作成し、次のようにインポートを追加します。
<wsdl:import namespace="<namespace>" location="<WSDL location>"/>
Enterprise Managerで、wss11_x509_token_with_message_protection_service_policyポリシーをクローニングします。このポリシーをwss11_x509_token_with_message_protection_service_policy_netという名前に変更します。
wss11_x509_token_with_message_protection_service_policy_netをエクスポートします。encrypted="true"を"false"に変更し、再びインポートします。
<orasp:x509-token orasp:enc-key-ref-mech="thumbprint" orasp:is-encrypted="true" orasp:is-signed="false" orasp:sign-key-ref-mech="direct"/>
ポリシーをWebサービス・クライアントにアタッチします。
ポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービス・クライアントへのポリシーのアタッチに関する項を参照してください。
keystore.recipient.aliasの構成を指定します。
この情報を指定するには、ポリシーをアタッチするときにポリシー構成をオーバーライドします。詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のオーバーライド可能なクライアントのアタッチに関する項を参照してください。
必ず、手順4でインポートした証明書(wsmcert3)の別名としてkeystore.recipient.aliasを構成してください。
クライアントからWebサービス・メソッドを起動します。
この項では、次の相互運用性シナリオにおいてメッセージ保護付きKerberosを実装する方法について説明します。
次の前提条件ステップを実行します。
鍵配布センター(KDC)およびアクティブ・ディレクトリ(AD)を構成します。詳細は、http://docs.sun.com/app/docs/doc/820-3746/gisgm?l=en&a=view
のWindowsのアクティブ・ディレクトリおよびドメイン・コントローラの構成方法(ドメイン・コントローラがKDCの役割を果たします)についての項を参照してください。
例5-1に示すように、c:\winntにあるKerberosの構成ファイルkrb5.confを設定します。
例5-1 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 = <hostname>:<portnumber> admin_server = <hostname>:<portnumber> 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 }
Microsoft WCF/.NET 3.5クライアントおよびOracle WSM 11g Webサービスを構成するには、次の各項で説明する手順を実行します。
Webサービス・アプリケーションを作成します。
wss11_kerberos_with_message_protection_service_policyポリシーをコピーします。
ポリシー設定を編集して、アルゴリズム・スイートを「Basic128Rsa15」に設定します。
Webサービスにポリシーをアタッチします。Fusion Middleware Controlを使用してデプロイ時にポリシーをアタッチする方法の詳細は、『Oracle Fusion Middleware Webサービスのためのセキュリティおよび管理者ガイド』のWebサービス・クライアントへのポリシーのアタッチに関する項を参照してください。
アプリケーションをデプロイします。
ADにユーザーを作成して、Webサービスがホストされるホストを指定します。デフォルトでは、ユーザー・アカウントはRC4-HMAC暗号を使用して作成されます。たとえば、ユーザー名をfoobarとすると、HTTP/foobarとなります。
次のように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サービスがホストされているマシンに移動します。
次のようにsetSpnコマンドを使用して、サービス・プリンシパルをユーザーにマッピングします。
setSpn -A HTTP/foobar@MYCOMPANY.LOCAL foobar
setSpn -L foobar
ユーザーにマッピングするSPNは1つにしてください。複数のSPNがユーザーにマッピングされている場合は、setSpn -D <spname> <username>
コマンドを使用して削除します。
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>
バインドのサンプルを例5-2に示します。
例5-2 バインドのサンプル
<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>
svcutil.exeユーティリティは、Oracle WSMポリシーがアタッチされているWebサービスでは機能しません。ユーティリティを実行する前にサービスからポリシーをデタッチし、プロキシを生成して、すべてのアーティファクトの生成に成功してから再びアタッチします。
クライアント・プログラムを実行します。