Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small int + workaround for credentials #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions connectors/java/databasetable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

## Table of Contents
1. [Introduction](#introduction)
2. [Capabilities and Features](#capabilities-and-features)
3. [JSON Mode](#json-mode)
4. [Custom SQL Query Mode](#custom-sql-query-mode)
5. [Basic Mode](#basic-mode)
6. [JDBC Driver](#jdbc-driver)
7. [Limitations](#limitations)
8. [Build](#build)

# Introduction
### databasetable-connector
Identity connector for generic relational database table.

# Capabilities and Features
- Schema: YES
- Provisioning: YES
- Live Synchronization: YES - Using last modification timestamps
- Password: YES
- Activation: SIMULATED - Configured capability
- Script execution: No

# Connector Modes
- Connector supports 3 different modes
- Modes can be changed via configuration in resource
- Three supported modes are: `JSON`, `CUSTOM_SQL_QUERY` and `BASIC`

## JSON Mode
- JSON Mode supports arbitrary number of ObjectClasses and their attributes
- When using JSON mode each object class needs to be defined in JSON file
- JSON File should be properly secured and protected with appropriate permissions
- Database, connector mode and credentials need to be defined in configuration as usual
- Every ObjectClass defined in JSON File must have the following parameters:

```
{
"objectClassName": "AnyObjectClass",
"configurationProperties": {
"Table": "TableName",
"Key Column": "KeyColumnName",
"Enable writing empty string": true,
"Change Log Column (Sync)": "ChangeLogColumn",
"Sync Order Column": "SyncOrderColumn",
"Sync Order Asc": true,
"Suppress Password": true
}
}
```
- For better understanding use `JSON_example.json` in the `samples` folder

## Custom SQL Query Mode
- In custom SQL Query mode the connectors expects SQL Query file.
- Where clause is supported
- Sql Query can be in-line or with each part in new line
- Using aggregate functions is supported
- Key column, database, connector mode and credentials need to be defined in configuration as usual
- Example `SQL_query.sql` can be found inside the `samples` folder
- Columns and table need to be defined in the sql query as shown:
```
SELECT column1, column2 FROM table
```
or
```
SELECT column1 as col1, column2 as col2 FROM table
```

## Basic Mode
- Configuration requires specifying the key column, database, connector mode, database table and credentials.
- An example configuration file `resource_basic.xml` can be found inside the `samples` folder.
-

## JDBC Driver
- Supported JDBC Drivers are:
- MySQL Connector/J 5.1.6
- Microsoft SQL Server 2005 JDBC Driver 1.2
- Oracle Database 10g Release 2 (10.2.0.2) JDBC Driver
- Apache Derby 10.4
- JDBC driver and it respective Url template:

| jdbcDriver | jdbcUrlTemplate |
|-------------------------------------------------------------------------------------|:---------------------------------------|
| oracle.jdbc.driver.OracleDriver, org.apache.derby.jdbc.EmbeddedDriver (for testing) | jdbc:oracle:thin:@%h:%p:%d |
| com.mysql.cj.jdbc.Driver, com.mysql.jdbc.Driver | jdbc:mysql://%h:%p/%d |
| org.postgresql.Driver | jdbc:postgresql://%h:%p/%d |
| com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:sqlserver://%h:%p;databaseName=%d;|

## Limitations
There are few limitation for specific connector modes.
### SQL QUERY
- Does not support create, update or delete

### BASIC
- Does not support multiple database tables

## Build
```
mvn clean install
```
## Build without Tests
```
mvn clean install -DskipTests=True
```
After successful build, you can find connector-databasetable-1.5.2.0-SNAPSHOT.jar in target directory.

## TODO
- An update to support new associations in version 4.9, this will enable the connector to handle traditional database relations.

# Status
- Tested only on MySQL 9.0.0
- Tested with MidPoint version 4.8.1.
11 changes: 11 additions & 0 deletions connectors/java/databasetable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<properties>
<project.source.version>17</project.source.version>
<derby.version>10.17.1.0</derby.version>
<javax.json.version>1.1.4</javax.json.version>

<connectorPackage>org.identityconnectors.databasetable</connectorPackage>
<connectorClass>DatabaseTableConnector</connectorClass>
Expand Down Expand Up @@ -88,6 +89,16 @@
<version>${derby.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>${javax.json.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
30 changes: 30 additions & 0 deletions connectors/java/databasetable/samples/Json_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"objects": [
{
"objectClassName": "User",
"configurationProperties": {
"Table": "pouzivatelia",
"Key Column": "key_column",
"Enable writing empty string": true,
"Change Log Column (Sync)": "change_log_column",
"Sync Order Column": "sync_order_column",
"Sync Order Asc": true,
"Suppress Password": true,
"Native Timestamps": true
}
},
{
"objectClassName": "Group",
"configurationProperties": {
"Table": "skupiny",
"Key Column": "key_column",
"Enable writing empty string": true,
"Change Log Column (Sync)": "change_log_column",
"Sync Order Column": "sync_order_column",
"Sync Order Asc": true,
"Suppress Password": true,
"All native": true
}
}
]
}
5 changes: 5 additions & 0 deletions connectors/java/databasetable/samples/SQL_query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT name, count(*) as NumberOfUsers
FROM users
Where test is null and name = 'Marc'
Group by name
Having count(*) > 0
96 changes: 96 additions & 0 deletions connectors/java/databasetable/samples/resource_basic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<resource xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
oid="02fd4df0-ac76-4966-8093-cbc7b8e9c747">

<name>Example Resource Basic</name>
<description>Example resource for the databaseTable connector</description>

<connectorRef relation="org:default" type="c:ConnectorType">
<filter>
<q:and>
<q:equal>
<q:path>connectorType</q:path>
<q:value>org.identityconnectors.databasetable.DatabaseTableConnector</q:value>
</q:equal>
<q:equal>
<q:path>connectorVersion</q:path>
<q:value>1.5.2.0-SNAPSHOT</q:value>
</q:equal>
</q:and>
</filter>
</connectorRef>
<connectorConfiguration xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
<icfc:configurationProperties xmlns:gen577="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-databasetable/org.identityconnectors.databasetable.DatabaseTableConnector">
<gen577:host>localhost</gen577:host>
<gen577:port>3306</gen577:port>
<gen577:user>root</gen577:user>
<gen577:password>
<t:clearValue>password</t:clearValue>
</gen577:password>
<gen577:database>test</gen577:database>
<gen577:table>users</gen577:table>
<gen577:keyColumn>key_column</gen577:keyColumn>
<gen577:jdbcDriver>com.mysql.cj.jdbc.Driver</gen577:jdbcDriver>
<gen577:jdbcUrlTemplate>jdbc:mysql://%h:%p/%d</gen577:jdbcUrlTemplate>
<gen577:connectorMode>Basic</gen577:connectorMode>
<gen577:changeLogColumn>change_log_column</gen577:changeLogColumn>
</icfc:configurationProperties>
</connectorConfiguration>

<schemaHandling>
<objectType>
<kind>account</kind>
<intent>user</intent>
<default>true</default>
<delineation>
<objectClass>ri:AccountObjectClass</objectClass>
</delineation>
<focus>
<type>UserType</type>
</focus>
<attribute>
<ref>icfs:name</ref>
<outbound>
<source>
<path>name</path>
</source>
</outbound>
</attribute>
<attribute>
<ref>ri:name</ref>
<outbound>
<source>
<path>fullName</path>
</source>
</outbound>
</attribute>
</objectType>
</schemaHandling>
<capabilities>
<native xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
<cap:schema/>
<cap:discoverConfiguration/>
<cap:liveSync/>
<cap:create/>
<cap:read>
<cap:returnDefaultAttributesOption>false</cap:returnDefaultAttributesOption>
</cap:read>
<cap:update>
<cap:addRemoveAttributeValues>true</cap:addRemoveAttributeValues>
</cap:update>
<cap:delete/>
<cap:testConnection/>
<cap:script>
<cap:host>
<cap:type>connector</cap:type>
</cap:host>
</cap:script>
</native>
</capabilities>
</resource>
Loading