com.infoengine.util
Class LdapDirectory

java.lang.Object
  extended bycom.infoengine.util.LdapDirectory
Direct Known Subclasses:
DelegateDirectory, PropertyDirectory

public class LdapDirectory
extends Object

Represents an LDAP directory object.

This class exposes methods for retrieving instances of LdapEntry either via a search or empty LdapEntry objects that can be used to create new LDAP objects.

See Also:
LdapEntry, Url

Field Summary
(package private)  Url url
           
 
Constructor Summary
LdapDirectory(String url)
          Constructs an Ldapdirectory from a String URL.
LdapDirectory(String host, int port)
          Constructs an LdapDirectory pointing to a particular host and port.
LdapDirectory(Url u)
          Constructs an LdapDirectory from a Url object.
 
Method Summary
 LdapEntry[] find(String scope, String filter)
          Searches the the directory from its root.
 LdapEntry[] find(String base, String scope, String filter)
          Searches the the directory from a specific base DN.
 String getBaseDn()
          Gets the base DN.
 LdapEntry getEntry(String dn)
          Gets the LdapEntry found at dn.
 String getProviderUrl()
          Gets the provider URL used by this directory.
 LdapEntry lookup(String dn)
          Looks up a single entry by DN.
 LdapEntry newEntry()
          Constructs an empty LdapEntry object.
 void setBaseDn(String dn)
          Sets the base DN.
 void setPassword(String pw)
          Sets the password for the principal.
 void setPrincipal(String dn)
          Sets the LDAP principal that should be used for operations.
 String toString()
          Gets the String representation of this LdapDirectory (its underlying URL).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

url

Url url
Constructor Detail

LdapDirectory

public LdapDirectory(Url u)
Constructs an LdapDirectory from a Url object.

Parameters:
u - The Url object.
See Also:
Url

LdapDirectory

public LdapDirectory(String url)
Constructs an Ldapdirectory from a String URL.

Parameters:
url - The string URL.

LdapDirectory

public LdapDirectory(String host,
                     int port)
Constructs an LdapDirectory pointing to a particular host and port.

Parameters:
host - The host where the LDAP server resides.
port - The port where the LDAP server is listening.
Method Detail

setBaseDn

public void setBaseDn(String dn)
Sets the base DN. This value is not used.

Parameters:
dn - The new base DN.

getBaseDn

public String getBaseDn()
Gets the base DN.

Returns:
The base DN.

setPrincipal

public void setPrincipal(String dn)
Sets the LDAP principal that should be used for operations.

Parameters:
dn - The principal's DN.
See Also:
setPassword(String)

setPassword

public void setPassword(String pw)
Sets the password for the principal.

Parameters:
pw - The password.
See Also:
setPrincipal(String)

getProviderUrl

public String getProviderUrl()
Gets the provider URL used by this directory. For example "ldap://cn=user:pass@host/"

Returns:
The provider URL.

getEntry

public LdapEntry getEntry(String dn)
Gets the LdapEntry found at dn.

Parameters:
dn - The LdapEntry's DN.
Returns:
The LdapEntry or null if it doesn't exist.
See Also:
LdapEntry

newEntry

public LdapEntry newEntry()
Constructs an empty LdapEntry object. The new object can then be used to create a new entry in the underlying LDAP directory.

Returns:
An empty LdapEntry object for this directory.
See Also:
LdapEntry

find

public LdapEntry[] find(String scope,
                        String filter)
Searches the the directory from its root.

Parameters:
scope - The scope that should be used for the search (e.g. 'sub', 'base', 'one').
filter - The search filter that should be used (e.g. '(objectClass=*)'.
Returns:
The list of entries found or null if none.
See Also:
LdapEntry

find

public LdapEntry[] find(String base,
                        String scope,
                        String filter)
Searches the the directory from a specific base DN.

Parameters:
base - The DN from where the search should be performed.
scope - The scope that should be used for the search (e.g. 'sub', 'base', 'one').
filter - The search filter that should be used (e.g. '(objectClass=*)'.
Returns:
The list of entries found or null if none.
See Also:
LdapEntry

lookup

public LdapEntry lookup(String dn)
Looks up a single entry by DN.

Parameters:
dn - The DN of the entry to retrieve.
Returns:
The entry or null if it doesn't exist.
See Also:
LdapEntry

toString

public String toString()
Gets the String representation of this LdapDirectory (its underlying URL).

Returns:
The string representation.