toolbox.ldap
Class LDAPWorkerImpl

Package class diagram package LDAPWorkerImpl
java.lang.Object
  extended by toolbox.ldap.LDAPWorkerImpl
All Implemented Interfaces:
LDAPWorker

public class LDAPWorkerImpl
extends java.lang.Object
implements LDAPWorker

Default LDAPWorker implementation.


Constructor Summary
LDAPWorkerImpl()
          Default constructor
 
Method Summary
 java.lang.String add(java.lang.String entry, java.lang.String context, java.util.Map attrs)
          Add an entry to the LDAP directory.
 java.lang.String getContextValue(java.lang.String mapping)
          Return context value for the given context mapping.
 EntryDefinition getEntryDefinition(java.lang.String mapping)
          Return EntryDefinition for the given entry mapping.
 java.lang.String getRootContext()
          Return the root context of this worker.
 void init(java.util.Map entries, java.util.Map contexts, LDAPManager mngr)
          Initialise this worker with the supported Map of LDAP entry definitions and contexts.
 java.util.Map lookup(java.lang.String entry, java.lang.String context, java.lang.String bindName, java.lang.String[] attrs)
          Return a single entry from the LDAP directory.
 void modify(java.lang.String entry, java.lang.String context, java.lang.String bindName, int modType, java.util.Map attrs)
          Modify the attributes of the entry with given bind attribute value.
 void remove(java.lang.String entry, java.lang.String context, java.lang.String bindName)
          Remove an entry from the LDAP directory.
 java.util.List search(java.lang.String entry, java.lang.String filter, java.lang.String context, int scope, java.lang.String[] attrs)
          Search for entries in the LDAP directory.
 java.util.List search(java.lang.String entry, java.lang.String filter, java.lang.String context, int scope, java.lang.String[] attrs, java.lang.String sortAttr, java.lang.String sortOrder)
          Search for entries in the LDAP directory and sort the results as specified.
 void update(java.lang.String entry, java.lang.String context, java.util.Map attrs)
          Update an existing entry in the LDAP directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPWorkerImpl

public LDAPWorkerImpl()
Default constructor

Method Detail

init

public void init(java.util.Map entries,
                 java.util.Map contexts,
                 LDAPManager mngr)
Initialise this worker with the supported Map of LDAP entry definitions and contexts.

Specified by:
init in interface LDAPWorker
Parameters:
entries - Map instance containing the supported LDAP entry definitions.
contexts - Map containing the supported context's.
mngr - LDAPManager instance that created this worker.

add

public java.lang.String add(java.lang.String entry,
                            java.lang.String context,
                            java.util.Map attrs)
                     throws LDAPException
Add an entry to the LDAP directory.

Specified by:
add in interface LDAPWorker
Parameters:
entry - String indicating the configured entry type.
context - String indicating the configured context where the the attributes should be added to the directory.
attrs - Map containing attributes. The keys will be used as attributes names. Multi-valued attributes must contain a Set instance with the attribute values.
Returns:
String containing the dn the of the added entry.
Throws:
LDAPException - if the attributes cannot be added to the directory.

update

public void update(java.lang.String entry,
                   java.lang.String context,
                   java.util.Map attrs)
            throws LDAPException
Update an existing entry in the LDAP directory.

Specified by:
update in interface LDAPWorker
Parameters:
entry - String indicating the configured entry type.
context - String indicating the configured context where the the attributes should be added to the directory.
attrs - Map containing attributes. The keys will be used as attributes names. Multi-valued attributes must contain a Set instance with the attribute values.
Throws:
LDAPException - if the attributes cannot be updated in the directory.

remove

public void remove(java.lang.String entry,
                   java.lang.String context,
                   java.lang.String bindName)
            throws LDAPException
Remove an entry from the LDAP directory.

Specified by:
remove in interface LDAPWorker
Parameters:
entry - String indicating the entry type to remove.
context - String containing the name of a configured context where the entry is located.
bindName - String containing the value of the bind attribute.
Throws:
LDAPException - if the entry cannot be removed from the given context.

modify

public void modify(java.lang.String entry,
                   java.lang.String context,
                   java.lang.String bindName,
                   int modType,
                   java.util.Map attrs)
            throws LDAPException
Modify the attributes of the entry with given bind attribute value.

Specified by:
modify in interface LDAPWorker
Parameters:
entry - String indicating the entry type.
context - String containing the name of configured context where the entry is located.
bindName - String containing the value of the bind attribute.
modType - Primitive int indication the modification operation type.
attrs - Map containing the attributes that must be modified.
Throws:
LDAPException - if the attributes cannot be modified.

lookup

public java.util.Map lookup(java.lang.String entry,
                            java.lang.String context,
                            java.lang.String bindName,
                            java.lang.String[] attrs)
                     throws LDAPException
Return a single entry from the LDAP directory.

Specified by:
lookup in interface LDAPWorker
Parameters:
entry - String indicating the entry type.
context - String indicating the name of the configured context to look in.
bindName - String containing the value of the bind attribute.
attrs - String array containing the names of the attributes that must be returned.
Returns:
Map containing the attributes of the entry.
Throws:
LDAPException - if the attributes cannot be returned.

search

public java.util.List search(java.lang.String entry,
                             java.lang.String filter,
                             java.lang.String context,
                             int scope,
                             java.lang.String[] attrs)
                      throws LDAPException
Search for entries in the LDAP directory.

Specified by:
search in interface LDAPWorker
Parameters:
entry - String containing entry type that we are searching for.
filter - String containing a valid LDAP filter.
context - String containing the name of one of the configured contexts. May be null.
scope - Primitive int indicating the search scope.
attrs - String array containing the names of the attributes that must be returned by the search.
Returns:
List containing search results as Maps of attribute name-value pairs.
Throws:
LDAPException - if the search cannot be performed.

search

public java.util.List search(java.lang.String entry,
                             java.lang.String filter,
                             java.lang.String context,
                             int scope,
                             java.lang.String[] attrs,
                             java.lang.String sortAttr,
                             java.lang.String sortOrder)
                      throws LDAPException
Search for entries in the LDAP directory and sort the results as specified.

Specified by:
search in interface LDAPWorker
Parameters:
entry - String containing entry type that we are searching for.
filter - String containing a valid LDAP filter.
context - String containing the name of one of the configured contexts. May be null.
scope - Primitive int indicating the search scope.
attrs - String array containing the names of the attributes that must be returned by the search.
sortAttr - String containing the name of the attribute that must be sorted on.
sortOrder - String indicating the sort order. Specify "asc" for ascending order and "desc" for descending order.
Returns:
List containing search results as Maps of attribute name-value pairs.
Throws:
LDAPException - if the search cannot be performed.

getContextValue

public java.lang.String getContextValue(java.lang.String mapping)
Return context value for the given context mapping.

Specified by:
getContextValue in interface LDAPWorker
Parameters:
mapping - String containing the context mapping.
Returns:
String containing the actual context value.

getEntryDefinition

public EntryDefinition getEntryDefinition(java.lang.String mapping)
Return EntryDefinition for the given entry mapping.

Specified by:
getEntryDefinition in interface LDAPWorker
Parameters:
mapping - String containing the entry mapping.
Returns:
EntryDefinition instance.

getRootContext

public java.lang.String getRootContext()
                                throws LDAPException
Return the root context of this worker.

Specified by:
getRootContext in interface LDAPWorker
Returns:
String representing the root context of this worker.
Throws:
LDAPException - if the context cannot be returned.