K
- the type of keys for caching objects by this component.V
- the type of objects cached by this component.public abstract class AbstractLDAPConnector<K,V> extends CachingComponent<K,V> implements Serviceable
Modifier and Type | Field and Description |
---|---|
protected static int |
__DEFAULT_PAGE_SIZE
The default LDAP search page size
|
private static Pattern |
__FILTER |
protected String |
_ldapAdminPassword
Password associated with the admin.
|
protected String |
_ldapAdminRelativeDN
Distinguished name of the admin used for searching.
|
protected String |
_ldapAliasDerefMode
Alias dereferencing mode.
|
protected String |
_ldapAuthenticationMethod
Authentication method used.
|
protected String |
_ldapBaseDN
Base DN to the ldap server.
|
private LDAPDataSourceManager |
_ldapDataSourceManager
The LDAP data source manager
|
protected boolean |
_ldapFollowReferrals
Enable following referrals.
|
protected String |
_ldapUrl
URL connection to the ldap server.
|
protected boolean |
_ldapUseSSL
Use ssl for connecting to ldap server.
|
protected boolean |
_pagingSupported
Indicates if the LDAP server supports paging feature.
|
protected boolean |
_serverSideSorting
True to sort the results on the server side, false to get the results unsorted.
|
Constructor and Description |
---|
AbstractLDAPConnector() |
Modifier and Type | Method and Description |
---|---|
protected void |
_cleanup(Context context,
NamingEnumeration result)
Clean a connection to an ldap server.
|
protected void |
_delayedInitialize(String dataSourceId)
Call this method with the datasource id to initialize this component
|
protected String |
_getConfigParameter(Configuration configuration,
String key)
Get a config parameter value
|
protected Hashtable<String,String> |
_getContextEnv()
Get the parameters for connecting to the ldap server.
|
protected String |
_getFilter(Configuration configuration,
String filterKey)
Get the filter from configuration key and check it
|
protected Hashtable<String,String> |
_getRootContextEnv()
Get the parameters for connecting to the ldap server, root DN.
|
protected int |
_getSearchScope(Configuration configuration,
String searchScopeKey)
Get the search scope from configuration key
|
protected boolean |
_hasMoreEntries(int pageSize,
LdapContext context)
Determines if there are more entries for the LDAP server to return based on server-generated cookie.
|
protected List<SearchResult> |
_search(int pageSize,
String name,
String filter,
Object[] filterArgs,
SearchControls searchControls,
int offset,
int limit)
Executes a LDAP search
|
protected List<SearchResult> |
_search(int pageSize,
String name,
String filter,
Object[] filterArgs,
SearchControls searchControls,
int offset,
int limit,
boolean sorted)
Executes a LDAP search
|
protected List<SearchResult> |
_search(int pageSize,
String name,
String filter,
SearchControls searchControls)
Executes a LDAP search
|
protected List<SearchResult> |
_search(int pageSize,
String name,
String filter,
SearchControls searchControls,
boolean sorted)
Executes a LDAP search
|
protected void |
_setResultsControls(int pageSize,
LdapContext context,
boolean sorted)
Set paging on ldap if supported, and set the sort
|
protected boolean |
_testConnectionsPooled()
Test if connections are pooled
|
protected boolean |
_testPagingSupported()
Test if paging is supported by the underlying directory server.
|
protected String[] |
getSortByFields()
Get the fields to sort by if the search is sorted
|
boolean |
isPagingSupported()
Test if paging is supported by the underlying directory server.
|
void |
service(ServiceManager serviceManager) |
addObjectInCache, clearCache, dispose, getObjectFromCache, initialize, isCacheEnabled, removeObjectFromCache
getLogger, setLogger
protected static final int __DEFAULT_PAGE_SIZE
protected String _ldapBaseDN
protected String _ldapAdminRelativeDN
protected String _ldapAdminPassword
protected String _ldapAuthenticationMethod
protected boolean _ldapUseSSL
protected boolean _ldapFollowReferrals
protected String _ldapAliasDerefMode
protected boolean _serverSideSorting
protected boolean _pagingSupported
private LDAPDataSourceManager _ldapDataSourceManager
public AbstractLDAPConnector()
protected void _delayedInitialize(String dataSourceId) throws Exception
dataSourceId
- The id of the datasourceException
- If an error occurs.public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
protected String _getFilter(Configuration configuration, String filterKey) throws ConfigurationException
configuration
- The configurationfilterKey
- The name of the child in configuration containing the filter config parameter nameConfigurationException
- if the filter does not matchprotected int _getSearchScope(Configuration configuration, String searchScopeKey) throws ConfigurationException
configuration
- The configurationsearchScopeKey
- The name of the child in configuration containing the search scope parameter nameSearchControls.ONELEVEL_SCOPE
, SearchControls.SUBTREE_SCOPE
and SearchControls.OBJECT_SCOPE
.ConfigurationException
- if a configuration problem occurspublic boolean isPagingSupported()
protected String _getConfigParameter(Configuration configuration, String key) throws ConfigurationException
configuration
- The configurationkey
- The child node of configuration containing the config parameter nameConfigurationException
- if parameter is missingprotected Hashtable<String,String> _getContextEnv()
protected Hashtable<String,String> _getRootContextEnv()
protected boolean _testPagingSupported()
protected boolean _testConnectionsPooled()
protected void _cleanup(Context context, NamingEnumeration result)
context
- The connection to the database to close.result
- The result to close.protected List<SearchResult> _search(int pageSize, String name, String filter, SearchControls searchControls) throws NamingException
pageSize
- The number of entries in a pagename
- the name of the context or object to searchfilter
- the filter expression to use for the searchsearchControls
- the search controls that control the search.NamingException
- if a naming exception is encounteredprotected List<SearchResult> _search(int pageSize, String name, String filter, SearchControls searchControls, boolean sorted) throws NamingException
pageSize
- The number of entries in a pagename
- the name of the context or object to searchfilter
- the filter expression to use for the searchsearchControls
- the search controls that control the search.sorted
- True to sort the resultsNamingException
- if a naming exception is encounteredprotected List<SearchResult> _search(int pageSize, String name, String filter, Object[] filterArgs, SearchControls searchControls, int offset, int limit) throws NamingException
pageSize
- The number of entries in a pagename
- the name of the context or object to searchfilter
- the filter expression to use for the searchfilterArgs
- the array of arguments to substitute for the variables in filter. Can be null.searchControls
- the search controls that control the search.offset
- the start indexlimit
- The max number of resultsNamingException
- if a naming exception is encounteredprotected List<SearchResult> _search(int pageSize, String name, String filter, Object[] filterArgs, SearchControls searchControls, int offset, int limit, boolean sorted) throws NamingException
pageSize
- The number of entries in a pagename
- the name of the context or object to searchfilter
- the filter expression to use for the searchfilterArgs
- the array of arguments to substitute for the variables in filter. Can be null.searchControls
- the search controls that control the search.offset
- the start indexlimit
- The max number of resultssorted
- True to sort the resultsNamingException
- if a naming exception is encounteredprotected boolean _hasMoreEntries(int pageSize, LdapContext context) throws NamingException
pageSize
- The number of entries to be returned per pagecontext
- The ldap contextNamingException
- If an error occurred while getting/setting the request controlsprotected void _setResultsControls(int pageSize, LdapContext context, boolean sorted) throws NamingException
pageSize
- The page size to communicate with ldapcontext
- The ldap contextsorted
- True add the sort controlsNamingException
- if an error occurredprotected String[] getSortByFields()