Liberty でのカスタム・ユーザー・リポジトリーの開発

Liberty サーバーで提供されている com.ibm.ws.security.wim.RepositoryFactory インターフェースと com.ibm.ws.security.wim.Repository インターフェースを実装することにより、カスタム・ユーザー・リポジトリー・クラスを開発することができます。

このタスクについて

リポジトリー・インターフェースを使用すると、ほぼすべてのタイプのアカウント・リポジトリーへのサポートが使用可能になります。

手順

  1. リポジトリー・ファクトリー (com.ibm.ws.security.wim.RepositoryFactory) インターフェースを実装します。RepositoryFactory インターフェースは構成パラメーターを取得し、リポジトリーのインスタンスを作成します。 以下に例を示します。
    	public Repository getRepository(Map<String, Object> properties) throws WIMException {
    	return new CustomRepository(properties);}
  2. リポジトリー (com.ibm.ws.security.wim.Repository) インターフェースを実装します。このクラスには、実際のリポジトリー操作があります。
    public class CustomRepository extends RepositoryConfiguration implements Repository {
    
        public CustomRepository(Map<String, Object> properties) {
            System.out.println("Constructor with " + properties);
        }
  3. 実装クラスを OSGi サービスに変換します。 詳細については、『OSGi Declarative Services に対するサービスの宣言』を参照してください。
  4. カスタム・ユーザー・リポジトリーを OSGi バンドルとしてパッケージし、ユーザー・リポジトリー・サービスをエクスポートします。OSGi バンドルの作成方法について詳しくは、『OSGi サービス・バンドルの作成』を参照してください。
  5. フィーチャー・マニフェスト・ファイルを作成して、この OSGi バンドルを組み込みます。詳細については、『Liberty: 製品拡張』を参照してください。
  6. フィーチャーがユーザー製品拡張ロケーションにインストールされた後、 そのフィーチャー名を指定して server.xml ファイル を構成します。 以下に例を示します。
    <featureManager>
    	...
    	<feature>usr:customRepositorySample-1.0</feature>
    </featureManager>
    ダウンロード可能なカスタム・ユーザー・レジストリー・サンプルについては、「https://developer.ibm.com/wasdev/downloads/#asset/samples-Custom_User_Registry」を参照してください。

例

以下のリポジトリー・ファクトリー・インターフェースおよびリポジトリー・インターフェースのサンプルを参照してください。
リポジトリー・ファクトリー・インターフェース
package com.myorg;

import java.util.Map;

import org.osgi.service.component.ComponentContext;

import com.ibm.websphere.security.wim.exception.WIMException;
import com.ibm.ws.security.wim.Repository;
import com.ibm.ws.security.wim.RepositoryFactory;

public class CustomRepositoryFactory implements RepositoryFactory {

    @Override
    public Repository getRepository(Map<String, Object> properties) throws WIMException {
        System.out.println("getRepository " + properties);
        return new CustomRepository(properties);
    }

    public void activate(ComponentContext cc, Map<String, Object> properties) {
        System.out.println("In activate");
    }

    public void deactivate(ComponentContext cc) {
        System.out.println("In deactivate");
    }
}
リポジトリー・インターフェース
package com.myorg;

import java.util.Map;

import com.ibm.websphere.security.wim.exception.WIMException;
import com.ibm.websphere.security.wim.model.Root;
import com.ibm.ws.security.wim.Repository;
import com.ibm.ws.security.wim.RepositoryConfiguration;

public class CustomRepository extends RepositoryConfiguration implements Repository {

    public CustomRepository(Map<String, Object> properties) {
        System.out.println("Constructor with " + properties);
    }

    @Override
    public Root create(Root arg0) throws WIMException {
        throw new WIMException("Method not supported");
    }

    @Override
    public Root delete(Root arg0) throws WIMException {
        throw new WIMException("Method not supported");
    }

    @Override
    public Root get(Root arg0) throws WIMException {
        throw new WIMException("Method not supported");
    }

    @Override
    public String getRealm() {
        return "customRepository";
    }

    @Override
    public Root login(Root arg0) throws WIMException {
        throw new WIMException("Method not supported");
    }

    @Override
    public Root search(Root arg0) throws WIMException {
        throw new WIMException("Method not supported");
    }

    @Override
    public Root update(Root arg0) throws WIMException {
        throw new WIMException("Method not supported");
    }
}

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: Tuesday, 12 July 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-dist&topic=twlp_sec_cust_repository
ファイル名: twlp_sec_cust_repository.html