Import and export policies in OES 11g using API

My friend has already posted about exporting and importing policies in OES 11g through command line. However, if you wish to do the same operation using OES 11g API, here is what you need to do:

  • Use the jps-config.xml as specified in the above posts for export and import respectively.
  • The below code snippet will backup or export the policies to an xml file.

// @ To retrieve the Context Factory Instance.
JpsContextFactory ctxFact = JpsContextFactory.getContextFactory();

// @ To retrieve the JPS context from jps-config.xml.
JpsContext ctx = ctxFact.getContext(“default”);

// @ To identify Policy Store Instance.
PolicyStore ps = ctx.getServiceInstance(PolicyStore.class);

// @ To backup policy data into an xml.
JpsUtilityFactory.getBackupRestorePolicyUtil().backupAllPolicyData(“default”, path);

Pre-requisites for export operation: The system-jazn-data.xml (available at $WL_DOMAIN/config/fmwconfig) has to be copied to an export location. This file will be overwritten by the above code snippet. The system-jazn-data.xml file located at  $WL_DOMAIN/config/fmwconfig will contain all the system policies. The above code snippet will export all the application policies into the same XML which can then be used for import.

  • The below code snippet will restore or import the policies to target OES environment.

// @ To retrieve the Context Factory Instance.
JpsContextFactory ctxFact = JpsContextFactory.getContextFactory();

// @ To retrieve the JPS context from jps-config.xml.
JpsContext ctx = ctxFact.getContext(“default”);

// @ To identify Policy Store Instance.
PolicyStore ps = ctx.getServiceInstance(PolicyStore.class);

// To restore the policies to target OES server
JpsUtilityFactory.getBackupRestorePolicyUtil().restoreAllPolicyData(path, jpsContext);

 

Share This Post with Your Friends over Social Media!

About the Author Mahendra

I am engulfed in Oracle Identity & Access Management domain. I have expertise on providing the optimized solutions for user provisioning, web access management, Single Sign-On and federation capabilities etc., I am also well versed with complex integrations within Identity Management and other product domains. I have expertise on building demos and implementation experience on products Oracle Access Manager, Oracle Adaptive Access Manager, Oracle Entitlement Server, Oracle Virtual Directory, Oracle Internet Directory etc., Look @ my blog: http://talkidentity.blogspot.com

Leave a Comment: