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 booleanauthenticateUser(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.voidconnect()Connects to thesource directorywith the configuredauthentication credentials.voiddisconnect()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.Searchcriteria.com.nimbusds.ldap.dnresolver.DNSearchResultsearch(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, SSLHandshakeExceptionConnects to thesource directorywith the configuredauthentication credentials. The connection should beclosedwhen 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, SSLHandshakeExceptionAuthenticates 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:
trueif 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.Searchcriteria. 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
KeyWarningsobject.- 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.DNSearchExceptionHandles 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:
searchin 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.
-
-