Sunday, February 12, 2012

OIM 11G API Usage

//Set the following vm arguments if you are executing in eclipse:
/*
-Djava.naming.provider.url=t3://hostname:port (for weblogic)
or
-Djava.naming.provider.url=jnp://hostname:port (for jboss)

Djava.security.auth.login.config=config\authwl.conf (for weblogic)
or
Djava.security.auth.login.config=config\auth.conf (for jboss)

-Djava.security.policy=config\xl.policy*/
Initializing the oimClient:

Hashtable<String, String> env = new Hashtable<String, String>();
            env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, providerURL);
            env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, OIMClient.WLS_CONTEXT_FACTORY);

            oimClient = new OIMClient(env);
            oimClient.login(userName, password.toCharArray());

//Getting the required service api's
usrMgrService = oimClient.getService(UserManager.class);
            notificationService = oimClient.getService(NotificationService.class);       
            roleMgrService = oimClient.getService(RoleManager.class);
            orgMgrService = oimClient.getService(OrganizationManager.class);

//Creating a user and user management
UserManager usrmanager=sample.getUsrMgrService();
            HashMap<String,Object> createUserMap=new HashMap<String, Object>();
            String userLogin="Testvish";
            createUserMap.put(UserManagerConstants.AttributeName.FIRSTNAME.getId(), "Testvish");
            createUserMap.put(UserManagerConstants.AttributeName.LASTNAME.getId(), "Testvish");
            createUserMap.put(UserManagerConstants.AttributeName.USER_LOGIN.getId(), "Testvish");
            createUserMap.put(UserManagerConstants.AttributeName.USERTYPE.getId(), "End-User");
            createUserMap.put(UserManagerConstants.AttributeName.EMPTYPE.getId(), "EMP");
            createUserMap.put(UserManagerConstants.AttributeName.PASSWORD.getId(), "vish@777");
            createUserMap.put(UserManagerConstants.AttributeName.DISPLAYNAME.getId(), "Testvish");
            createUserMap.put(UserManagerConstants.AttributeName.EMAIL.getId(), "Testvish@abc.com");
            createUserMap.put(UserManagerConstants.AttributeName.PHONE_NUMBER.getId(), "765454544");
            createUserMap.put("act_key", new Long("1"));
            User user=new User(userLogin,createUserMap);
            usrmanager.create(user);

//User Update
createUserMap.put("PHONE_NUMBER", "123456789");
            usrmanager.modify(new User(userLogin,createUserMap));

//Organization Create
String orgName="sampleOrg1";
            HashMap<String,Object> createOrgMap=new HashMap<String, Object>();
            createOrgMap.put("Organization Name", orgName);
            createOrgMap.put("Organization Customer Type", "Branch");
            Organization orgCreate = new Organization(orgName,createOrgMap);
            OrganizationManager orgManager=sample.getOrgMgrService();
            orgManager.create(orgCreate);

No comments:

Post a Comment