Java Authentication SPI for Containers (JASPIC) ユーザー・フィーチャーの構成

Liberty サーバーで提供される com.ibm.wsspi.security.jaspi.ProviderService インターフェースを使用して、インバウンド Web 要求を認証するための JASPIC プロバイダーを開発できます。

このタスクについて

Java™ Authentication SPI for Containers 仕様 JSR 196に、認証プロバイダー用のインターフェースが定義されています。 Liberty サーバーで、JASPIC プロバイダーをユーザー・フィーチャーとしてパッケージ化する必要があります。 そのフィーチャーは、com.ibm.wsspi.security.jaspi.ProviderService インターフェースを実装する必要があります。

手順

  1. com.ibm.wsspi.security.jaspi.ProviderService インターフェースを実装するサービスを提供する OSGi コンポーネントを作成します。

    ProviderService インターフェースは、 javax.security.auth.message.config.AuthConfigProvider インターフェースを実装する JASPIC プロバイダー・クラスのインスタンスを取得するために Liberty ランタイムが呼び出すメソッド getAuthConfigProviderを定義します。

    以下の例では、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 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 factory.
            // This example reads the properties from the OSGi
            // component definition.
            configProps = (Map<String, String>) cc.getProperties();
        }
    
        protected void deactivate(ComponentContext cc) {}
    }
  2. このコンポーネントを、ユーザー・フィーチャーの一部である OSGi バンドルに、JASPIC 認証プロバイダーと一緒にパッケージします。
  3. フィーチャーに OSGi サブシステム・コンテンツが含まれていることを確認します: com.ibm.websphere.appserver.jaspic-1.1; type="osgi.subsystem.feature"
  4. フィーチャーがユーザー製品拡張の場所にインストールされたら、フィーチャー名を使用して server.xml ファイルを構成します。 以下に例を示します。
    <featureManager>
       ...
       <feature>usr:myJaspiProvider</feature>
    </featureManager>