Liberty プロファイル・サーバーで提供されている com.ibm.wsspi.security.jaspi.ProviderService インターフェースを使用して、
インバウンド Web 要求を認証するための JASPIC プロバイダーを開発できます。
このタスクについて
Java™ Authentication
SPI for Containers 仕様 JSR
196 に、認証プロバイダー用のインターフェースが定義されています。Liberty プロファイル・サーバーで、JASPIC プロバイダーをユーザー・フィーチャーとしてパッケージする必要があります。そのフィーチャーは、com.ibm.wsspi.security.jaspi.ProviderService インターフェースを実装する必要があります。
手順
- com.ibm.wsspi.security.jaspi.ProviderService インターフェースを実装するサービスを提供する OSGi コンポーネントを作成します。
ProviderServiceインターフェースには getAuthConfigProvider メソッドが定義されていて、
Liberty プロファイル・ランタイムはこのメソッドを呼び出して、javax.security.auth.message.config.AuthConfigProvider インターフェースを実装する JASPIC プロバイダー・クラスのインスタンスを取得します。
以下の例では、OSGi 宣言型サービスのアノテーションが使用されています。
@package com.mycompany.jaspi;
import java.util.Map;
import javax.security.auth.message.config.AuthConfigFactory;
import javax.security.auth.message.config.AuthConfigProvider;
import org.osgi.service.component.ComponentContext;
import com.mycompany.jaspi.SampleAuthConfigProvider;
import com.ibm.wsspi.security.jaspi.ProviderService;
@Component(service = { ProviderService.class },
configurationPolicy = ConfigurationPolicy.IGNORE,
immediate = true,
property = { "myPoviderPoperty1=value1",
"myPoviderPoperty2=value2"})
public class SampleJaspiProviderService implements ProviderService {
Map<String, String> configProps = null;
// This method called by the Liberty profile runtime
// to get an instance of AuthConfigProvider
@Override
public AuthConfigProvider getAuthConfigProvider(Map<String, String>
AuthConfigFactory factory)
{
return new SampleAuthConfigProvider(configProps, factory);
}
protected void activate(ComponentContext cc) {
// Read provider config properties here if needed,
// then pass them to the AuthConfigProvider ctor.
// This example reads the properties from the OSGi
// component definition.
configProps = (Map<String, String>) cc.getProperties();
}
protected void deactivate(ComponentContext cc) {}
}
- このコンポーネントを、ユーザー・フィーチャーの一部である OSGi バンドルに、JASPIC 認証プロバイダーと一緒にパッケージします。
- フィーチャーには OSGi サブシステム・コンテンツを必ず含めてください: com.ibm.websphere.appserver.jaspic-1.1;
type="osgi.subsystem.feature"。
- フィーチャーがユーザー製品拡張ロケーションにインストールされた後、
そのフィーチャー名を指定して server.xml ファイル
を構成します。以下に例を示します。
<featureManager>
...
<feature>usr:myJaspiProvider</feature>
</featureManager>