-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47dc0c0
commit 640a8d2
Showing
28 changed files
with
5,689 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# graph-ldap-sync | ||
# graph-ldap-sync | ||
|
||
LDAP user import utility Apache Shindig with the Neo4j Websocket Backend (https://github.com/iisys-hof/shindig-websocket-client) | ||
|
||
Works with generic connectors and an XML-defined mapping of attributes. | ||
|
||
License: Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
### Usage | ||
1. Build a using maven build with package goal | ||
2. A runnable binary is generated in the target-Folder | ||
3. Edit ldapConfig.xml to match your setup | ||
4. Run, optionally with a configuration file parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ldap_config> | ||
<url>ldap://127.0.0.1:389/</url> | ||
<user>uid=admin,ou=admins,dc=schub,dc=de</user> | ||
<password>secret</password> | ||
<context>ou=users,dc=schub,dc=de</context> | ||
<interval>DAILY</interval> | ||
<read_only>true</read_only> | ||
<subtree_search>true</subtree_search> | ||
<sync_on_start>true</sync_on_start> | ||
<object_classes> | ||
<class>person</class> | ||
<class>inetOrgPerson</class> | ||
</object_classes> | ||
<org_units> | ||
<unit>ou=users,dc=schub,dc=de</unit> | ||
</org_units> | ||
<endpoint> | ||
<type>shindig-graph</type> | ||
<create_own_entries>true</create_own_entries> | ||
<delete_own_entries>false</delete_own_entries> | ||
<create_ldap_entries>false</create_ldap_entries> | ||
<delete_ldap_entries>false</delete_ldap_entries> | ||
<properties> | ||
<user>admin</user> | ||
<host>http://127.0.0.1:8080/shindig/</host> | ||
<fields>id,name,displayName,organizations,thumbnailUrl,emails,phoneNumbers</fields> | ||
<pic-folder>/home/user/pictures/</pic-folder> | ||
<pic-url>http://127.0.0.1:8080/pictures/</pic-url> | ||
</properties> | ||
<mapping> | ||
<!--LDAP to Shindig rules--> | ||
<rule> | ||
<ldap_property>uid</ldap_property> | ||
<end_point_property>id</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>cn</ldap_property> | ||
<end_point_property>name.formatted</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>cn</ldap_property> | ||
<end_point_property>displayName</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>givenName</ldap_property> | ||
<end_point_property>name.givenName</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>sn</ldap_property> | ||
<end_point_property>name.familyName</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<!--new attributes--> | ||
<rule> | ||
<ldap_property>jpegPhoto</ldap_property> | ||
<end_point_property>thumbnail</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>mail</ldap_property> | ||
<end_point_property>emails</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>telephoneNumber</ldap_property> | ||
<end_point_property>phoneNumbers</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>roomNumber</ldap_property> | ||
<end_point_property>org_location</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>physicalDeliveryOfficeName</ldap_property> | ||
<end_point_property>org_site</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>title</ldap_property> | ||
<end_point_property>job_title</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<!-- extended model properties --> | ||
<rule> | ||
<ldap_property>manager</ldap_property> | ||
<end_point_property>managerId</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>secretary</ldap_property> | ||
<end_point_property>secretary</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>departmentNumber</ldap_property> | ||
<end_point_property>department</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>ou</ldap_property> | ||
<end_point_property>orgUnit</end_point_property> | ||
<direction>FROM_LDAP</direction> | ||
<operation>COPY</operation> | ||
</rule> | ||
<!-- department head flag does not exist --> | ||
<!--general attriutes copied on creation--> | ||
<rule> | ||
<ldap_property>uid</ldap_property> | ||
<end_point_property>id</end_point_property> | ||
<direction>BOTH</direction> | ||
<operation>COPY_ON_CREATE</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>cn</ldap_property> | ||
<end_point_property>name.formatted</end_point_property> | ||
<direction>BOTH</direction> | ||
<operation>COPY_ON_CREATE</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>cn</ldap_property> | ||
<end_point_property>displayName</end_point_property> | ||
<direction>BOTH</direction> | ||
<operation>COPY_ON_CREATE</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>givenName</ldap_property> | ||
<end_point_property>name.givenName</end_point_property> | ||
<direction>BOTH</direction> | ||
<operation>COPY_ON_CREATE</operation> | ||
</rule> | ||
<rule> | ||
<ldap_property>sn</ldap_property> | ||
<end_point_property>name.familyName</end_point_property> | ||
<direction>BOTH</direction> | ||
<operation>COPY_ON_CREATE</operation> | ||
</rule> | ||
</mapping> | ||
</endpoint> | ||
<!--test end point printing LDAP user info--> | ||
<!-- | ||
<endpoint> | ||
<type>test</type> | ||
<create_own_entries>false</create_own_entries> | ||
<delete_own_entries>false</delete_own_entries> | ||
<create_ldap_entries>false</create_ldap_entries> | ||
<delete_ldap_entries>false</delete_ldap_entries> | ||
<properties> | ||
</properties> | ||
<rules> | ||
</rules> | ||
</endpoint> | ||
--> | ||
</ldap_config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>de.hofuniversity.iisys</groupId> | ||
<artifactId>graph-ldap-sync</artifactId> | ||
<version>0.0.5</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<archive> | ||
<manifest> | ||
<mainClass>de.hofuniversity.iisys.ldapsync.LdapSync</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
115 changes: 115 additions & 0 deletions
115
src/main/java/de/hofuniversity/iisys/ldapsync/ILdapConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package de.hofuniversity.iisys.ldapsync; | ||
|
||
import javax.naming.NamingEnumeration; | ||
import javax.naming.directory.DirContext; | ||
import javax.naming.directory.ModificationItem; | ||
|
||
/** | ||
* Interface for LDAP connectors that manage domains and other prefixes and | ||
* suffixes and offer manipulation functionality. All names are considered UIDs. | ||
* | ||
* @author fholzschuher2 | ||
* | ||
*/ | ||
public interface ILdapConnector | ||
{ | ||
/** | ||
* Establishes a connection to the specified LDAP directory service. | ||
* | ||
* @throws Exception | ||
* if creating the connection fails | ||
*/ | ||
public void connect() throws Exception; | ||
|
||
/** | ||
* Disconnects any established connection to the LDAP directory service. | ||
* | ||
* @throws Exception | ||
* if disconnecting fails | ||
*/ | ||
public void disconnect() throws Exception; | ||
|
||
/** | ||
* @return whether a connection is currently established | ||
*/ | ||
public boolean isConnected(); | ||
|
||
/** | ||
* Queries the LDAP directory service for the given name of a context or | ||
* object which may not be null. | ||
* | ||
* @param name | ||
* name (UID) of the context or object to search | ||
* @return query result | ||
* @throws Exception | ||
* if the query is flawed or fails | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public NamingEnumeration nameQuery(String name) throws Exception; | ||
|
||
/** | ||
* Queries the LDAP directory service for all contexts and objects that | ||
* match the given filter expression which may not be null or empty. | ||
* | ||
* @param filter | ||
* filter expression to use | ||
* @return query result | ||
* @throws Exception | ||
* if the query is flawed or fails | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public NamingEnumeration filterQuery(String filter) throws Exception; | ||
|
||
/** | ||
* Queries the LDAP directory service for the given name of a context or | ||
* object and filters the results with the given expression. None of the | ||
* parameters may be null. | ||
* | ||
* @param name | ||
* name (UID) of the context or object to search | ||
* @param filter | ||
* filter expression to use | ||
* @return query result | ||
* @throws Exception | ||
* if the query is flawed or fails | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public NamingEnumeration query(String name, String filter) throws Exception; | ||
|
||
/** | ||
* Carries out the given modifications on the specified directory entry. | ||
* None of the parameters may be null. | ||
* | ||
* @param name | ||
* name (UID) of the entity to modify | ||
* @param mods | ||
* attribute modifications | ||
* @throws Exception | ||
* if parameters are flawed or the operation fails | ||
*/ | ||
public void update(String name, ModificationItem[] mods) throws Exception; | ||
|
||
/** | ||
* Creates the entity as defined by the directory context and the given | ||
* name. No parameter may be null or empty. | ||
* | ||
* @param name | ||
* name (UID) of the entity to create | ||
* @param object | ||
* entity to store with initial attributes to set | ||
* @throws Exception | ||
* if the creation fails | ||
*/ | ||
public void create(String name, DirContext object) throws Exception; | ||
|
||
/** | ||
* Removes an entry from the LDAP directory as defined by the given name. | ||
* Should be used with caution. | ||
* | ||
* @param name | ||
* name (UID) of the entity to remove | ||
* @throws Exception | ||
* if the removal fails | ||
*/ | ||
public void remove(String name) throws Exception; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/de/hofuniversity/iisys/ldapsync/ISyncEndpointFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package de.hofuniversity.iisys.ldapsync; | ||
|
||
import java.util.List; | ||
|
||
import de.hofuniversity.iisys.ldapsync.endpoints.ISyncEndpoint; | ||
|
||
/** | ||
* Factory interface for creating ISyncEndpoint objects that can be used for | ||
* synchronization. | ||
* | ||
* @author fholzschuher2 | ||
* | ||
*/ | ||
public interface ISyncEndpointFactory | ||
{ | ||
/** | ||
* Creates all configured end points and links them to an LDAP connector. | ||
* This method should only be called once, unless duplicate end points are | ||
* desired. | ||
* | ||
* @return newly created end points for synchronization | ||
*/ | ||
public List<ISyncEndpoint> createEndpoints(); | ||
} |
Oops, something went wrong.