ヘッダーをスキップ
Oracle® Fusion Middleware Identity Governance Framework開発者ガイド
11gリリース2(11.1.2)
B71699-01
  目次へ移動
目次

前
 
 

4 アイデンティティ・ディレクトリAPIへの移行

この章では、ユーザーおよびロールAPIからアイデンティティ・ディレクトリAPIにアプリケーションを移行する方法を説明します。この章の内容は次のとおりです。

4.1 概要

『Oracle Fusion Middlewareアプリケーション・セキュリティ・ガイド』および『Oracle Fusion Middleware Oracle Platform Security ServicesユーザーおよびロールJava APIリファレンス』に記載されているユーザーおよびロールAPIを使用するアプリケーションがある場合、そのかわりにアイデンティティ・ディレクトリAPIを使用するよう変更できます。

アイデンティティ・ディレクトリAPIは、jps-configファイルからLDAPベースのアイデンティティ・ストアの確認を取得します。したがって、ユーザーおよびロールAPIからアイデンティティ・ディレクトリAPIにアプリケーションを移行する際、jps-configファイルの構成を変更する必要はありません。

ユーザーおよびロールAPIをプログラム的な構成で初期化するアプリケーションは、類似のメソッドを使用して、アイデンティティ・ディレクトリAPIを初期化できます。詳細は、第2.4.3項「メモリー内アイデンティティ・ディレクトリ・ハンドルの初期化と取得」を参照してください。

4.2 アプリケーションの移行

ユーザーおよびロールAPIからアイデンティティ・ディレクトリAPIに移行するアプリケーションでは、次のコード変更が必要です。

4.2.1 APIの初期化

プロセスは、IdentityStoreService.GetIdmStore()を使用してoracle.security.idm.IdentityStoreハンドルを取得する方法に類似しています。アイデンティティ・ディレクトリAPIは、IdentityStoreService.getIdentityStore()を使用してIdentityDirectoryハンドルを取得します。次に例を示します。

import oracle.igf.ids.IdentityDirectory;
import oracle.igf.ids.IDSException;
import oracle.security.jps.JpsContext;
import oracle.security.jps.JpsContextFactory;
import oracle.security.jps.service.idstore.IdentityStoreService;

// Get IdentityDirectory from JpsContext
JpsContext context = JpsContextFactory.getContextFactory().getContext();
IdentityStoreService idstore = (IdentityStoreService)
context.getServiceInstance(IdentityStoreService.class);
Identity Directory ids = idstore.getIdentityStore();

4.2.2 UserManagerおよびGroupManagerのハンドルの取得

ユーザー関連のCRUD操作はoracle.igf.ids.UserManagerを使用して、ロール関連のCRUD操作はoracle.igf.ids.GroupManagerを使用して実行できます。UserManagerおよびGroupManagerのハンドルは、IdentityDirectoryオブジェクトから取得できます。次に例を示します。

import oracle.igf.ids.UserManager;
import oracle.igf.ids.GroupManager;

// Get UserManager and GroupManager handles
        UserManager uMgr = ids.getUserManager();
        GroupManager gMgr = ids.getGroupManager();

4.2.3 検索フィルタ

簡易検索フィルタまたは複雑な検索フィルタの作成には、oracle.igf.ids.SearchFilterを使用します。次に例を示します。

import oracle.igf.ids.SearchFilter;

// Simple search filter for (firstname equals "john")

SearchFilter filter1 = new SearchFilter("firstname", 
SearchFilter.Operator.EQUALS, "john");

        // Complex search filter for 
        ((title contains "manager") and (org equals "amer")) or 
((title contains "senior manager") and (org equals "apac"))

            SearchFilter filter = new SearchFilter(
                SearchFilter.LogicalOp.OR,
                new SearchFilter(SearchFilter.LogicalOp.AND,
                  new SearchFilter("manager", SearchFilter.Operator.CONTAINS,
 "manager"),
                  new SearchFilter("org", SearchFilter.Operator.EQUALS, "amer")),
                new SearchFilter(SearchFilter.LogicalOp.AND,
                  new SearchFilter("manager", SearchFilter.Operator.CONTAINS,
 "senior manager"),
                  new SearchFilter("org", SearchFilter.Operator.EQUALS, "apac")));
           

4.2.4 CRUD操作

ユーザー、グループ、組織のエンティティおよび汎用エンティティに対する作成/読取り/更新/削除(CRUD)操作の実行については、次の各項で説明します。

4.2.4.1 ユーザーの検索

ユーザーの検索に使用されるAPIを次に示します。

  • 指定されたprincipal識別子のユーザーを取得します。次に例を示します。

    User getUser(Principal principal, ReadOptions opts)
    
  • ユーザーを一意に識別する、指定されたid属性値と一致するユーザーを検索します。次に例を示します。

    User searchUser(String id, ReadOptions opts)
    
  • 指定された属性の名前および値と一致するユーザーを検索します。次に例を示します。

    User searchUser(String attrName, String attrVal, ReadOptions opts)
    
  • ユーザーを一意に識別する、指定されたGUID値と一致するユーザーを検索します。次に例を示します。

    searchUserByGuid(String guid, ReadOptions opts) 
    

4.2.4.2 ユーザーの検索

ユーザーを検索するAPIの例を次に示します。

ResultSet<User> searchUsers(SearchFilter filter, SearchOptions opts)

4.2.4.3 ユーザーの作成

ユーザーを作成するAPIの例を次に示します。

Principal createUser(List<Attribute> attrVals, CreateOptions opts)

4.2.4.4 ユーザーの削除

ユーザーを削除するAPIの例を次に示します。

  • 指定されたprincipal識別子のユーザーを削除します。

    void deleteUser(Principal principal, DeleteOptions opts)
    
  • 指定されたid属性値のユーザーを削除します。

    void deleteUser(String id, DeleteOptions opts)
    

4.2.4.5 ユーザーの認証

ユーザーを認証するAPIの例を次に示します。

  • 指定されたid属性値と一致するユーザーを認証します。

    User authenticateUser(String id, char[] password, ReadOptions opts)
    
  • 指定されたprincipal識別子のユーザーを認証します。

    boolean authenticateUser(Principal principal, char[] password)
    

4.2.4.6 ユーザーの変更と関連エンティティの管理

ユーザー属性を変更するAPIおよびその関連エンティティを取得するAPIは、UserManagerではなくUserオブジェクトにあります。

4.2.4.6.1 ユーザーの変更

ユーザーを変更するAPIの例を次に示します。

  • ユーザーの属性を変更します。

    void User.modify(List<ModAttribute> attrVals, ModifyOptions opts) 
    
  • ユーザーの属性値を設定します。

    void User.setAttributeValue(String attrName, String attrVal, ModifyOptions opts)
    
4.2.4.6.2 関連エンティティの管理

エンティティを管理するAPIの例を次に示します。

  • 管理チェーンを取得します。

    ResultSet<User> getManagementChain(int nLevels, SearchOptions opts) 
    
  • 指定されたユーザーがこのユーザーの管理者であるかどうかを確認します。

    boolean isManager(User user, boolean direct, ReadOptions opts)
    
  • 指定されたユーザーをこのユーザーの管理者として設定します。

    void setManager(User user, ModifyOptions opts)
    
  • このユーザーのReporteeをすべて取得します。

    ResultSet<User> getReportees(int nLevels,
     SearchFilter targetFilter, SearchOptions opts) 
    
  • このユーザーがメンバーとして属している、指定されたフィルタ基準と一致するグループをすべて取得します。

    ResultSet<Group> getMemberOfGroups(int
     nLevels, SearchFilter targetFilter, SearchOptions opts)
     
    
  • このユーザーが指定されたグループのメンバーであるかどうかを確認します。

    boolean isMemberOf(Group group, boolean direct, ReadOptions opts) 
    
  • 指定されたグループのメンバーとしてこのユーザーを追加します。

    void addMemberOf(Group group, ModifyOptions opts) 
    
  • 指定されたグループのメンバーからこのユーザーを削除します。

    void deleteMemberOf(Group group, ModifyOptions opts)
    

4.3 ユーザーおよびロールAPIとIDS APIとの比較

ユーザーおよびロールAPIとアイデンティティ・ディレクトリAPIの違いについて、次のトピックで説明します。

4.3.1 ユーザー関連API

表4-1に、ユーザー関連APIのメソッドと、対応するアイデンティティ・ディレクトリAPIのメソッドとの比較を示します。

表4-1 ユーザー関連APIとアイデンティティ・ディレクトリAPIとの比較

機能 ユーザー/ロールAPIのメソッド アイデンティティ・ディレクトリAPIのメソッド

ユーザーの作成

User UserManager.createUser(String name, char[] password)

User UserManager.createUser(String name, char[] password, PropertySet pset)

Principal UserManager.createUser(List<Attribute> attrVals, CreateOptions opts)

ユーザーの削除

void UserManager.dropUser(UserProfile user)

void UserManager.dropUser(User user);

void UserManager.deleteUser(Principal principal, DeleteOptions opts)

void UserManager.deleteUser(String id, DeleteOptions opts)

ユーザーの認証

User UserManager.authenticateUser(String user_id, char[] passwd)

User UserManager.authenticateUser(User user, char[] passwd)

User UserManager.authenticateUser(String user_id, String authProperty, char[] passwd)

User UserManager.authenticateUser(String id, char[] password, ReadOptions opts)

boolean UserManager.authenticateUser(Principal principal, char[] password)

ユーザーの作成がサポートされているかどうかのチェック

boolean UserManager.isCreateUserSupported()

boolean UserManager.getCapabilities().isCreateCapable()

ユーザーの変更がサポートされているかどうかのチェック

boolean UserManager.isModifyUserSupported()

boolean UserManager.getCapabilities().isUpdateCapable()

ユーザーの削除がサポートされているかどうかのチェック

boolean UserManager.isDropUserSupported()

boolean UserManager.getCapabilities().isDeleteCapable()

指定された検索基準によるユーザーの検索

SearchResponse IdentityStore.searchUsers(SearchParameters params)

ResultSet<User> UserManager.searchUsers(SearchFilter filter, SearchOptions opts)

名前/一意の名前/guidによるユーザーの検索

User IdentityStore.searchUser(String name)

User UserManager.searchUser(String id, ReadOptions opts)

User UserManager.searchUser(String attrName, String attrVal, ReadOptions opts)

特定のユーザー・オブジェクトのリポジトリにユーザーが存在するかどうかのチェック

boolean IdentityStore.exists (User user)

User.getPrincipal() 次のメソッドがnullを返す場合、ユーザーは存在しません。それ以外の場合は存在します。

User getUser(Principal principal, ReadOptions opts)

単純な検索フィルタ(1つの名前、タイプおよび値に基づいた検索)

SimpleSearchFilter

SearchFilter(String propertyName, Operator op, String propertyVal)

複雑な検索フィルタ(フィルタ条件とネストしたフィルタを使用した複数の属性に基づいた検索)

ComplextSearchFilter

SearchFilter(LogicalOp op, SearchFilter... searchFilters)

指定されたプロパティ名に対するプロパティ値の取得

String User.getPropertyVal(String propName)

ユーザー・ロールAPIはキャッシュから属性値をフェッチします。キャッシュにない場合、リポジトリからフェッチします。

String User.getAttributeValue(String attrName)

制限: リポジトリからすでにフェッチされているユーザー・オブジェクトから属性値を返します。

指定されたプロパティ名に対するユーザー・プロパティの取得

Property User.getProperty(String propName)

Attribute User.getAttribute(String attrName)

指定されたプロパティ名のセットに対するユーザー・プロパティの取得

Map User.getProperties()

Map<String, Attribute> User.getAllAttributes()

ユーザーのリポジトリからユーザー・プロパティをすべて取得します。

PropertySet User.getAllUserProperties()

Map<String, Attribute> User.getAllAttributes()

すべてのユーザー・プロパティ名のスキーマからの取得

List IdentityStore.getUserPropertyNames()

スキーマ内にあるすべてのプロパティの名前を返します。

List<String> UserManager.getEntityAttributes()

ユーザーのリポジトリ内の属性値の変更

void User.setProperty(ModProperty mprop)

void User.setAttributeValue(String attrName, String attrVal, ModifyOptions opts)

ユーザーのリポジトリ内の属性値のセットの変更

void User.setProperties(ModProperty[] modPropObjs)

void User.setProperties(LdapContext ctx, ModProperty[] modPropObjs)

void User.modify(List<ModAttribute> attrVals, ModifyOptions opts)

ユーザーの直接または間接のすべてのReporteeを取得します。

SearchResponse User.getReportees(boolean direct)

ResultSet<User> User.getReportees(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ユーザーの管理チェーンの取得

List User.getManagementChain(int max, String upToManagerName, String upToTitle)

ResultSet<User> User.getManagementChain(int nLevels, SearchOptions opts)

List<User> User.getManagementChain(int nLevels, String manager, String title, SearchOptions opts)

バイナリ属性の取得/設定

使用可能

ユーザー/ロールAPIのプロパティでは、バイナリ属性がサポートされます。

byte[] user.getJPEGPhoto()

void user.setJPEGPhoto(String imgpath)

Base64でエンコードした値を返します。

値を設定する際、ModAttributeを作成するには、Base64でエンコードした値またはbyte[]を使用できます。

レルムの選択

使用可能

env.put(OIDIdentityStoreFactory.RT_SUBSCRIBER_NAME, "<realm dn>");

IdentityStoreFactory.getIdentityStoreInstance(env);

これは、IDSオペレーション構成の一部です。APIレベルでは、searchbaseおよびcreatebaseは同様に指定できます。


4.3.2 ロール関連API

表4-2に、ロール関連APIのメソッドと、対応するアイデンティティ・ディレクトリAPIのメソッドとの比較を示します。

表4-2 ロール関連APIとアイデンティティ・ディレクトリAPIとの比較

機能 ユーザー/ロールAPIのメソッド アイデンティティ・ディレクトリAPIのメソッド

ロールの作成

Role RoleManager.createRole(String name, int scope)

Role RoleManager.createRole(String name)

Principal GroupManager.createGroup(List<Attribute> attrVals, CreateOptions opts)

ロールの削除

void RoleManager.dropRole(RoleProfile role)

void RoleManager.dropRole(Role role)

void GroupManager.deleteGroup(Principal principal, DeleteOptions opts)

ロールの作成がサポートされているかどうかのチェック

boolean RoleManager.isCreateRoleSupported()

boolean GroupManager.getCapabilities().isCreateCapable()

ロールの変更がサポートされているかどうかのチェック

boolean RoleManager.isModifyRoleSupported()

boolean GroupManager.getCapabilities().isUpdateCapable()

ロールの削除がサポートされているかどうかのチェック

boolean RoleManager.isDropRoleSupported()

boolean GroupManager.getCapabilities().isDeleteCapable()

グループがユーザーによって所有されているか

boolean RoleManager.isGranted(Role parent, Principal principal)

boolean Group.isMember(User user, boolean direct, ReadOptions opts)

boolean User.isMemberOf(Group group, boolean direct, ReadOptions opts)

グループがユーザーによって所有されているか

boolean RoleManager.isOwnedBy(Role parent, Principal principal)

boolean User.isOwnerOf(Group group, boolean direct, ReadOptions opts)

グループがユーザーによって管理されているか

boolean RoleManager.isManagedBy(Role parent, Principal principal)

サポートされていません。

ロールの直接または間接のすべてのメンバーの取得

SearchResponse Role.getGrantees(SearchFilter filter, boolean direct)

ResultSet<User> Group.getMembers(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ユーザーをメンバーとしてロールに追加します。

void RoleManager.grantRole(Role parent, Principal principal)

void Group.addMember(User user, ModifyOptions opts)

ロールのメンバーからユーザーを削除

void RoleManager.revokeRole(Role parent, Principal principal)

void Group.deleteMember(User user, ModifyOptions opts)

特定のロールの直接または間接のすべての所有者の取得

SearchResponse Role.getOwners(SearchFilter filter, boolean direct)

SearchResponse Role.getOwners(SearchFilter filter)

ResultSet<User> Group.getOwners(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ユーザーを所有者としてロールに追加

void Role.addOwner(Principal principal)

void Group.addOwner(User user, ModifyOptions opts)

ロールの所有者からユーザーを削除

void Role.removeOwner(Principal principal)

void Group.deleteOwner(User user, ModifyOptions opts)

ロールの直接または間接のすべての管理者の取得

SearchResponse Role.getManagers(SearchFilter filter, boolean direct)

SearchResponse Role.getManagers(SearchFilter filter)

サポートされていません。

ユーザーをロールの管理者として追加します。

void Role.addManager(Principal principal)

サポートされていません。

ロールの管理者からユーザーを削除します。

void Role.removeManager(Principal principal)

サポートされていません。

ロールのプロパティの取得

Property Role.getProperty(String propName)

注意: ユーザー・ロールAPIはキャッシュからこれらの属性値をフェッチします。キャッシュにない場合、リポジトリからフェッチします。

Attribute Group.getAttribute(String attrName)

ロール・タイプの確認

Role.isApplicationRole

Role.isEnterpriseRole

Role.isSeeded

サポートされていません。

指定された検索基準に対するロールの検索

SearchResponse IdentityStore.searchRoles(int scope, SearchParameters params)

ResultSet<Group> GroupManager.searchGroups(SearchFilter filter, SearchOptions opts)

名前/一意の名前/guidによるロールの検索

Role IdentityStore.searchRole(int searchType, String value)

Group searchGroup(String id, ReadOptions opts)

Group searchGroup(String attrName, String attrVal, ReadOptions opts)

指定されたフィルタに対するユーザーとロールの検索

SearchResponse IdentityStore.search(SearchParameters params)

次の異なるメソッドを使用できます。

UserManager.searchUsers

GroupManager.searchGroups

ユーザー/グループに割り当てられたすべてのロールを取得します。

SearchResponse getGrantedRoles(Principal principal, boolean direct)

ResultSet<Group> User.getMemberOfGroups(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ResultSet<Group> Group.getMemberOfGroups(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ユーザー/グループが所有しているすべてのロールを取得します。

SearchResponse getOwnedRoles(Principal principal, boolean direct)

ResultSet<Group> User.getOwnedGroups(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ResultSet<Group> Group.getOwnedGroups(int nLevels, SearchFilter targetFilter, SearchOptions opts)

ユーザー/グループが管理しているすべてのロールを取得します。

SearchResponse getManagedRoles(Principal principal, boolean direct)

サポートされていません。