edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector
Class LdapDataConnector

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.AbstractResolutionPlugIn<Map<String,BaseAttribute>>
      extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.BaseDataConnector
          extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.LdapDataConnector
All Implemented Interfaces:
DataConnector, ResolutionPlugIn<Map<String,BaseAttribute>>

public class LdapDataConnector
extends BaseDataConnector

LdapDataConnector provides a plugin to retrieve attributes from an LDAP.


Nested Class Summary
static class LdapDataConnector.AUTHENTICATION_TYPE
          Authentication type values.
protected  class LdapDataConnector.LDAPValueEscapingStrategy
          Escapes values that will be included within an LDAP filter.
 
Constructor Summary
LdapDataConnector(LdapPoolStrategy pool, net.sf.ehcache.Cache cache)
          This creates a new LDAP data connector with the supplied properties.
 
Method Summary
protected  Map<String,BaseAttribute> buildBaseAttributes(Iterator<SearchResult> results)
          This returns a map of attribute ids to attributes from the supplied search results.
protected  void cacheResult(String searchFilter, Map<String,BaseAttribute> attributes)
          This stores the supplied attributes in the cache.
protected  void clearCache()
          Removes all entries from the cache if results are being cached.
 String getFilterTemplate()
          Gets the template used to create queries.
 LdapPoolStrategy getLdapPool()
          This returns the ldap pool strategy this connector is using.
 String[] getReturnAttributes()
          This returns the attributes that all searches will request from the ldap.
 TemplateEngine getTemplateEngine()
          Gets the engine used to evaluate the query template.
 boolean isCacheResults()
          This returns whether this connector will cache search results.
 boolean isNoResultsIsError()
          This returns whether this connector will throw an exception if no search results are found.
 void registerTemplate(TemplateEngine engine, String template)
          This sets the underlying template engine and registers the supplied template.
 Map<String,BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
          Performs the attribute resolution for this plugin.
protected  Map<String,BaseAttribute> retrieveAttributesFromCache(String searchFilter)
          This retrieves any cached attributes for the supplied resolution context.
protected  Iterator<SearchResult> searchLdap(String searchFilter)
          This searches the LDAP with the supplied filter.
 void setNoResultsIsError(boolean isError)
          This sets whether this connector will throw an exception if no search results are found.
 void setReturnAttributes(String s)
          This sets the attributes that all searches will request from the ldap.
 void setReturnAttributes(String[] attributes)
          This sets the attributes that all searches will request from the ldap.
 void validate()
          Validate the internal state of this plug-in.
 
Methods inherited from class edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.BaseDataConnector
getFailoverDependencyId, setFailoverDependencyIds
 
Methods inherited from class edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.AbstractResolutionPlugIn
getDependencyIds, getId, getValuesFromAllDependencies, getValuesFromAttributeDependency, getValuesFromConnectorDependency, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ResolutionPlugIn
getDependencyIds, getId
 

Constructor Detail

LdapDataConnector

public LdapDataConnector(LdapPoolStrategy pool,
                         net.sf.ehcache.Cache cache)
This creates a new LDAP data connector with the supplied properties.

Parameters:
pool - LDAP connection pooling strategy
cache - cached used to cache search results, or null if results should not be cached
Method Detail

registerTemplate

public void registerTemplate(TemplateEngine engine,
                             String template)
This sets the underlying template engine and registers the supplied template.

Parameters:
engine - engine used to fill in search filter templates
template - search filter template

clearCache

protected void clearCache()
Removes all entries from the cache if results are being cached.


isCacheResults

public boolean isCacheResults()
This returns whether this connector will cache search results.

Returns:
true if results are being cached

isNoResultsIsError

public boolean isNoResultsIsError()
This returns whether this connector will throw an exception if no search results are found.

Returns:
true if searches which return no results are considered an error

setNoResultsIsError

public void setNoResultsIsError(boolean isError)
This sets whether this connector will throw an exception if no search results are found.

Parameters:
isError - true if searches which return no results are considered an error, false otherwise

getTemplateEngine

public TemplateEngine getTemplateEngine()
Gets the engine used to evaluate the query template.

Returns:
engine used to evaluate the query template

getFilterTemplate

public String getFilterTemplate()
Gets the template used to create queries.

Returns:
template used to create queries

getLdapPool

public LdapPoolStrategy getLdapPool()
This returns the ldap pool strategy this connector is using.

Returns:
ldap pool strategy

getReturnAttributes

public String[] getReturnAttributes()
This returns the attributes that all searches will request from the ldap.

Returns:
String[]

setReturnAttributes

public void setReturnAttributes(String[] attributes)
This sets the attributes that all searches will request from the ldap. This method will remove any cached results.

Parameters:
attributes - String[]
See Also:
clearCache()

setReturnAttributes

public void setReturnAttributes(String s)
This sets the attributes that all searches will request from the ldap. s should be a comma delimited string.

Parameters:
s - String[] comma delimited returnAttributes

validate

public void validate()
              throws AttributeResolutionException
Validate the internal state of this plug-in. This process may not rely on information from any dependency.

Throws:
AttributeResolutionException - if the plug-in has an invalid internal state

resolve

public Map<String,BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
                                  throws AttributeResolutionException
Performs the attribute resolution for this plugin.

Parameters:
resolutionContext - the context for the resolution
Returns:
the attributes made available by the resolution, never null
Throws:
AttributeResolutionException - the problem that occurred during the resolution

retrieveAttributesFromCache

protected Map<String,BaseAttribute> retrieveAttributesFromCache(String searchFilter)
This retrieves any cached attributes for the supplied resolution context. Returns null if nothing is cached.

Parameters:
searchFilter - the search filter the produced the attributes
Returns:
Map of attributes IDs to attributes

searchLdap

protected Iterator<SearchResult> searchLdap(String searchFilter)
                                     throws AttributeResolutionException
This searches the LDAP with the supplied filter.

Parameters:
searchFilter - String the searchFilter that produced the attributes
Returns:
Iterator of search results
Throws:
AttributeResolutionException - if an error occurs performing the search

buildBaseAttributes

protected Map<String,BaseAttribute> buildBaseAttributes(Iterator<SearchResult> results)
                                                 throws AttributeResolutionException
This returns a map of attribute ids to attributes from the supplied search results.

Parameters:
results - Iterator of LDAP search results
Returns:
Map of attribute ids to attributes
Throws:
AttributeResolutionException - if an error occurs parsing attribute results

cacheResult

protected void cacheResult(String searchFilter,
                           Map<String,BaseAttribute> attributes)
This stores the supplied attributes in the cache.

Parameters:
searchFilter - the searchFilter that produced the attributes
attributes - Map of attribute IDs to attributes


Copyright © 2006-2010 Internet2. All Rights Reserved.