README.md revision d792382b68b74b11c1f14512157eda1ebe0de014
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * Copyright (c) 2014-2015 ForgeRock AS. All rights reserved.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * The contents of this file are subject to the terms
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * of the Common Development and Distribution License
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * (the License). You may not use this file except in
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * compliance with the License.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * You can obtain a copy of the License at
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * http://forgerock.org/license/CDDLv1.0.html
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * See the License for the specific language governing
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * permission and limitations under the License.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * When distributing Covered Code, include this CDDL
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * Header Notice in each file and include the License file
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * at http://forgerock.org/license/CDDLv1.0.html
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * If applicable, add the following below the CDDL Header,
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * with the fields enclosed by brackets [] replaced by
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * your own identifying information:
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering * "Portions Copyrighted [year] [name of copyright owner]"
72648326ea6d3e68cdb0b5890df737047d031a41Lennart PoetteringSample 3 - Scripted SQL
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poettering=======================
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart PoetteringThis sample demonstrates creating a new CustomScriptedSQL connector using the
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringcustom-scripted-connector-bundler-3.2.0-SNAPSHOT.jar that is included in the tools
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringdirectory of the OpenIDM zip file. This sample will rely on this new custom
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringconnector you create. It will provide an example configuration and a handful of
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringgroovy scripts that will be used to communicate with the SQL server.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart PoetteringThis example requires a fresh installation of OpenIDM. It also requires that you
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringhave Maven installed.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart PoetteringFor documentation pertaining to this example see:
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringhttp://openidm.forgerock.org/doc/install-guide/index.html#more-sample3
72648326ea6d3e68cdb0b5890df737047d031a41Lennart PoetteringThis sample also demonstrates the use of complex data types. Complex types
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringcan be stored, retrieved and synced like any other property of an object. These
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringtypes can be mapped to your external data sources in any way you choose but are
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringgenerally stored in the managed data as JSON represented as a String. This may
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringbe customized further to do additional work with or transformation on that data.
72648326ea6d3e68cdb0b5890df737047d031a41Lennart PoetteringThe sync.json script demonstrates the use of event hooks to perform an action. In
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringthis example there are two hooks, one for the onCreate event and another for onUpdate,
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringboth for the managed user to external repo user case. In both events this sample
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringwill log a statement to OpenIDM's log file (see the logs directory) when a managed
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringuser is created or updated in the external repo. In both cases the script is
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringexplicitly included in the sync.json file but could just as easily have referenced
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringan external file for the script source instead. For more information see:
5fa89b2cb366d533e56a9b7a9ce548480776f973Lennart Poetteringhttp://openidm.forgerock.org/doc/webhelp/integrators-guide/appendix-scripting.html
72648326ea6d3e68cdb0b5890df737047d031a41Lennart PoetteringThe scripted connector supports any number of custom scripted endpoints. These are
72648326ea6d3e68cdb0b5890df737047d031a41Lennart Poetteringconfigured via the provisioner script and currently support only Groovy. See
Description: Generate classes and files necessary to build a custom connector. Using those generated files we will build
1. From sample3/create-connector directory, run the following command using the custom config
provided in the sample3/data directory.
$ java -jar ../../../tools/custom-scripted-connector-bundler-3.2.0-SNAPSHOT.jar -c ../data/scriptedsql.json
2. Copy the provided sample scripts into connector src directory; these will become part of the custom connector.
$ cp ../tools/* src/main/resources/script/hrdb/
3. Build the custom connector. You should be in the sample3/create-connector directory
4. Change directory up one directory to the sample's main directory, /path/to/openidm/samples/sample3.
5. Copy the connector you just created from the create-connector directory to the connectors directory of OpenIDM. If
$ cp create-connector/target/hrdb-connector-1.4.1.0.jar ../../connectors/
At this point we now have a connector that is ready to go in OpenIDM. This connector has all the necessary files you will
need to have it displayed in the UI. It has also both the scripts and provisioner config ready to go.
inflated: conf/provisioner.openicf-hrdb.json
7. Replace the "systemActions" value inside the sample3/conf/provisioner.openicf-hrdb.json
"actionFile" : "tools/ResetDatabaseScript.groovy"
8. For demonstration purposes we are going to also copy the generated html template file associated with this connector
Inside the connector jar we just created search for a file containing "1.4.html".
$ cd path/to/openidm
Extract the file you found above into the /path/to/openidm/ui directory.
$ jar -xvf connectors/hrdb-connector-1.4.1.0.jar ui/org.forgerock.openicf.connectors.hrdb.HRDBConnector_1.4.html
$ mkdir -p ui/extension/templates/admin/connector; mv ui/org.forgerock.openicf.connectors.hrdb.HRDBConnector_1.4.html ui/extension/templates/admin/connector
$ curl -k --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --header "Content-Type: application/json" --request POST "https://localhost:8443/openidm/system/hrdb?_action=script&scriptId=ResetDatabase"
+----+--------+------------------------------------------+-----------+----------+---------------+---------------------------+--------------+---------------------+
+----+--------+------------------------------------------+-----------+----------+---------------+---------------------------+--------------+---------------------+
| 1 | bob | e38ad214943daad1d64c102faec29de4afe9da3d | Bob | Fleming | Bob Fleming | Bob.Fleming@example.com | HR | 2014-10-30 08:55:41 |
| 2 | rowley | 2aa60a8ff7fcd473d321e0146afd9e26df395147 | Rowley | Birkin | Rowley Birkin | Rowley.Birkin@example.com | SALES | 2014-10-30 08:55:41 |
| 3 | louis | 1119cfd37ee247357e034a08d844eea25f6fd20f | Louis | Balfour | Louis Balfour | Louis.Balfor@example.com | SALES | 2014-10-30 08:55:41 |
| 4 | john | a1d7584daaca4738d499ad7082886b01117275d8 | John | Smith | John Smith | John.Smith@example.com | SUPPORT | 2014-10-30 08:55:41 |
| 5 | jdoe | edba955d0ea15fdef4f61726ef97e5af507430c0 | John | Doe | John Doe | John.Doe@example.com | ENG | 2014-10-30 08:55:41 |
+----+--------+------------------------------------------+-----------+----------+---------------+---------------------------+--------------+---------------------+
$ curl -k -H "Content-type: application/json" -u "openidm-admin:openidm-admin" -X POST "https://localhost:8443/openidm/recon?_action=recon&mapping=systemHrdb_managedUser"
$ curl -k -u "openidm-admin:openidm-admin" --request GET "https://localhost:8443/openidm/managed/user/?_queryId=query-all-ids&_prettyPrint=true"
$ curl -k -u "openidm-admin:openidm-admin" --request GET "https://localhost:8443/openidm/managed/user?_queryId=for-userName&uid=rowley&_prettyPrint=true"
by OpenIDM/OpenICF in the Groovy scripts.
cars.users_id column. The Groovy scripts are responsible for reading this
$ curl -k -u "openidm-admin:openidm-admin" --request GET 'https://localhost:8443/openidm/system/hrdb/account?_queryFilter=uid+sw+""&_pageSize=2&_sortKeys=timestamp,id'
$ curl -k -u "openidm-admin:openidm-admin" --request GET 'https://localhost:8443/openidm/system/hrdb/account?_queryFilter=uid+sw+""&_pageSize=2&_sortKeys=timestamp,id&_pagedResultsCookie=2014-09-11%2010:07:57.0,2'
You can log in to the OpenIDM UI (https://localhost:8443/openidmui) with any of
Consult the values from the sample3/tools/ResetDatabaseScript.groovy script to