Introduction
The Scripted SQL connector provides great flexibility in the interaction with a database resource. A different Groovy script can be configured for each operation.
This wiki page shows all the steps needed to configure a Scripted SQL resource identified by the following connection parameters:
Host: localhost
Port: 3306
Database: HR
JDBC Driver: com.mysql.jdbc.Driver
JDBC Connection URL: jdbc:mysql://%h:%p/%d
User: root
User Password: password
In order to link a Scripted SQL resource there are pre-requisites and configuration steps to be satisfied.
Pre-Requisites
- Download JDBC driver (MySQL JDBC driver in this case) and include it into your JEE container classpath
- Install OpenICF ScriptedSQL connector bundle
- Implement custom Groovy SQL scripts
Install OpenICF ScriptedSQL connector bundle
Warning
A bug in the current stable version of this connector bundle makes sync()
not working: a patch for this was already provided but not yet part of any standard release.
A temporary workaround is to perform full reconciliation on the related synchronization task(s).
Scripted SQL connector bundles can be added at run-time just performing the following two steps.
- Download Scripted SQL connector bundle JAR file from OpenICF site
- Copy downloaded JAR file into the connector bundles directory specified into the configuration parameter
bundles.directory
Implementation of custom Groovy SQL scripts
Every action script receives a set of parameters and an attribute map. The set of parameters varies for each action.
Configuration steps
Configure Scripted SQL connector instance
Use this page as example for your configuration.
- Open your browser and access to the Syncope administration console (http://host:port/syncope-console).
- Log into the interface by providing the following credentials:
- Login: admin
- Password: password
- Click on the Resources tab.
- Click on the Connectors sub-tab.
- Click on Create new Connector button (configuration modal page appears).
- Click on tab General.
- Provide Display name (e.g. 'Sql Scripted Connector').
- Select the correct Bundle name (org.forgerock.openicf.connectors.scriptedsql.ScriptedSQLConnector).
- Select the correct Bundle version (1.1.0.1).
- Click on tab Configurations and provide connector instance configuration.
User: root
Password: password
Host: localhost
TCP Port: 3306
Database: HR
JDBC Driver: com.mysql.jdbc.Driver
JDBC Connection URL: jdbc:mysql://%h:%p/%d
clearTextPasswordToScript: true
reloadScriptOnExecution: true
createScriptFileName: /opt/scriptsql/groovy/CreateScript.groovy
updateScriptFileName: /opt/scriptsql/groovy/UpdateScript.groovy
deleteScriptFileName: /opt/scriptsql/groovy/DeleteScript.groovy
searchScriptFileName: /opt/scriptsql/groovy/SearchScript.groovy
syncScriptFileName: /opt/scriptsql/groovy/SyncScript.groovy
- Click on tab Capabilities.
- Check needed capabilities as shown at Connector instance configuration.
- Click on Save button.
Configure Scripted SQL resource
- Click on the Resources tab.
- Click on the Resources sub-tab.
- Click on Create new Resource button (configuration modal page appears).
- Click on Resource Details tab.
- Choose from the list the correct Connector instance name.
- Provide the following information
- Name: Sql Scripted Resource
- Connector: Sql Scripted Connector
- Click on Schema Mappings tab.
- Click on Add button to insert attributes mapping.
- Click on Save button.
Internal mapping types |
Internal mapping |
External Attributes |
Mandatory condition |
Account Id |
Password |
---|---|---|---|---|---|
Username |
|
|
true |
X |
|
Password |
|
|
true |
|
X |
UserSchema |
surname |
lastname |
false |
|
|
UserSchema |
firstname |
firstname |
false |
|
|
UserSchema |
fullname |
fullname |
false |
|
|
UserSchema |
false |
|
|
||
UserSchema |
organization |
organization |
false |
|
|