To compile the adapter, the following steps must be executed:
1. Create a work folder, let's say c:\work and inside create the following structure:
c:\work\com\oracle\events\
2. Create a java file in c:\work\com\oracle\events\ named tcGenerateRandomPassword .java
3. Copy the source code provided in this document to the java file.
Here is the code,
package com.oracle.events;
import java.util.Random;
import com.thortech.xl.dataobj.tcDataSet;
import com.thortech.xl.util.logging.LoggerMessages;
import com.thortech.xl.util.logging.LoggerModules;
import com.thortech.util.logging.Logger;
public class tcGenerateRandomPassword extends com.thortech.xl.client.events.tcBaseEvent {
private static Logger logger = Logger.getLogger(LoggerModules.XL_JAVA_CLIENT);
public static int DEFAULT_PASSWORD_LENGTH=8;
public static char[] Special_Character = {'!','@','#','$','%','^','&','*','(',')' };
public tcGenerateRandomPassword() {
setEventName("Generating a random password for a User.");
}
protected void implementation() throws Exception {
if (getDataObject().isDeleting()) {
return;
}
if (getDataObject().isUpdating()) {
return;
}
String randomPassword = getRandomPassword();
getDataObject().setString("usr_password",randomPassword);
return;
}
public static char getSpecialCharacter(){
Random rand = new Random();
int randInt = rand.nextInt(10);
return Special_Character[randInt];
}
public static String getRandomPassword(int n) {
if(n <=8 ){ n=DEFAULT_PASSWORD_LENGTH; } char[] pw = new char[n]; int c = 'A'; int r1 = 0; int i=0; String tempString = new String(); while(i< n){ r1 = (int)(Math.random() * 4); l1: switch(r1) { case 0: c = '0' + (int)(Math.random() * 10); break l1; case 1: c = 'a' + (int)(Math.random() * 26); break l1; case 2: c = 'A' + (int)(Math.random() * 26); break l1; case 3: c = getSpecialCharacter(); break; } char c1 = (char)c; boolean isExisting = false; l2: for(int j=0; j < i; j++){ if(c1 == pw[j]){ isExisting = true; break l2; } } if(!isExisting){ pw[i] = (char)c; i++; } } return new String(pw); } } 4. In c:\work create a file named compile.bat with the following contents: set OIM_LIBS=D:\oracle\oimserver\xellerate\lib set CLASSPATH=%OIM_LIBS%\xlLogger.jar;%OIM_LIBS%\xlDataObjects.jar;%OIM_LIBS%\xlVO.jar;%OIM_LIBS%\xlUtils.jar javac -classpath %CLASSPATH% com\oracle\events\tcGenerateRandomPassword .java jar cf tcGenerateRandomPassword.jar * 5. Run compile.bat and check for any compilation errors. 6. At this point a JAR file named loginuseridgenern.jar will be created in c:\work folder. Running the Code: To add the new created event handler to OIM server, perform the following steps: 1. Copy the file tcGenerateRandomPassword.jar from c:\work to OIM_HOME\xellerate\EventHandlers 2. Open Design Console and navigate to: Development Tools -> Business Rule Definition -> Event Handler Manager
***Follow the remaining steps as in Oracle identity manager customized userid for strong random password generation like
OUTPUT :fb(1W6O72dtq
If any questions,please post it