Package com.nimbusds.ldapsync
Class TargetDirectory
- java.lang.Object
-
- com.nimbusds.ldapsync.TargetDirectory
-
public class TargetDirectory extends Object
Represents the target LDAP v3 - compatible directory which is accessed through aJson2Ldap web service
. Provides methods to perform entry retrieval, addition, modification and delete (required for the synchronisation).
-
-
Constructor Summary
Constructors Constructor Description TargetDirectory(Json2LdapConnector json2ldap, Configuration.TargetDirectory targetDir)
Creates a new target directory representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntry(com.unboundid.ldap.sdk.Entry entry)
Adds a new entry to the target directory.String
connect()
Connects to the target directory via the Json2Ldap web service.void
deleteEntry(String dn)
Deletes an entry in the target directory.void
disconnect()
Closes a connection to the target directory obtained through the Json2Ldap web service.String
getCID()
Returns the Json2Ldap connection identifier (CID) for the target directory.Map<com.unboundid.ldap.sdk.RDN,com.unboundid.ldap.sdk.Entry>
getEntries()
Gets all target directory entries directly under theConfiguration.TargetDirectory.baseDn
branch.void
updateEntry(com.unboundid.ldap.sdk.DN dn, List<ModifySpec> modList)
Updates the specified target directory entry.
-
-
-
Constructor Detail
-
TargetDirectory
public TargetDirectory(Json2LdapConnector json2ldap, Configuration.TargetDirectory targetDir)
Creates a new target directory representation.- Parameters:
json2ldap
- The Json2Ldap web service.targetDir
- The target directory details.
-
-
Method Detail
-
connect
public String connect() throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException, com.thetransactioncompany.jsonrpc2.JSONRPC2Error
Connects to the target directory via the Json2Ldap web service. Uses an "ldap.connect" JSON-RPC 2.0 request with an authenticate (simple bind) option.- Returns:
- The Json2Ldap connection identifier (CID) representing the LDAP connection.
- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- On a JSON-RPC 2.0 session exception.com.thetransactioncompany.jsonrpc2.JSONRPC2Error
- On a Json2Ldap request exception.
-
getCID
public String getCID()
Returns the Json2Ldap connection identifier (CID) for the target directory.- Returns:
- The Json2Ldap connection identifier (CID),
null
not connected.
-
getEntries
public Map<com.unboundid.ldap.sdk.RDN,com.unboundid.ldap.sdk.Entry> getEntries() throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException, com.thetransactioncompany.jsonrpc2.JSONRPC2Error, com.unboundid.ldap.sdk.LDAPException, com.unboundid.ldif.LDIFException, IOException
Gets all target directory entries directly under theConfiguration.TargetDirectory.baseDn
branch. Uses an "ldap.search" JSON-RPC 2.0 request with a simple paged results control option.- Returns:
- The matching directory entries, returned as a map and keyed by their RDN.
- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- On a JSON-RPC 2.0 session exception.com.thetransactioncompany.jsonrpc2.JSONRPC2Error
- On a Json2Ldap request exception.com.unboundid.ldap.sdk.LDAPException
- On an RDN parse exception.com.unboundid.ldif.LDIFException
- On an LDIF parse exception.IOException
- On an LDIF read exception.
-
addEntry
public void addEntry(com.unboundid.ldap.sdk.Entry entry) throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException, com.thetransactioncompany.jsonrpc2.JSONRPC2Error
Adds a new entry to the target directory. Uses an "ldap.add" LDIF JSON-RPC 2.0 request.- Parameters:
entry
- The new directory entry to add.- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- On a JSON-RPC 2.0 session exception.com.thetransactioncompany.jsonrpc2.JSONRPC2Error
- On a Json2Ldap request exception.
-
updateEntry
public void updateEntry(com.unboundid.ldap.sdk.DN dn, List<ModifySpec> modList) throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException, com.thetransactioncompany.jsonrpc2.JSONRPC2Error
Updates the specified target directory entry. Uses an "ldap.modify" LDIF JSON-RPC 2.0 request.- Parameters:
dn
- The DN of the entry to modify.modList
- A list of one or more modification specifications.- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- On a JSON-RPC 2.0 session exception.com.thetransactioncompany.jsonrpc2.JSONRPC2Error
- On a Json2Ldap exception.
-
deleteEntry
public void deleteEntry(String dn) throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException, com.thetransactioncompany.jsonrpc2.JSONRPC2Error
Deletes an entry in the target directory. Uses an "ldap.delete" LDIF JSON-RPC 2.0 request.- Parameters:
dn
- The DN of the entry to delete.- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- On a JSON-RPC 2.0 session exception.com.thetransactioncompany.jsonrpc2.JSONRPC2Error
- On a Json2Ldap request exception.
-
disconnect
public void disconnect() throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException, com.thetransactioncompany.jsonrpc2.JSONRPC2Error
Closes a connection to the target directory obtained through the Json2Ldap web service. Uses an "ldap.close" remote procedure call.- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- On a JSON-RPC 2.0 session exception.com.thetransactioncompany.jsonrpc2.JSONRPC2Error
- On a Json2Ldap request exception.
-
-