15.6. STS クライアントのプーリング
PicketLink はサーバー側で STS クライアントのプールを提供します。これにより、ボトルネックであった STS クライアントの作成が解消されます。
クライアントプーリングは、SAML チケットの取得に STS クライアントが必要となるログインモジュールから利用できます。
STS クライアントプーリングを使用できるログインモジュールは以下のとおりです。
- org.picketlink.identity.federation.core.wstrust.auth.STSIssuingLoginModule
- org.picketlink.identity.federation.core.wstrust.auth.STSValidatingLoginModule
- org.picketlink.trust.jbossws.jaas.JBWSTokenIssuingLoginModule
プールのデフォルトのクライアント数を各ログインモジュールに設定するには、
initialNumberOfClients
ログインモジュールオプションから設定します。
STSClientPoolFactory クラス
org.picketlink.identity.federation.bindings.stspool.STSClientPoolFactory
は、クライアントプール機能をアプリケーションに提供します。
STSClientPoolFactory の使用
STS クライアントは、設定をキーとして使用してサブプールに挿入されます。STSClientPool インスタンスを取得した後、設定を基にサブプールを初期化します (STS クライアントの最初の数またはデフォルトの数)。
final STSClientPool pool = STSClientPoolFactory.getPoolInstance(); pool.createPool(20, stsClientConfig); final STSClient client = pool.getClient(stsClientConfig);
final STSClientPool pool = STSClientPoolFactory.getPoolInstance();
pool.createPool(20, stsClientConfig);
final STSClient client = pool.getClient(stsClientConfig);
クライアントで作業を終えたら、以下のようにプールに返すことができます。
pool.returnClient();
pool.returnClient();
指定の設定にサブプールがすでに存在するかどうかをチェックするには、以下を実行します。
if (! pool.configExists(stsClientConfig) { pool.createPool(stsClientConfig); }
if (! pool.configExists(stsClientConfig) {
pool.createPool(stsClientConfig);
}
PicketLink Federation サブシステムが有効になると、デプロイメント向けに作成されたすべてのクライアントプールはアンデプロイ処理中に自動的に破棄されます。プールを手動で破棄するには、以下を実行します。
pool.destroyPool(stsClientConfig);
pool.destroyPool(stsClientConfig);