Skip to content

Commit

Permalink
Merge pull request #4 from Olethros/ecmaversion
Browse files Browse the repository at this point in the history
Ecmaversion
  • Loading branch information
lhaeger authored Jan 12, 2022
2 parents 02bda82 + eb74fcb commit bbff4b5
Show file tree
Hide file tree
Showing 9 changed files with 1,517 additions and 200 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,40 @@
A helper class to queue XDS events into a Micro Focus Identity Manager driver cache

Initially developed by Peter Lambrechtsen and published at https://community.microfocus.com/t5/Identity-Manager-Tips/Sending-a-XDS-Message-from-one-driver-to-another/ta-p/1777175 , this version fixes a few bugs and adds javadocs.

If a supplied document is only a command and lacks the complete nds wrapper, a wrapper will be added.
Includes support for injecting both regular "add/modify" events and also "migrate into Identity Vault" style queries.

# dxqueue-es

This version is a port of the code to ECMAScript and adds more robust validation.


There are minor differences between the internal pre-validation of DOM documents. In the ECMAScript version, all attempts are made to try and ensure that invalid documents are not queued. Instead an error message is returned.
This is to prevent crashing or hanging of the engine. Also the ECMAScript version, one can pass a document where the operation/element node is the root of the documet and it will be accepted.

Also The JAR version expects that you select pass a child of the root node.

## sendQueueEvent
Support for queueing "add/modify" style operations.

The JAR version is called from the defined namespace.
dxqueue:sendQueueEvent(java.lang.String driverDN, org.w3c.dom.Element element)

The ECMAScript version is a drop-in replacement for the Java helper class, with identical calling syntax.
Any well formed operation, including driver-specific operations and namespaces can be queued.

es:sendQueueEvent(java.lang.String driverDN, org.w3c.dom.Element element)


## sendMigrateApp
Support for queueing "migrate into Identity Vault" style queries.

The JAR version is called from the defined namespace.
dxqueue:sendMigrateApp(java.lang.String driverDN, org.w3c.dom.Element element)

The ECMAScript version is a drop-in replacement for the Java helper class, with identical calling syntax.

Only query or query-ex operations can be queued.

es:sendMigrateApp(java.lang.String driverDN, org.w3c.dom.Element element)
288 changes: 288 additions & 0 deletions demo/SendMigrateApp-es.trace

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions demo/SendMigrateApp.trace

Large diffs are not rendered by default.

211 changes: 211 additions & 0 deletions demo/SendMigrateApp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="UTF-8"?><driver-configuration dn="cn=SendMigrateApp,cn=driverset1,o=system" driver-set-dn="cn=driverset1,o=system" name="SendMigrateApp">
<attributes>
<configuration-manifest>
<manifest/>
</configuration-manifest>
<driver-filter-xml>
<filter>
<filter-class class-name="User" publisher="ignore" publisher-create-homedir="true" publisher-track-template-member="true" subscriber="sync">
<filter-attr attr-name="Given Name" merge-authority="default" publisher="ignore" publisher-optimize-modify="true" subscriber="sync"/>
<filter-attr attr-name="CN" merge-authority="default" publisher="ignore" publisher-optimize-modify="true" subscriber="sync"/>
<filter-attr attr-name="Surname" merge-authority="default" publisher="ignore" publisher-optimize-modify="true" subscriber="sync"/>
</filter-class>
</filter>
</driver-filter-xml>
<driver-image>R0lGODlhYgBPAOZ/AJWp2ank/5TDZJ1yk0u58aTZ+5bY/omFi1Z4ikhJS2Fme7a1tjZabI246Irb/orG9hRwrPT09Pv7+2bJ+FbG/Dw8Pk2q2my65U2QtITc/3WYqXfK8yeNy6220qKXxaioqofI6mXR/wmO2Fmaw9Dw/9nZ2XPD64nV/tLS0sTFxWOp1OXl5TuDrpzh/4jQ+0VpfpyezTut6lWCl7LB27GItKbG5+vs7VJMY5TF4nza/4air2/U/qiUv6yOvDlui2CizG5cb+T1/XB2e5iUmbHI55TA1pvK9HvU/nCftqG74GXA7Lzq/mey3qbN8QB2yx09TR59uo7V9rWXtqt8pIPU+J+ps3e42neEm7aBrTFBIXXY/wQEBF+btZvQ6ozO6wxlnzej31FrOAdJdItphrSWrXzP96zS87LU6863yebd49rL1ioqKazb+i6Z1xgfEO7v8NfX2GNjYuz5/83U19PBzN3c3ff394F1lObn6Ojl59rQ1nKvzHiozh0dHf///////yH5BAEAAH8ALAAAAABiAE8AAAf/gH+Cg4SFhoeIiYqLiSspB3EJa2sVCUIfJXaMm5ydnpsoQm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znDW8gBmLwBRIogRBQgRYIBRiYgRjIARzQBmXFVBclTCIogsR0BCaTATlwBDswARNAARbFBFZgBUWgA72nfb+3Hk8Q/4ETSIEW2IMVmIEcWFaAZVFEiFYUwEizc0xvo4IsKIL9d1kJOIM1yE0XAw05uINY+AU+CIRBKIR/tVRgGFOnNEXJl3zYw4JoiIb/5wJuggNSuHPi9Q1XmIUTeIEaCAUc2IUe+IUxhYT/8z9pmIalp1yq4gVu+IaZZoODYBZfwQ46mIVbeIcb2IV82FSBeIkseHzK1VmFGIVF0AHfsCm+Nwi1gCProIM+2IOSyIUd+FcWAE4E0H+yOAGyeFmkRgWqkipuIieH2AEdIwEbsQC+oQgZYg+sEQEskIzbk4zM2IzKaH9g94rSaAEJpgT8Z4vqJSdwso1vooCHOANlJBBbcMwDC8A4jbARVdgcxbGO7BgNTMZLqLEANrAI1KEh7XiP+EgcA/FJKSAUiYAOW/AB+TiQBPkNKDA0C1ACnHAYWyAEYVWQEPkab/AB21ATS7SQo7AGJ5ELhdORHvmRIBmSIjmShZMbQxAMrFATJNQJEYACqxAXMBmTMjmTaSEM0DNCsSAhQqAfFdCTPvmTQBmUQjmURFmURZkAcdA6K3CRxkApJQAHUBmVUjmVVFmVVnmVWGmVWAE0LdGVXgkLPROWYjmWZFmWZnmWYRkLgQAAOw==</driver-image>
<log-events inherit="true"/>
<trace-file inherit="true"/>
<trace-size-limit inherit="true"/>
<trace-level value="3"/>
<driver-trace-level inherit="true"/>
<log-limit inherit="true"/>
<java-module value="com.novell.nds.dirxml.driver.nulldriver.NullDriverShim"/>
<policy-linkage>
<linkage-item dn="cn=sendMigrateApp,cn=Library,cn=driverset1,o=system" order="0" policy-set="3" policy-set-name="ECMAScript"/>
<linkage-item dn="cn=Send Migrate App,cn=Subscriber,cn=SendMigrateApp,cn=driverset1,o=system" order="0" policy-set="4" policy-set-name="Subscriber Event"/>
</policy-linkage>
<driver-cache-limit value="0"/>
<shim-auth-password-query/>
<driver-password-query/>
<driver-start-option no-resync="false" value="2"/>
<shim-config-info-xml>
<driver-config name="Null Driver">
<publisher-options>
<configuration-values>
<definitions>
<definition display-name="Publisher heartbeat interval" name="pub-heartbeat-interval" type="integer">
<description>Configures the driver shim to send a periodic status message on the publisher channel when there has been no publisher traffic for the given number of seconds.</description>
<value>0</value>
</definition>
</definitions>
</configuration-values>
</publisher-options>
</driver-config>
</shim-config-info-xml>
<global-config-values>
<configuration-values>
<definitions display-name="Queue Event">
<definition critical-change="true" display-name="How to handle queuing of events" name="drv.action.queueEvent" type="enum">
<description/>
<value>use-es</value>
<enum-choice display-name="Do nothing">none</enum-choice>
<enum-choice display-name="Use JAR">use-jar</enum-choice>
<enum-choice display-name="Use ECMAScript">use-es</enum-choice>
</definition>
</definitions>
</configuration-values>
</global-config-values>
<application-schema/>
</attributes>
<children>
<publisher name="Publisher">
<attributes/>
<children/>
</publisher>
<subscriber name="Subscriber">
<attributes/>
<children>
<rule name="Send Migrate App">
<policy xmlns:dxqueue="http://www.novell.com/nxsl/java/dxqueue.send">
<rule>
<description>Query Event</description>
<comment xml:space="preserve">This policy will trigger on an incoming event, and generate a XDS Message to put onto the other driver. In this scenario, it does the following:
- Create a query document
- Inject it into the other driver tagged as a "Migrate From App" query.
- Any resulting instance will be turned into a sync by the engine.

There are a few tricks:
- DriverDN must include the full TreeName.
- sendMigrateApp will return a Nodeset so you must set the variable type to be a nodeset. - Resulting nodeset can be parsed to determine if the queue event request was successful or not. This does not indicate whether the query ran successfully, only that the queue event was successful.
- Target driver can be same driver, or another driver. (not yet tested injecting events for drivers that run on another server in driverset)
- Target driver does not have to be running, but it cannot be disabled.</comment>
<conditions>
<and>
<if-global-variable name="drv.action.queueEvent" op="available"/>
</and>
</conditions>
<actions>
<do-set-local-variable name="attrsToClone" notrace="true" scope="policy">
<arg-node-set>
<token-split csv="true" delimiter=",">
<token-text xml:space="preserve">cached-time,class-id,class-name,timestamp</token-text>
</token-split>
</arg-node-set>
</do-set-local-variable>
<do-append-xml-element expression=".." name="query"/>
<do-for-each>
<arg-node-set>
<token-xpath expression="../query[last()]"/>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="parent-node" scope="policy">
<arg-node-set>
<token-local-variable name="current-node"/>
</arg-node-set>
</do-set-local-variable>
<do-set-xml-attr expression="$current-node" name="event-id">
<arg-string>
<token-text xml:space="preserve">migrateQuery:trigger</token-text>
</arg-string>
</do-set-xml-attr>
<do-clone-xpath dest-expression="$current-node" notrace="true" src-expression="@*[name()=$attrsToClone]"/>
<do-set-xml-attr expression="$current-node" name="scope">
<arg-string>
<token-text xml:space="preserve">entry</token-text>
</arg-string>
</do-set-xml-attr>
<do-clone-xpath dest-expression="$current-node" notrace="true" src-expression="$current-op/association"/>
<do-append-xml-element before="*[1]" expression="$current-node" name="search-attr" notrace="true"/>
<do-set-xml-attr expression="$current-node/search-attr" name="attr-name">
<arg-string>
<token-text xml:space="preserve">CN</token-text>
</arg-string>
</do-set-xml-attr>
<do-append-xml-element before="*[1]" expression="$current-node/search-attr[last()]" name="value" notrace="true"/>
<do-append-xml-text expression="$current-node/search-attr[last()]/value[last()]">
<arg-string>
<token-src-name/>
</arg-string>
</do-append-xml-text>
<do-set-local-variable name="varQueryXDS-ns" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-xml-serialize>
<token-xpath expression="$current-node" notrace="true"/>
</token-xml-serialize>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>
<do-strip-xpath expression="$current-node"/>
</arg-actions>
</do-for-each>
<do-trace-message>
<arg-string>
<token-xml-serialize>
<token-local-variable name="varQueryXDS-ns"/>
</token-xml-serialize>
</arg-string>
</do-trace-message>
<do-set-local-variable name="DriverDN" scope="policy">
<arg-string>
<token-parse-dn dest-dn-format="slash" length="-2" src-dn-format="slash">
<token-text xml:space="preserve">~dirxml.auto.driverdn~</token-text>
</token-parse-dn>
<token-text xml:space="preserve">\JDBC</token-text>
</arg-string>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-global-variable mode="nocase" name="drv.action.queueEvent" op="equal">use-es</if-global-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="CmdResult" scope="policy">
<arg-node-set>
<token-xpath expression="es:sendMigrateApp($DriverDN, $varQueryXDS-ns)"/>
</arg-node-set>
</do-set-local-variable>
</arg-actions>
</do-if>
<do-if>
<arg-conditions>
<and>
<if-global-variable mode="nocase" name="drv.action.queueEvent" op="equal">use-jar</if-global-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="XDS" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-text xml:space="preserve">&lt;nds>&lt;input></token-text>
<token-xml-serialize>
<token-local-variable name="varQueryXDS-ns"/>
</token-xml-serialize>
<token-text xml:space="preserve">&lt;/input>&lt;/nds></token-text>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="CmdResult" scope="policy">
<arg-node-set>
<token-xpath expression="dxqueue:sendMigrateApp($DriverDN, $XDS/nds)"/>
</arg-node-set>
</do-set-local-variable>
</arg-actions>
<arg-actions/>
</do-if>
<do-trace-message>
<arg-string>
<token-xml-serialize>
<token-xpath expression="$CmdResult//status"/>
</token-xml-serialize>
</arg-string>
</do-trace-message>
</actions>
</rule>
</policy>
</rule>
</children>
</subscriber>
</children>
</driver-configuration>
Loading

0 comments on commit bbff4b5

Please sign in to comment.