How to call external java methods from Policy Xpress

book

Article ID: 49105

calendar_today

Updated On:

Products

DIRECTORY CA Identity Manager CA Identity Governance CA Identity Portal CA Risk Analytics CA Secure Cloud SaaS - Arcot A-OK (WebFort) CA Secure Cloud SaaS - Advanced Authentication CA Secure Cloud SaaS - Identity Management CA Secure Cloud SaaS - Single Sign On SINGLE SIGN ON - LEGACY CA Data Protection (DataMinder) CA User Activity Reporting

Issue/Introduction

 

You need to package and deploy your class correctly, then invoke it from PX using the Run Java Code -> Execute Main function option.

Environment

Release:14.3

 

Resolution

The following information expands on the documentation:
https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-identity-and-access-management/identity-manager/14-3/programming/programming-guide-for-java/Deploy-Custom-Code.html


In order to call a java class from Policy Xpress you will need to do the following:

1.  Create a java class that has a Main method. The arguments to the class are passed as string arguments (var is args - see below).

Here is an example of such a class.

/** *  */package com.ca.px.example;import com.netegrity.imapi.IMContext;/** */public class PxExternalCode {	/**	 * @param args	 */	public static void main(String[] args) {		System.out.println("Main - Entered.");		System.out.println("Main - Calling invoke method.");		new PxExternalCode().invoke(null, args);		System.out.println("Main - exit. DONE");	}		public static void invoke(IMContext context, String[] args) {		System.out.println("invoke - Entered");		System.out.println("invoke - printing the received arguments");		System.out.println(args[0]);		System.out.println("invoke - Exit");	}}

2. After compiling the class you need to deploy it. You have two options:

   a.  If the class is packaged as a jar file then you need to place your jar file under: user_console.war\web-inf\lib
   b.  If the class file is not packaged as a jar file then you need to place your class under its respective package folder structure under user_console.war\web-inf\classes.

So, for the example above it will be under: user_console.war\web-inf\classes\com\ca\px\example (where you'll place the class file).

Note: the 'classes' folder under user_console.war\web-inf does not exist by default and you'll need to create it.


3. If your Identity Manager server is clustered then this should be deployed to all nodes of your cluster.

4. If your using Virtual Appliance Suite, the Path for custom code should be: /opt/CA/VirtualAppliance/custom/IdentityManager/iam_im.ear_user_console.war_WEB-INF_lib

5. Restart the Identity Manager server, or the IM component of VAPP.  If clustered, restart all nodes.

6. Create a PX Policy. Choose the trigger you need.
In Action Rules -> create an action rule -> Choose the Execute Java Method -> Main method option. There you should specify the full name of your class. In our example you should use: com.ca.px.example.PxExternalCode.
You can add parameters in this screen using the Data elements you have in your policy. These parameters will be passed onto your java class as arguments in the 'args' variable. Your class can use them via the args variable.