This is just a simple application to show how to call a java application from Novell's IdM product.
Be sure the DirXML Script namespace definitions are set within the policy where using the Java call.
You will also need to place the Java jar files in the correct location.
The idea is to supply a UUID as defined in RFC 4122.
The UUID will be a string and look similar to:
cd2c0ce6-5d5d-11dc-a188-f53b0a4780f0
Shows a DirXML Example and XPATH Example for working with DirXML Calling Java Example.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE policy PUBLIC "policy-builder-dtd" "C:\novell\Designer\eclipse\plugins\com.novell.designer.idm.policybuilder_2.0.0.200703152140\DTD\dirxmlscript.dtd"> <policy xmlns:uuid="http://www.novell.com/nxsl/java/com.willeke.uuid.UUIDGen"> <rule> <description>GUID Generate</description> <conditions> <and/> </conditions> <actions> <do-set-local-variable name="mac" scope="policy"> <arg-string> <token-text xml:space="preserve">f5:3b:0a:47:80:f0</token-text> </arg-string> </do-set-local-variable> <do-set-local-variable name="myguid" scope="policy"> <arg-string> <token-xpath expression="uuid:genUUID($mac)"/> </arg-string> </do-set-local-variable> <do-trace-message> <arg-string> <token-text xml:space="preserve">### </token-text> <token-local-variable name="myguid"/> <token-text xml:space="preserve"> ###</token-text> </arg-string> </do-trace-message> </actions> </rule> </policy>
In the example, we supply a MAC Address as a local variable which could be from a GCV. The value should be a "real" MAC Address of the machine the generator runs on to comply with the RFC.
Here is the Java source code of the application:
/** * A wrapper around the Java Uuid Generator (JUG) * See: http://jug.safehaus.org/Home */ package com.willeke.uuid; /** * @author jim@willeke.com */ public class UUIDGen { /** * Just here for fun */ public UUIDGen(String macaddress) { System.out.println(genUUID(macaddress)); } /** * @param mac - * Mac address of Machine * @return - String of UUID */ public static String genUUID(String mac) { return org.safehaus.uuid.UUIDGenerator.getInstance().generateTimeBasedUUID(new org.safehaus.uuid.EthernetAddress(mac)).toString(); } /** * Prints to the system console * * @param macaddress */ public static void printUUID(String macaddress) { System.out.println(genUUID(macaddress)); } /* * Just to test with */ public static void main(String[] args) { printUUID(args[0]); } }
Copy the jar file to the correct location for Jars for IDM.
You will have to stop and start the IdM engine for the jar file to be read.
Install the policy and watch it work.
12:17:16 964A5BA0 Drvrs: Generic Null ST:Applying policy: Temp. 12:17:16 964A5BA0 Drvrs: Generic Null ST: Applying to modify #1. 12:17:16 964A5BA0 Drvrs: Generic Null ST: Evaluating selection criteria for rule 'GUID Generate'. 12:17:16 964A5BA0 Drvrs: Generic Null ST: Rule selected. 12:17:16 964A5BA0 Drvrs: Generic Null ST: Applying rule 'GUID Generate'. 12:17:16 964A5BA0 Drvrs: Generic Null ST: Action: do-set-local-variable("mac",scope="policy","f5:3b:0a:47:80:f0"). 12:17:16 964A5BA0 Drvrs: Generic Null ST: arg-string("f5:3b:0a:47:80:f0") 12:17:16 964A5BA0 Drvrs: Generic Null ST: token-text("f5:3b:0a:47:80:f0") 12:17:16 964A5BA0 Drvrs: Generic Null ST: Arg Value: "f5:3b:0a:47:80:f0". 12:17:16 964A5BA0 Drvrs: Generic Null ST: Action: do-set-local-variable("myguid",scope="policy",token-xpath("uuid:genUUID($mac)")). 12:17:16 964A5BA0 Drvrs: Generic Null ST: arg-string(token-xpath("uuid:genUUID($mac)")) 12:17:16 964A5BA0 Drvrs: Generic Null ST: token-xpath("uuid:genUUID($mac)") 12:17:16 964A5BA0 Drvrs: Generic Null ST: Token Value: "cd2c0ce6-5d5d-11dc-a188-f53b0a4780f0". 12:17:16 964A5BA0 Drvrs: Generic Null ST: Arg Value: "cd2c0ce6-5d5d-11dc-a188-f53b0a4780f0". 12:17:16 964A5BA0 Drvrs: Generic Null ST: Action: do-trace-message("### "+token-local-variable("myguid")+" ###"). 12:17:16 964A5BA0 Drvrs: Generic Null ST: arg-string("### "+token-local-variable("myguid")+" ###") 12:17:16 964A5BA0 Drvrs: Generic Null ST: token-text("### ") 12:17:16 964A5BA0 Drvrs: Generic Null ST: token-local-variable("myguid") 12:17:16 964A5BA0 Drvrs: Generic Null ST: Token Value: "cd2c0ce6-5d5d-11dc-a188-f53b0a4780f0". 12:17:16 964A5BA0 Drvrs: Generic Null ST: token-text(" ###") 12:17:16 964A5BA0 Drvrs: Generic Null ST: Arg Value: "### cd2c0ce6-5d5d-11dc-a188-f53b0a4780f0 ###". 12:17:16 964A5BA0 Drvrs: Generic Null ST:### cd2c0ce6-5d5d-11dc-a188-f53b0a4780f0 ###