Build ant script to build jars and zip files for scheduled Task.

In Oracle Identity Management for our implementation purpose, we write many schedules. But many times we want the only custom set of classes to register in the system, for that we always need to go and do changes in metadata plugin XML files and then registered the schedulers.

Here a small ant script that we can use to compile a set of custom classes, build Jar, and zip file of those custom classes which we need to register in our environment.


Please find below the folder structure.




  src = Contains all scheduled tasks java classes.
  build = All compile classes will be generated in this folder.
  lib = Jar file will be stored here.
  META-INF your custom scheduled task XML

Steps to be done before running the script.
  1. You need to create a tmp folder.
  2. Prepare your custom set of metadata and plugin XML like scheduledTask_Set1.xml and plugin_Set1.xml and put those XMLs in the tmp folder.
  3. The script will runtime pick that XMLs according to target which we'll be running.

build.xml

<project name="MyCustomScheduledTasks" basedir="." default="main">


 <property name="src.dir"     value="src"/>

 <property name="build.dir"   value="build"/>
 <property name="classes.dir" value="${build.dir}/classes"/>
 <property name="lib.dir" value="lib"/>
 <property name="meta-inf.dir" value="META-INF"/>
 <property name="tmp.dir" value="tmp"/>
 <property name="set1.dir" value="set1"/>
 <property name="set2.dir" value="set2"/>
<property file ="build.properties"/>

 <target name="clean">

  <delete dir="${build.dir}"/>
  <delete dir="${meta-inf.dir}"/>
  <delete dir="${lib.dir}"/>
  <delete file="plugin.xml"/>
 </target>

 <target name="compile">

  <mkdir dir="${classes.dir}"/>
  <javac srcdir="${src.dir}" destdir="${classes.dir}"/>
 </target>

 <target name="set1" depends="compile">

  <mkdir dir="${lib.dir}" />
  <mkdir dir="${meta-inf.dir}" />
  <mkdir dir="${set1.dir}" />
  <jar destfile="${lib.dir}/${ant.project.name}.jar" basedir="${classes.dir}" incluedes="${set1.classes}">
  </jar>
  <copy file="${tmp.dir}/plugin_Set1.xml" tofile="plugin.xml" />
  <copy file="${tmp.dir}/ScheduledTasks_Set1.xml" tofile="${meta-inf.dir}/ScheduledTasks.xml" />
  <zip destfile="${set1.dir}/${ant.project.name}.zip" basedir=".">
   <include name="plugin.xml" />
   <include name="${meta-inf.dir}/ScheduledTasks.xml" />
   <include name="${lib.dir}/${ant.project.name}.jar" />
  </zip>
 </target>

 <target name="set2" depends="compile">

  <mkdir dir="${lib.dir}" />
  <mkdir dir="${meta-inf.dir}" />
  <mkdir dir="${set2.dir}" />
  <jar destfile="${lib.dir}/${ant.project.name}.jar" basedir="${classes.dir}" includes="${set2.classes}" >
  </jar>
  <copy file="${tmp.dir}/plugin_Set2.xml" tofile="plugin.xml"/>
  <copy file="${tmp.dir}/ScheduledTasks_Set2.xml" tofile="${meta-inf.dir}/ScheduledTasks.xml"/>
  <zip destfile="${set1.dir}/${ant.project.name}.zip" basedir=".">
   <include  name="plugin.xml"/>
   <include name="${meta-inf.dir}/ScheduledTasks.xml"/>
   <include name="${lib.dir}/${ant.project.name}.jar"/>
  </zip>
 </target>

 <target name="main" depends="clean"/>


</project>

In build.properties file you have to mention the comma-separated set of custom classes.

build.properties looks like this,

set1.classes com/myTask/DisableUser.class,com/myTask/CreateUser.class

set2.classes com/myTask/EnableUser.class,com/myTask/UpdateUserParameters.class

I am still working on this script. If any suggestions then those are always welcome.


Happy Coding. 



How to add new Tab in OIM PS3 and How to hide it from end user

  1. Login to identity console.
  2. Create & activate sandbox in Identity console.
  3. Go to Manage->users. List of users will be displayed
  4. Click on user login of any user and you will be able to see details of that particular user
  5. You will see various tabs on that page like 'Attributes' 'Roles' 'Entitlements' 'Accounts' 'Organizations' 'Admin Roles'
  6. Now we need to add one new tab named “Personal Information” after “Admin Roles” tab
  7. Click on customize button
  8. Click on structure present on the leftmost upper corner
  9. Click on the area where you want to add a new tab
  10. A prompt window will open then click on Edit.
  11. On the right side of the window, you will see the below vertical window
  12. In above vertical window we can see the parent tab i.e. PanelTabbedAbove
  13. Click on it and then click on the edit button which is the leftmost second option on customize page.
  14. Below window will open.
  15. Click on Add Tab button
  16. New Tab gets created. Change the name of it.
  17.       Enter the name as 'Personal Information'
  18. Click on Apply
  19.       As we want this tab at last position then use Reorder the tabs field. with the help of down arrows, we can adjust the position of the newly created tab.
  20.       Then click on OK.
  21.       You will see that the new tab is added on the page after the “Admin Roles” tab

  1.    To add information or attributes under  this new tab do the following steps
  • Click on ‘Personal Information’ in customize window
  • Click on ‘+’ i.e. add the symbol. Below window will appear

  • Open Web components tab which is the last option in the list

  • Select and add Panel Group Layout option from the list
  • Then click on this added layout tab and click on edit

  • Select the layout as vertical. 
  • Apply and OK
  • Click on the layout that we have rightly created and click on add symbol
  • Go to web components and add ‘show header details
  •  Change the name of the header by clicking on edit symbol
  • Give the name ‘Personal Information’ instead of ‘Header
  • Apply and OK
  • Now add ‘PanelFormLayout’ same manner as we added ‘ShowDetailHeader
  • Edit PanelFormLayout as below
  • Apply and OK
  • For adding attributes under this tab click on PanelFormLayout and click on add
  • Add Panel label with the message from Web Components
  • Change the name of that label. Here label is the name of an attribute that we want to add under the tab 'Personal Information'
  • Apply and OK
  • Click on PanelLabelAndMessage tab and click on add
  • Open Data Component-Manage Users
  • Open UserVO1 tab
  • Select the required attribute from the list
  •  Add that attribute
     
  • Here I am selecting 'City' attribute
  • Select ADF OutputText from list
                           
                             
  •  We can add any number of attributes that we want to add under 'Personal Information' tab i.e. First Name, Common Name, Email, etc. by following above-mentioned procedure.

2.  To hide Tab from End User do the following steps

  • Click on the ‘Personal Information’ tab
  • Click on edit and scroll down
  • Click on show component
  • Click on Expression Builder
  • Remove true and paste below EL(Expression Language)
  • #{oimcontext.currentUser.roles['SYSTEM ADMINISTRATORS'] != null}
  • Click on Test
  • After successful test click on ok
  • Click on apply and OK
  • Close customization window
  • Publish sandbox
  • 'Personal Information' tab only visible to Administrator. It will be invisible for end users.




Login fails in OIM

Login fails in OIM and if sysadmin user is locked 

  1. Shut down all servers.
  2. Go to /home/oracle/Oracle/Middleware/user_projects/domains/base_domain/servers
    Delete all  tmp, logs, data/store files from Adminserver, oim_server1, soa_server1
  3. Check the boot.properties file present in/home/oracle/Oracle/Middleware/user_projects/domains/base_domain/servers/security 
    folder of all servers.
    replace username with weblogic and password with your server
  4. Now login to SQL and execute follwoing command.
    update DEV_OIM.usr set usr_locked=0, usr_login_attempts_ctr=0 where usr_login='XELSYSADM';
  5. After doing all steps start all servers.

Java Regex

In this post, you will learn Java REGX and its example.

regular expression defines a pattern for a String. Regular Expressions can be used to search, edit or manipulate text. Regular expressions are not language specific but they differ slightly for each language. 

Here are some rules to be followed while creating a regular expression.







E.g.

Regular expression for validating the email id is:

^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$


^ // start of the line
[_A-Za-z0-9-\\+]+ //   must start with string in the bracket [ ], must contains one or more (+)
( //      start of group #1
  \\.[_A-Za-z0-9-]+ //     follow by a dot "." and string in the bracket [ ], must contains one or more (+)
)* //     end of group #1, this group is optional (*)
  @ //     must contains a "@" symbol
   [A-Za-z0-9-]+              //     follow by string in the bracket [ ], must contains one or more (+)
    ( //      start of group #2 - first level TLD checking
     \\.[A-Za-z0-9]+   //      follow by a dot "." and string in the bracket [ ], must contains one or more (+)
    )* //       end of group #2, this group is optional (*)
    ( //       start of group #3 - second level TLD checking
     \\.[A-Za-z]{2,}           //       follow by a dot "." and string in the bracket [ ], with minimum length                                                    of 2
    ) //       end of group #3
$         //       end of the line


Exporting and Importing Metadata files in Oracle Identity Manager


1.      Go to $OIM_ORACLE_HOME/server/bin.
(Set $OIM_ORACLE_HOME= /home/oracle/Oracle/Middleware/Oracle_IDM1)

2.      Edit the weblogic.properties file.

3.      To Export file change the following fields.

wls_servername=oim_server1
application_name=OIMMetadata
metadata_from_loc=@From_location
metadata_to_loc=<path where to export>
metadata_files=<relative path to file>

4.      Then run ./weblogicExportMetadata.sh
Username= weblogic
Password= (your password)
URL: t3://Host:port (e.g. t3://host:14000)


5.      Then again to import change following fields in weblogic.properties.

wls_servername=oim_server1
application_name=OIMMetadata
metadata_from_loc=”path from where to import”
metadata_to_loc=@To_location

metadata_files=<file name>

For importing you have to give the path from where you want to import the file