Package com.nimbusds.ldapsync
Class SourceDirectory
- java.lang.Object
-
- com.nimbusds.ldapsync.SourceDirectory
-
- All Implemented Interfaces:
com.nimbusds.ldap.dnresolver.DNSearchRequestHandler
public class SourceDirectory extends Object implements com.nimbusds.ldap.dnresolver.DNSearchRequestHandler
Represents the source LDAP v3 - compatible directory which feeds the original entries. Provides methods for connection, authentication and retrieval of the entries for export to the target directory.
-
-
Constructor Summary
Constructors Constructor Description SourceDirectory(Configuration.SourceDirectory srcDir)
Creates a new source directory representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
authenticateUser(com.unboundid.ldap.sdk.DN dn, String password)
Authenticates a user against the source LDAP directory by making a test simple bind with his distinct name (DN) and password.void
connect()
Connects to thesource directory
with the configuredauthentication credentials
.void
disconnect()
Closes the LDAP connection to the source directory.Map<String,com.unboundid.ldap.sdk.Entry>
getEntries(String keyAttribute, String[] attributeList, KeyWarnings keyWarnings)
Retrieves the source directory entries that match theConfiguration.SourceDirectory.Search
criteria.com.nimbusds.ldap.dnresolver.DNSearchResult
search(com.nimbusds.ldap.dnresolver.DNSearchRequest request)
Handles LDAP search requests from a DN resolver.
-
-
-
Constructor Detail
-
SourceDirectory
public SourceDirectory(Configuration.SourceDirectory srcDir)
Creates a new source directory representation.- Parameters:
srcDir
- The source directory configuration.
-
-
Method Detail
-
connect
public void connect() throws com.unboundid.ldap.sdk.LDAPException, GeneralSecurityException, SSLHandshakeException
Connects to thesource directory
with the configuredauthentication credentials
. The connection should beclosed
when no longer in use.- Throws:
GeneralSecurityException
- On a general TLS/SSL exception.SSLHandshakeException
- On a bad server certificate.com.unboundid.ldap.sdk.LDAPException
- If a connection to the source directory could not be established.
-
authenticateUser
public boolean authenticateUser(com.unboundid.ldap.sdk.DN dn, String password) throws com.unboundid.ldap.sdk.LDAPException, GeneralSecurityException, SSLHandshakeException
Authenticates a user against the source LDAP directory by making a test simple bind with his distinct name (DN) and password.To perform the DN / password check this method creates a new LDAP connection to the specified
Configuration.SourceDirectory
, makes the test simple bind request, and then closes the connection.- Parameters:
dn
- The user DN.password
- The user password.- Returns:
true
if the credentials authenticated successfully, elsefalse
.- Throws:
GeneralSecurityException
- On a general TLS/SSL exception.SSLHandshakeException
- On a bad server certificate.com.unboundid.ldap.sdk.LDAPException
- If a connection to the source directory could not be established.
-
getEntries
public Map<String,com.unboundid.ldap.sdk.Entry> getEntries(String keyAttribute, String[] attributeList, KeyWarnings keyWarnings) throws com.unboundid.ldap.sdk.LDAPException
Retrieves the source directory entries that match theConfiguration.SourceDirectory.Search
criteria. These will be returned as a hash map keyed by the specified entry attribute.Entries with missing key attribute value, multiple key attribute values or non-unique key attribute value will be skipped and their DNs will be reported using the supplied
KeyWarnings
object.- Parameters:
keyAttribute
- The name of the attribute to use for keying the retrieved entries.attributeList
- The names of the attributes to retrieve for each entry.keyWarnings
- An empty key warnings object used to report any entries with missing, multi-value or non-unique key attribute.- Returns:
- The source directory entries, stored in a hash map keyed by specified entry attribute.
- Throws:
com.unboundid.ldap.sdk.LDAPException
- If the LDAP search request failed.
-
search
public com.nimbusds.ldap.dnresolver.DNSearchResult search(com.nimbusds.ldap.dnresolver.DNSearchRequest request) throws com.nimbusds.ldap.dnresolver.DNSearchException
Handles LDAP search requests from a DN resolver. Returns the distinguished names (DNs) of the source directory entries that match the specified search criteria. No attributes are being requested.- Specified by:
search
in interfacecom.nimbusds.ldap.dnresolver.DNSearchRequestHandler
- Parameters:
request
- The DN search request.- Returns:
- The DN search result.
- Throws:
com.nimbusds.ldap.dnresolver.DNSearchException
- If the search request failed.
-
disconnect
public void disconnect()
Closes the LDAP connection to the source directory.
-
-