このタスクについて
クライアント認証が有効になっていると、クライアントは
eXtreme Scale サーバーに接続する前に認証されます。
このセクションでは、
eXtreme Scale サーバー環境でどのようにすればクライアント認証が可能であるかを、サンプル
SecureSimpleApp.java を使用して実証します。
クライアント資格情報SecureSimpleApp.java サンプルでは、次の 2 つのプラグイン実装を使用してクライアント資格情報を取得します。
com.ibm.websphere.objectgrid.security.plugins.builtins.UserPasswordCredential
com.ibm.websphere.objectgrid.security.plugins.builtins.UserPasswordCredentialGenerator
これらのプラグインについて詳しくは、クライアント認証プログラミングを参照してください。
サーバー・オーセンティケーター
この例では、テストとサンプルが目的である eXtreme Scale 組み込み実装 KeyStoreLoginAuthenticator を使用します (鍵ストアは単純なユーザー・レジストリーであり、実動には使用しないようにしてください)。
詳しくは、クライアント認証プログラミングのオーセンティケーター・プラグインについてのトピックを参照してください。
- コマンド行ウィンドウで、wxs_home ディレクトリーに移動します。
- Java SE セキュリティー・チュートリアル - ステップ 3 で作成した wxs_home/security ディレクトリーに切り替えます。
- サーバーに対する認証の方法を実施する JAAS 構成ファイル (og_jaas.config) を作成します。 security.xml ファイルで参照されている KeyStoreLoginAuthenticator は、JAAS ログイン・モジュール「KeyStoreLogin」を使用することによって鍵ストアを使用します。
鍵ストアは、KeyStoreLoginModule クラスに対するオプションとして構成できます。
og_jaas.config
KeyStoreLogin{
com.ibm.websphere.objectgrid.security.plugins.builtins.KeyStoreLoginModule required
keyStoreFile="../security/sampleKS.jks" debug = true;
};
- パスワードが sampleKS1 である鍵ストア sampleKS.jks を作成します。
- java_home/bin ディレクトリーに切り替え、keytool を実行します。
- wxs_home /security ディレクトリーに切り替え、それぞれ独自のパスワードを持つ 2 人のユーザー「manager」および「cashier」を作成します。
- keytool を使用して、パスワード「manager1」を持つユーザー「manager」を鍵ストア sampleKS.jks に作成します。
keytool -genkey -v -keystore ./sampleKS.jks -storepass sampleKS1
-alias manager -keypass manager1
-dname CN=manager,O=acme,OU=OGSample -validity 10000
- keytool を使用して、パスワード「cashier1」を持つユーザー「cashier」を鍵ストア sampleKS.jks に作成します。
keytool -genkey -v -keystore ./sampleKS.jks -storepass sampleKS1
-alias cashier -keypass cashier1 -dname CN=cashier,O=acme,OU=OGSample
-validity 10000
- wxs_home/properties ディレクトリーに切り替えます。
- sampleClient.properties ファイルをコピーします。
cp ../properties/sampleClient.properties client.properties
- wxs_home/security ディレクトリーで、これを client.properties として保存します。
client.properties ファイルに対して以下の変更を行います。
- securityEnabled: securityEnabled を true (デフォルト値) に設定します。認証を含むクライアント・セキュリティーが有効になります。
- credentialAuthentication: credentialAuthentication を Supported (デフォルト値) に設定すると、クライアントで資格情報認証がサポートされます。
- transportType: transportType を TCP/IP に設定すると、SSL は使用されません。
- sampleServer.properties ファイルをコピーします。
cp ../properties/sampleServer.properties server.properties
- wxs_home/security ディレクトリーで、これを server.properties として保存します。
server.properties ファイルで以下の変更を行います。
- securityEnabled: securityEnabled 属性を true に設定します。
- transportType: transportType 属性を TCP/IP に設定します。すなわち、SSL は使用されません。
- secureTokenManagerType: secureTokenManagerType 属性を none に設定します。これで、セキュア・トークン・マネージャーが構成されなくなります。
- wxs_home/bin ディレクトリーに移動し、ご使用のプラットフォームに応じて、次のいずれかのコマンドを実行してカタログ・サーバーを始動します。 セキュリティー・プロパティーを渡すために、-clusterFile および -serverProps のコマンド行オプションを実行する必要があります。
![[Unix]](./icons/ngunix.gif)
startOgServer.sh catalogServer -clusterSecurityFile ../security/security.xml
-serverProps ../security/server.properties -jvmArgs
-Djava.security.auth.login.config="../security/og_jaas.config"
startOgServer.bat catalogServer -clusterSecurityFile ../security/security.xml
-serverProps ../security/server.properties -jvmArgs
-Djava.security.auth.login.config="../security/og_jaas.config"
- 次のいずれかのスクリプトを使用して、c0 という名前のコンテナー・サーバーを始動します。-serverProps を発行するとサーバー・プロパティー・ファイルが渡されます。
![[Linux]](./icons/nglinux.gif)
startOgServer.sh c0 -objectgridFile ../xml/SimpleApp.xml
-deploymentPolicyFile ../xml/SimpleDP.xml
-catalogServiceEndPoints localhost:2809
-serverProps ../security/server.properties
-jvmArgs -Djava.security.auth.login.config="../security/og_jaas.config"
startOgServer.bat c0 -objectgridFile ../xml/SimpleApp.xml
-deploymentPolicyFile ../xml/SimpleDP.xml
-catalogServiceEndPoints localhost:2809
-serverProps ../security/server.properties
-jvmArgs -Djava.security.auth.login.config="../security/og_jaas.config"
- カタログ・サーバーとコンテナー・サーバーが始動されたならば、次のようにして sec_sample.jar サンプルを実行します。
java -classpath ../lib/objectgrid.jar;../applib/sec_sample.jar
com.ibm.websphere.objectgrid.security.sample.guide.SecureSimpleApp
../security/client.properties manager manager1
前の例にあるように、セミコロン (;) ではなくコロン (:) をクラスパスの分離文字として使用します。
クラスを発行すると、以下の出力が得られます。
The customer name for ID 0001 is fName lName.
- 次のように xscmd コマンド・ユーティリティーを実行して、「accounting」グリッドに挿入された「customer」マップのサイズを確認します。
![[Unix]](./icons/ngunix.gif)
xscmd.sh -c showMapSizes -g accounting -m customer -username manager -password manager1
xscmd.bat -c showMapSizes -g accounting -m customer -username manager -password manager1
- オプション: コンテナー・サーバーまたはカタログ・サーバーを停止する場合は、stopOgServer を使用することができます。
ただし、セキュリティー構成ファイルを指定する必要があります。
サンプル・クライアント・プロパティー・ファイルは、以下の 2 つのプロパティーを定義して、ユーザー ID とパスワードの資格情報 (manager/manager1) を生成します。
credentialGeneratorClass=com.ibm.websphere.objectgrid.security.plugins.builtins.UserPasswordCredentialGenerator
credentialGeneratorProps=manager manager1
次のコマンドを使用してコンテナー c0 を停止します。
![[Unix]](./icons/ngunix.gif)
stopOgServer.sh c0 -catalogServiceEndPoints
localhost:2809 -clientSecurityFile ..¥security¥client.properties
stopOgServer.bat c0 -catalogServiceEndPoints
localhost:2809 -clientSecurityFile ..¥security¥client.properties
-clientSecurityFile オプションを指定しないと、次のメッセージを伴う例外が表示されます。
>>
SERVER (id=39132c79, host=9.10.86.47) TRACE START:
>>
org.omg.CORBA.NO_PERMISSION: Server requires credential authentication
but there is no security context from the client. This usually happens
when the client does not pass a credential the server.
vmcid:
0x0
minor code: 0
completed:
No
また、以下のコマンドを使用してカタログ・サーバーをシャットダウンすることもできます。
ただし、チュートリアルの次のステップに続行する場合は、このカタログ・サーバーを実行させたままにしておいてかまいません。
![[Unix]](./icons/ngunix.gif)
stopOgServer.sh catalogServer -catalogServiceEndPoints
localhost:2809 -clientSecurityFile ..¥security¥client.properties
stopOgServer.bat catalogServer -catalogServiceEndPoints
localhost:2809 -clientSecurityFile ..¥security¥client.properties
カタログ・サーバーをシャットダウンすると、次の出力が表示されます。
CWOBJ2512I: ObjectGrid server catalogServer
stopped
これで、認証を有効にすることにより、正常にシステムが部分的にセキュアになりました。
サーバーを構成してユーザー・レジストリーをプラグインし、クライアントを構成してクライアント資格情報を提供するようにし、クライアント・プロパティー・ファイルおよびクラスター XML ファイルを変更して認証を有効にしています。
無効なパスワードを入力すると、ユーザー名およびパスワードが誤っていることを示す例外が表示されます。
クライアント認証について詳しくは、アプリケーション・クライアントの認証を参照してください。
次のチュートリアル・ステップ