Wednesday, April 3, 2019

Custom plugin extending UserNameGenerationPolicy for OIM

Oracle provides yet another plug-in point to generate userName for identities as per the Organization standards.
The plug-in point for this is  : oracle.iam.identity.usermgmt.api.UserNameGenerationPolicy

By default the Common Name Generation Policy used in OIM is "oracle.iam.identity.usermgmt.impl.plugins.DefaultComboPolicy".
If we want to use our own policy for example creating the user ID from the user's first name, and last naem, appending it with a random number so that it's unique, here is how it can be achieved.

The steps would be to  :

1. Write our own logic which will extend the "UserNameGenerationPolicy" , and return the userName , after processing the inputs from the orchestration data.

The plugin Class :




2. Jar the above file and keep it in the plug-in zip file under lib/ folder.
3. Configure the plugin.xml for registering the plug-in using ant

The plugin.xml :



4. Keep the plugin-name.zip file under OIM_HOME/server/plugins folder.
5. If the auto-plugin-registration property is set up, it would be automatically registered (you can read about it here - plugin auto-registration )  , if not  :

  •    Navigate to OIM_HOME/server/pluggin_utiltiy
  •    run ant -f pluginregistration.xml register
  •    provide user name, password, and full location of the zip file (OIM_HOME/server/plugins/UserNamePolicy.zip)
  •    check if the plug-in properly registered from DB :
  •    select * from plugins where ID like ('iam.demo.pluginpoints.UserNamePolicy')

6. Change in the system configuration property "Default policy for username generation"
  • Log-into http://oim_hostname:port/sysadmin console.
  • Open "System Configuration"
  • Search for the property 'Default policy for username generation' .
  • This property name can be different in different set up, but notice the keyword will be same as  : "XL.DefaultUserNamePolicyImpl"
  • Change the value from 'oracle.iam.identity.usermgmt.impl.plugins.DefaultComboPolicy' to our full class name 'iam.demo.pluginpoints.UserNamePolicy'.
Do a purge cache and take an admin+managed server restart of your environmet :
  • Navigate to $OIM_HOME/bin directory, locate PurgeCache.sh file
  • run  ./PurgeCache.sh ALL
  • Provide system admin login : XELSYSADM
  • Provide system admin password : ******
  • Provide managed servers URLs : t3://oim_hostname:port (run once for each managed server in case of cluster set up)
Now, try to create an user to see the username getting generated.

As always, thanks for reading !