Tuesday, 23 May 2017

Calling Unix command from Java

Here is the code sample for calling Unix command from java. The below sample can only run the Unix command in the same system.


public class LinuxInJava {
    public static void main(String args[]) {
        String s;
        Process p;
        try {
            p = Runtime.getRuntime().exec("ls -aF");
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            while ((s = br.readLine()) != null){
                System.out.println("line: " + s);
   
    }
            p.waitFor();
            System.out.println ("exit: " + p.exitValue());
            p.destroy();
        } catch (Exception e) {}
    }
}




Friday, 19 May 2017

OIM 11gR2 PS3 Workflow policy page showing blank

In OIM 11gR2 PS3, one should not update the default applications (Self-Service and Sysadmin) from Weblogic deployments.



Sometime during implementation of OIM UI Customizations, peoples are updating the oracle.iam.ui.custom. In PS3 you can find that while updating oracle.iam.ui.custom, automatically below depended applications got updated.



If by mistake oracle.iam.console.identity.self-service.ear and oracle.iam.console.identity.sysadmin.ear got updated then you may find the workflow policy in sysadmin console showing blank. See the below image where opening the Workflows -> Approvals showing a white page.






Reason:
In OIM PS3, if some how oracle.iam.console.identity.self-service.ear and oracle.iam.console.identity.sysadmin.ear got updated then the OPSS policy gets overwritten.


Solution:
To resolve this issue, we need to Re-Seed the policy again from self service and sysadmin.
There are 3 policy files you need to re-seed.


1. Copy 'jazn-data.xml' (from OIM.ear) to a different directory.
2. Copy 'jazn-data.xml' (found in oracle.iam.console.identity.self-service.ear) to a different directory.
3. Copy 'jazn-data-sysadmin.xml' (found in oracle.iam.console.identity.self-service.ear) to a different directory.


4. Go to [DOMAIN_HOME]/config/fmwconfig/ take a backup of the file 'jps-config-jse.xml' in the same folder


cp jps-config-jse.xml jps-config-jse_backup.xml


5. Open the backup file 'jps-config-jse_backup.xml' and add the below 2 jps contexts just before the "</jpsContexts>" tag.


<jpsContext name="mydst">
<serviceInstanceRef ref="policystore.db"/>
</jpsContext>

<jpsContext name="mysrc">
<serviceInstanceRef ref="mysource.policystore.xml"/>
</jpsContext>



6. Open the 'jps-config-jse_backup.xml' file and add the below 'serviceInstance' just before the "</serviceInstances>" tag.


<serviceInstance name="mysource.policystore.xml"
provider="policystore.xml.provider" location="<FILE PATH>">
<description>My source</description>
</serviceInstance>



Give an absolute path of jazn-dataXXXX.xml in <FILE PATH> as per the step 1. You need to change the <FILE PATH> 3 times to seed 3 different policies.


7. Goto the location "[MWHOME]/oracle_common/common/bin/" and execute "sh wlst.sh" script


8. Execute the below command to import policies from Jazn-dataxxx.xml to the OPSS store.


Syntax
migrateSecurityStore(type='appPolicies', configFile='/opt/app/oracle/Middleware/user_projects/domains/<oim_domain>/config/fmwconfig/jps-config-jse_backup.xml',
src='mysrc', dst='mydst', srcApp='<Follow point B mentioned above>', overWrite='false')



Example
migrateSecurityStore(type='appPolicies', configFile='[DOMAIN_HOME]/config/fmwconfig/jps-config-jse_backup.xml',src='mysrc', dst='mydst', srcApp='OIM', overWrite='false')


Note: srcApp value will be changed according to the policy data as below:
'jazn-data.xml' (from OIM.ear)  - srcApp is OIM
'jazn-data.xml' (found in oracle.iam.console.identity.self-service.ear) - srcApp is OracleIdentityManager
'jazn-data-sysadmin.xml' (found in oracle.iam.console.identity.self-service.ear) - srcApp is OracleIdentityManager




9. Exit the WLST session using exit() command.
10. Repeat from the Step 6 for the other 2 policies.
11. Once done take a restart of OIM servers.


Example for the WLS command for other 2 policies:


migrateSecurityStore(type='appPolicies', configFile='[DOMAIN_HOME]/config/fmwconfig/jps-config-jse_backup.xml',src='mysrc', dst='mydst', srcApp='OracleIdentityManager', overWrite='false')

Thursday, 18 May 2017

Changing SOA Admin user for OIM

SOA Admin user is an user which is required for OIM to communicate with SOA. By default OIM use weblogic as SOA Admin user, but you can change this user as per your requirement. Changes need to be done in several location. Below is a python script cn be used to change SOA Admin user.


Run this python script for $OIM_HOME/common/bin/wlst.sh


wlst> ./tmp/changeSOAAdmin.py $WL_USER $WL_PASSWORD $OIM1_URL $ADMIN_URL_T3 $WEBLOGIC_DOMAIN_NAME


------------------------------------changeSOAAdmin.py--------------------------------------
#!/usr/bin/python
import sys
wl_user=sys.argv[1]
wl_password=sys.argv[2]
oim1_url=sys.argv[3]
admin_url=sys.argv[4]
domain_name=sys.argv[5]


connect(wl_user,wl_password, oim1_url)
custom()
cd('/oracle.iam/oracle.iam:name=SOAConfig,type=XMLConfig.SOAConfig,XMLConfig=Config,Application=oim,ApplicationVersion=11.1.2.0.0')
set('Username', wl_user)
shutdown(force='true')
disconnect()

connect(wl_user,wl_password,admin_url)
deleteCred(map="oim", key="SOAAdminPassword");
createCred(map="oim", key="SOAAdminPassword", user=wl_user,password=wl_password);

edit()
startEdit()

cd('/ForeignJNDIProviders/ForeignJNDIProvider-SOA')
set('User',wl_user)
set('Password',wl_password)

save()
activate()
exit()

-------------------------------------------------------------------------------------------------------------------
The above script is doing 3 changes


1. Changing the SOA Admin Username in XMLConfig.SOAConfig
2. Recreating the SOAAdminPassword CSF
3. Updating the new user details in ForeignJNDIProvider-SOA

WLST to grant Jps Permission to OIM domain directories

You can grant Jps Permission to directories using following WLST command.


Syntax


grantPermission(codeBaseURL=[]DIRECTORY_URL', permClass=[PERMISSION_CLASS]', permTarget='[PERMISSION_TARGET]')


Example


[OIM_HOME]/common/bin/wlst.sh
connect(wl_user,wl_password, admin_url)


grantPermission(codeBaseURL='file:${XL.HomeDir}/apps/-', permClass='oracle.security.jps.JpsPermission', permTarget='IdentityAssertion')


grantPermission(codeBaseURL='file:${domain.home}/servers/${weblogic.Name}/tmp/_WL_user/-', permClass='oracle.security.jps.JpsPermission', permTarget='IdentityAssertion')

WLST command to deploy SOA composites for OIM

You can deploy SOA composites for OIM using WLST command, without login into EM console


Syntax


sca_deployComposite(serverURL, sarLocation, [overwrite], [user], [password],
[forceDefault], [configplan], [partition])



Example


$SOA_HOME/common/bin/wlst.sh
sca_deployComposite('http://localhost:8001','/workflows/sca_ManagerApproval_rev1.2.jar',true,'weblogic','abcd1234',true,'/workflows/ManagerApproval_cfgplan.xml');

DuplicateRefException in Disconnected Application Instance after upgrading OIM to PS3

After upgrading OIM to PS3 from previous version (like PS1 or R2 base version), we observed that the disconnected application instance's form doesn't work properly. Issue may happen with create form  and modify form.


If the issue is in create form, then you will not be able to raise request of it. Submit of request will throw exceptions.
If issue is with modify form then request can be created but approvers/fulfillment users will not be able to see the form data from request.


we noticed that the issue occurred on those disconnected applications where there are some hidden field in request dataset.


The error looks like below.


oracle.mds.exception.MDSRuntimeException: MDS-00010: DuplicateRefException. In document /oracle/iam/ui/runtime/form/view/pages/[APP_NAME]CreateForm.jsff there are multiple elements with the same ID _xg_0


oracle.mds.exception.MDSRuntimeException: MDS-00010: DuplicateRefException. In document /oracle/iam/ui/runtime/form/view/pages/[APP_NAME]ModifyForm.jsff there are multiple elements with the same ID _xg_0


Solution


1. Export the whole MDS of identity self service.


$OIM_HOME/common/bin/wlst.sh
connect('${WL_USER}','${WL_PASSWORD}','${ADMIN_URL_T3}');
exportMetadata(application='oracle.iam.console.identity.self-service.ear', server='${OIM_INSTANCE_NAME}', toLocation='/tmp/mds');


2. Go to the location where the MDS is exported /tmp/mds.
3. Now move to /oracle/iam/ui/runtime/form/view/pages/mdssys/cust/site/site/
4. Here you can see the create form and modify form's jsff files for all the application instances.
5. Open the create or modify jsff file in editor mode. You can see there are 2 <af: panelFormLayout> tags, which are under same <mds: insert> tag




6. Edit this form and put each <af: panelFormLayout>  under a separate <mds: insert> tag, like below.




7. Save the form do the same for all other application forms.


You can also use the below Unix command to perform the bulk update on all the forms.


Create Forms


find /tmp/mds/oracle/iam/ui/runtime/form/view/pages/mdssys/cust/site/site/ -name *CreateForm.jsff.xml -exec \
 sed  --in-place -e '/<\/af:panelFormLayout>/,/<panelFormLayout id="_xg_0"/s/<\/af:panelFormLayout>/<\/af:panelFormLayout>\n<\/mds:insert>\n<mds:insert parent="sdh1" position="last">/' {} \;



Modify Forms


find /tmp/mds/oracle/iam/ui/runtime/form/view/pages/mdssys/cust/site/site/ -name *ModifyForm.jsff.xml -exec \
 sed  --in-place -e '/<\/af:panelFormLayout>/,/<panelFormLayout id="_xg_0"/s/<\/af:panelFormLayout>/<\/af:panelFormLayout>\n<\/mds:insert>\n<mds:insert parent="sdh1" position="last">/' {} \;



Note: Change the id="_xg_0" or "_xg_1" according to your error message.


8. Zip the entire MDS.


cd /tmp/mds
zip -r ../mds.zip . >/dev/null



9. Upload the mds zip to OIM MDS repository


$OIM_HOME/common/bin/wlst.sh
connect('${WL_USER}','${WL_PASSWORD}','${ADMIN_URL_T3}');
importMetadata(application='oracle.iam.console.identity.self-service.ear', server='$OIM_INSTANCE_NAME', fromLocation='/tmp/mds.zip');



10. Restart the OIM servers.
11. Check all the Disconnected Application Instance form from OIM identity console.


Tuesday, 16 May 2017

Apply weblogic patches in bulk using unix script.

If you apply more than one weblogic patches, then you have to either run the bsu.sh (located at $ORACLE_HOME/utils/bsu) in GUI mode or 1 by 1 in console mode. You can use the below script to install all the patches in one run.


follow the below steps:


1. Create a directory named /tmp/WLS_Patch
2. Put all the patches zip in the above directory
3. Create a sh file name run.sh and copy the below text into the file and save it.


echo "*********************"
echo Upgrade WLS
echo "*********************"
mkdir $ORACLE_HOME/utils/bsu/cache_dir
cd $ORACLE_HOME/utils/bsu/cache_dir
yes | find /tmp/WLS_Patch -name \*.zip -exec unzip  {} \;

cd ..
for i in 56MM CM69 FSG4 IMWL VRGR XA6W YVDZ ZARV
do

 ./bsu.sh -prod_dir=$WL_HOME -patchlist=$i -verbose -install | tee $i.out
 grep "Result: Success" $i.out
 if [ $? -ne 0 ]
 then
  echo "Unexpected issue applying patch $i. Check file $i.out"
  exit 1
 fi
done

echo "*********************"
echo WLS Upgraded
echo "*********************"



4. Replace the ORACLE_HOME and WL_HOME with the appropriate value as per your environment.
5. Add the patch alias name in the for loop list (highlighted in bold)
6. Save the file and run the script.
7. if any error occurred check the i.out file generated where the script is located.







Followers

OIM API for adding process task and retry failed task

 In this blog you can find how to add new process task and retry any failed/rejected tasks using API. Adding new process task: /************...