OIM API To Get Indirect Role Members


  1. package com.oimacademy.role;
  2. import static oracle.iam.identity.utils.Constants.FIRSTNAME;
  3. import static oracle.iam.identity.utils.Constants.SEARCH_ENDROW;
  4. import static oracle.iam.identity.utils.Constants.SEARCH_SORTEDBY;
  5. import static oracle.iam.identity.utils.Constants.SEARCH_SORTORDER;
  6. import static oracle.iam.identity.utils.Constants.SEARCH_STARTROW;
  7. import java.util.HashMap;
  8. import java.util.HashSet;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Set;
  12. import oracle.iam.identity.exception.RoleMemberException;
  13. import oracle.iam.identity.rolemgmt.api.RoleManager;
  14. import oracle.iam.identity.usermgmt.vo.User;
  15. import oracle.iam.platform.authz.exception.AccessDeniedException;
  16. import oracle.iam.platform.entitymgr.spi.entity.Searchable.SortOrder;
  17. import oracle.iam.platform.entitymgr.vo.SearchCriteria;
  18. import com.oimacademy.connection.Platform;
  19. public class GetRoleIndirectMembers {
  20.    protected RoleManager m_roleManager = Platform.getService(RoleManager.class);
  21.  public static void main(String[] args) throws Exception {
  22.   new GetRoleIndirectMembers().getRoleIndirectMembersWithPagenation();
  23.  }
  24. public void getRoleIndirectMembersWithPagenation() throws Exception {  
  25.     String roleKey = "61";   
  26.     //actual test case.
  27.     SearchCriteria criteria = getSearchCriteriaAllUsers();
  28.     //test getting all members by passing null to control and retrieve
  29.     Set<String> retAttr = new HashSet<String>();
  30.     Map<String, Object> control = new HashMap<String, Object>();
  31.     control.put(SEARCH_SORTORDER, SortOrder.ASCENDING);
  32.     control.put(SEARCH_SORTEDBY, FIRSTNAME);
  33.     control.put(SEARCH_STARTROW, 0);
  34.     control.put(SEARCH_ENDROW, 30);    
  35.     retAttr.add("rownum");
  36.     retAttr.add("First Name");
  37.     retAttr.add("User Login");    
  38.     List<User> listOfIndirectMembers = null; 
  39.             try {
  40.                 listOfIndirectMembers =
  41.                     m_roleManager.getRoleMembers(roleKey,criteria,retAttr,control, false);
  42.             } catch (RoleMemberException e) {                
  43.             } catch (AccessDeniedException e) {               
  44.             }  
  45.             System.out.println(listOfIndirectMembers);}
  46. protected SearchCriteria getSearchCriteriaAllUsers() {   
  47.    SearchCriteria criteria1 = new SearchCriteria("Display Name", "ABC", SearchCriteria.Operator.OR);
  48.     return new SearchCriteria(FIRSTNAME, "ABC", SearchCriteria.Operator.CONTAINS);
  49. }
  50. }

No comments:

Post a Comment