Tuesday, December 1, 2015

weblogic.socket.MaxMessageSizeExceededException

when  we execute some java code (OIM api) form Eclipse, we may face the below issue :
Caused by: weblogic.socket.MaxMessageSizeExceededException: Incoming message of size: '10000080' bytes exceeds the configured maximum of: '10000000' bytes for protocol: 't3'

to resolve the issue we can just add a system property in the java code

System.setProperty("weblogic.MaxMessageSize", "300000000"); and you are done :)

sample code:

public OIMClient envContext(String oimUserName, String oimPassword, String oimURL ){
/*String oimUserName = "xelsysadm";   
String oimPassword = "xxxxxxxxxxxxxxxxxxx";
String oimURL = "t3://xxxxxxxxxxxxxxxxxxxxxxxt:14000"; */

String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
OIMClient oimClient= null;
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, oimInitialContextFactory);
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,oimURL);
System.setProperty("java.security.auth.login.config", "./config/authwl.conf");
System.setProperty("java.security.policy", "./config/xl.policy"); 
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
System.setProperty("weblogic.Name", "oim_server1");
System.setProperty("weblogic.MaxMessageSize", "300000000");
System.setProperty("weblogic.security.SSL.trustedCAKeyStore", "./config/xxxxxxx.jks");
oimClient = new OIMClient(env);
try {
oimClient.login(oimUserName, oimPassword.toCharArray());
System.out.println("Successfully Connected with OIM ");
} catch (LoginException e) {
System.out.println("Login Exception"+ e);
}
return oimClient;
}

Retry Evaluate user policies task

Some time we need to retry Evaluate user policies task. But  some time when we  run the Evaluate user policies task again, the task seems to ignore users who failed the previous run. To solve this issue we need to execute the below query to reset the POLICY_EVAL_NEEDED flag in DB.

query:
UPDATE USER_PROVISIONING_ATTRS SET POLICY_EVAL_IN_PROGRESS = 0, POLICY_EVAL_NEEDED = 1, UPDATE_DATE = SYSDATE where USR_KEY IN( all affected  user Ids)

Sunday, July 19, 2015

OIM API- Update Schedule task attribute

Some time we need to update schedule task attribute like time stump; so that when the schedule task execute next time it can start executing after that time stump. we can use the below code to achieve that.

private void updateSchedulerTimeStamp(Date curTime,String scheduledTaskName)
{
try
{
String currentTime = curTime.toString();
SimpleDateFormat lastExecutionTimeParser1 = new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy");
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
curTime = lastExecutionTimeParser1.parse(currentTime);
String curDate=sdf.format(curTime);
HashMap <String,String> hashmap = new HashMap<String,String>();
hashmap.put("Task Scheduler.Name", scheduledTaskName);
tcSchedulerOperationsIntf tcSchOper = (tcSchedulerOperationsIntf) Platform.getService(tcSchedulerOperationsIntf.class);
tcResultSet tcresultset = tcSchOper.findScheduleTasks(hashmap);


if(tcresultset != null && tcresultset.getRowCount() > 0)
{
tcresultset.goToRow(0);
long schedularKey = tcresultset.getLongValue("Task Scheduler.Key");
String schedularKeyStr = String.valueOf(schedularKey);
hashmap.clear();
hashmap.put("Task Scheduler.Key", schedularKeyStr);
hashmap.put("Task Scheduler.Task Attributes.Name", "Last Execution Time");
tcResultSet tcresultset1 = tcSchOper.findScheduleTaskAttributes(hashmap);
if(tcresultset1 != null && tcresultset1.getRowCount()>0){
tcresultset1.goToRow(0);
long scheduleTaskAtrKey = tcresultset1.getLongValue("Task Scheduler.Task Attributes.Key");
hashmap.put("Task Scheduler.Task Attributes.Value", curDate);
tcSchOper.updateScheduleTaskAttribute(schedularKey,scheduleTaskAtrKey, hashmap);  

}
else{
logger.finest("CLASS_NAME - Nirupam - in updateSchedulerTimeStamp Method :Resultset is null: ");
}

}
}
catch(Exception e)
{
logger.finest("CLASS_NAME - Nirupam - in updateSchedulerTimeStamp Method :Exception:"+e);
}

}

OIM API read IT Resource Parameter

/**
* returns a HashMap with   IT resource field details
* @param itResourceName
* @return
*/
public HashMap<String, String> getITResourceAttributeInMap(String itResourceName)  {

HashMap<String, String>  adITResourcefileds = new HashMap<String, String> ();

try{
tcITResourceInstanceOperationsIntf tcITResourceIntf = Platform.getService(tcITResourceInstanceOperationsIntf.class);
HashMap<String, String>  searchcriteria = new HashMap<String, String>();
searchcriteria.put("IT Resources.Name", itResourceName);
tcResultSet resultSet = tcITResourceIntf.findITResourceInstances(searchcriteria);
resultSet = tcITResourceIntf.getITResourceInstanceParameters(resultSet.getLongValue("IT Resources.Key"));

for (int i = 0; i < resultSet.getRowCount(); i++) {
resultSet.goToRow(i);
String name = resultSet.getStringValue("IT Resources Type Parameter.Name");

String value= resultSet.getStringValue("IT Resources Type Parameter Value.Value");
adITResourcefileds.put(name,value);
}
}catch (Exception ae) {
ae.printStackTrace();
}
return adITResourcefileds;

}

Monday, March 30, 2015

Validation Handler- getting error message from properties file

The way to read it from properties file is shown below.

1.     We need to create the custom  properties file  and upload it in MDS using UploadResourceBundles.sh and UploadResourceBundles.bat utility which are available in the OIM_HOME/server/bin/ directory as custom resource.

Enter OIM admin username :]ADMIN_login
[Enter the admin password :]admonpassword
[Enter serverURL :[ t3://localhost:14000 ]]t3://oimhost:14000
[Enter context Factory :[ weblogic.jndi.WLInitialContextFactory weblogic.jndi.WLInitialContextFactory
Enter the resource bundle type
 1.Custom Resource
 2.Connector Resource
 1
Enter the path/location of resource bundle file :
/prop/<custom_property_name>.properties
Do u want to load more resource bundles [y/n] :n


2.      In the validation handler do the following:

         PlatformService pltSrv = Platform.getService(PlatformService.class);
         Properties props = pltSrv.LoadResourceBundleFromDB("customResources", 
                                                                                                             "<custom_property_name>.properties");
                                                    String errorMsg = props.getProperty("ERRCODE");