package com.oim.utilities;
import java.util.HashMap;
import oracle.iam.identity.rolemgmt.api.RoleManager;
import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
import oracle.iam.identity.rolemgmt.vo.Role;
import oracle.iam.platform.OIMClient;
public class RoleManagement
{
static RoleManager roleManager=null;
static OIMClient client=null;
@SuppressWarnings("null")
public static void createRole(String roleName){
System.out.println("RoleManagement :: createRole :: role name is "+roleName);
try
{
if (roleName!=null)
{
HashMap<String, Object> mapAttrs = new HashMap<String, Object>();;
mapAttrs.put(RoleManagerConstants.ROLE_NAME, roleName);
mapAttrs.put(RoleManagerConstants.ROLE_DISPLAY_NAME,roleName);
mapAttrs.put(RoleManagerConstants.ROLE_DESCRIPTION, roleName);
Role role = new Role(mapAttrs);
// Initialising the OIM Connection
client=ClientOIM.initialise();
System.out.println("RoleManagement :: createRole :: OIMClient "+client);
roleManager=client.getService(RoleManager.class);
System.out.println("RoleManagement :: createRole :: role manager is "+roleManager);
if (roleManager!=null)
{
roleManager.create(role);
}
}
}
catch (Exception e)
{
System.out.println("RoleManagement :: createRole :: Exception caught is "+e.getMessage());
e.printStackTrace();
}
}
public static void main(String[] args)
{
createRole("Employee");
}
}
import java.util.HashMap;
import oracle.iam.identity.rolemgmt.api.RoleManager;
import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
import oracle.iam.identity.rolemgmt.vo.Role;
import oracle.iam.platform.OIMClient;
public class RoleManagement
{
static RoleManager roleManager=null;
static OIMClient client=null;
@SuppressWarnings("null")
public static void createRole(String roleName){
System.out.println("RoleManagement :: createRole :: role name is "+roleName);
try
{
if (roleName!=null)
{
HashMap<String, Object> mapAttrs = new HashMap<String, Object>();;
mapAttrs.put(RoleManagerConstants.ROLE_NAME, roleName);
mapAttrs.put(RoleManagerConstants.ROLE_DISPLAY_NAME,roleName);
mapAttrs.put(RoleManagerConstants.ROLE_DESCRIPTION, roleName);
Role role = new Role(mapAttrs);
// Initialising the OIM Connection
client=ClientOIM.initialise();
System.out.println("RoleManagement :: createRole :: OIMClient "+client);
roleManager=client.getService(RoleManager.class);
System.out.println("RoleManagement :: createRole :: role manager is "+roleManager);
if (roleManager!=null)
{
roleManager.create(role);
}
}
}
catch (Exception e)
{
System.out.println("RoleManagement :: createRole :: Exception caught is "+e.getMessage());
e.printStackTrace();
}
}
public static void main(String[] args)
{
createRole("Employee");
}
}
Hi Thanks for the code snippet. I am able to create role using the code but i want to set owner and certifier for the role with the help of the code. I am able to fine the constant for certifier in RoleManagerConstants
ReplyDelete