Sample Code:
import Thor.API.Operations.tcLookupOperationsIntf;
import java.util.HashMap;
import java.util.Hashtable;
import javax.security.auth.login.LoginException;
import oracle.iam.identity.exception.UserAlreadyExistsException;
import oracle.iam.identity.exception.UserCreateException;
import oracle.iam.identity.exception.ValidationFailedException;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.platform.OIMClient;
public class OIMTestClient
{
public static void main(String arg[])
{
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://pokuri.demo.com:14000");
System.setProperty("java.security.auth.login.config", "/IdentityManagement/Blog/OIM/JDeveloperConfigforOIM/designconsole/config/authwl.conf");
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oracle.iam.platform.OIMClient oimClient = new oracle.iam.platform.OIMClient(env);
try
{
oimClient.login("xelsysadm", "Abcd1234".toCharArray());
System.out.print("Successfully Connected with OIM ");
System.out.println("Before Create User --");
HashMap<String, Object> userAttributeValueMap = new HashMap<String, Object>();
userAttributeValueMap.put("act_key", new Long(1));
userAttributeValueMap.put("User Login", "sam");
userAttributeValueMap.put("First Name", "sam");
userAttributeValueMap.put("Last Name", "peter");
userAttributeValueMap.put("Email", "speter@abc.com");
userAttributeValueMap.put("usr_password", "Password123");
userAttributeValueMap.put("Role", "OTHER");
User user = new User("sam", userAttributeValueMap);
UserManager userManager = oimClient.getService(UserManager.class);
try {
userManager.create(user);
System.out.println("\nUser Created");
} catch (ValidationFailedException e) {
e.printStackTrace();
} catch (UserAlreadyExistsException e) {
e.printStackTrace();
} catch (UserCreateException e) {
e.printStackTrace();
}
System.out.println("User Created successfully");
}
catch (Exception e)
{
System.out.print(" Exception"+ e);
}
}
}
import Thor.API.Operations.tcLookupOperationsIntf;
import java.util.HashMap;
import java.util.Hashtable;
import javax.security.auth.login.LoginException;
import oracle.iam.identity.exception.UserAlreadyExistsException;
import oracle.iam.identity.exception.UserCreateException;
import oracle.iam.identity.exception.ValidationFailedException;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.platform.OIMClient;
public class OIMTestClient
{
public static void main(String arg[])
{
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://pokuri.demo.com:14000");
System.setProperty("java.security.auth.login.config", "/IdentityManagement/Blog/OIM/JDeveloperConfigforOIM/designconsole/config/authwl.conf");
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oracle.iam.platform.OIMClient oimClient = new oracle.iam.platform.OIMClient(env);
try
{
oimClient.login("xelsysadm", "Abcd1234".toCharArray());
System.out.print("Successfully Connected with OIM ");
System.out.println("Before Create User --");
HashMap<String, Object> userAttributeValueMap = new HashMap<String, Object>();
userAttributeValueMap.put("act_key", new Long(1));
userAttributeValueMap.put("User Login", "sam");
userAttributeValueMap.put("First Name", "sam");
userAttributeValueMap.put("Last Name", "peter");
userAttributeValueMap.put("Email", "speter@abc.com");
userAttributeValueMap.put("usr_password", "Password123");
userAttributeValueMap.put("Role", "OTHER");
User user = new User("sam", userAttributeValueMap);
UserManager userManager = oimClient.getService(UserManager.class);
try {
userManager.create(user);
System.out.println("\nUser Created");
} catch (ValidationFailedException e) {
e.printStackTrace();
} catch (UserAlreadyExistsException e) {
e.printStackTrace();
} catch (UserCreateException e) {
e.printStackTrace();
}
System.out.println("User Created successfully");
}
catch (Exception e)
{
System.out.print(" Exception"+ e);
}
}
}