Class LdapDataSourceFactory
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.util.ldap.AbstractLDAPConnector
org.ametys.plugins.externaldata.data.ldap.LdapDataSourceFactory
- All Implemented Interfaces:
DataSourceFactory<LdapQuery,
,LdapQueryResult> LogEnabled
,PluginAware
,Serviceable
public class LdapDataSourceFactory
extends AbstractLDAPConnector
implements DataSourceFactory<LdapQuery,LdapQueryResult>, PluginAware
LDAP Data Source factory.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The LDAp attributes to returnstatic final String
Constraint query parameter.Query configuration parameters.static final String
The relative DN for usersstatic final String
The search scope of the queryFields inherited from class org.ametys.core.util.ldap.AbstractLDAPConnector
__PAGE_SIZE, _ldapAdminPassword, _ldapAdminRelativeDN, _ldapAliasDerefMode, _ldapAuthenticationMethod, _ldapBaseDN, _ldapFollowReferrals, _ldapUrl, _ldapUseSSL, _pagingSupported, _serverSideSorting
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
Get the scope as an integer (handlable by the SearchControls) from the scope string.protected SearchControls
_getSearchControls
(Collection<String> attributes, String scopeStr) Get the LDAP search controls.buildQuery
(String id, String type, String name, String description, Query.ResultType resultType, String dataSourceId, Map<String, String> additionalConfiguration) Build a query with the specified information.Execute the query with the specified parameter values.Execute the query with the specified parameter values.Get the types that the factory can build.The configuration parameters needed to build a Query of the specified type.void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Methods inherited from class org.ametys.core.util.ldap.AbstractLDAPConnector
_cleanup, _delayedInitialize, _getConfigParameter, _getContextEnv, _getFilter, _getRootContextEnv, _getSearchScope, _hasMoreEntries, _isPagingSupported, _search, _search, _search, _search, _setResultsControls, _testConnectionsPooled, _testPagingSupported, getSortByFields, service
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
QUERY_CONFIGURATION_RELATIVE_DN
The relative DN for users- See Also:
-
QUERY_CONFIGURATION_SCOPE
The search scope of the query- See Also:
-
QUERY_CONFIGURATION_ATTRIBUTES
The LDAp attributes to return- See Also:
-
QUERY_CONFIGURATION_CONSTRAINT
Constraint query parameter.- See Also:
-
QUERY_CONFIGURATION_PARAMETERS
Query configuration parameters.
-
-
Constructor Details
-
LdapDataSourceFactory
public LdapDataSourceFactory()
-
-
Method Details
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
getHandledTypes
Description copied from interface:DataSourceFactory
Get the types that the factory can build.- Specified by:
getHandledTypes
in interfaceDataSourceFactory<LdapQuery,
LdapQueryResult> - Returns:
- the handled types as a Collection.
-
getQueryConfigurationParameters
Description copied from interface:DataSourceFactory
The configuration parameters needed to build a Query of the specified type.- Specified by:
getQueryConfigurationParameters
in interfaceDataSourceFactory<LdapQuery,
LdapQueryResult> - Parameters:
type
- the type of the Query.- Returns:
- the configuration parameters as a Collection.
-
buildQuery
public LdapQuery buildQuery(String id, String type, String name, String description, Query.ResultType resultType, String dataSourceId, Map<String, String> additionalConfiguration) throws DataInclusionExceptionDescription copied from interface:DataSourceFactory
Build a query with the specified information.- Specified by:
buildQuery
in interfaceDataSourceFactory<LdapQuery,
LdapQueryResult> - Parameters:
id
- the Query ID.type
- the Query type.name
- the Query name.description
- the Query description.resultType
- the Query result type (single/multiple).dataSourceId
- the id of data sourceadditionalConfiguration
- additional query configuration parameter values as a Map<parameterName, parameterValue>.- Returns:
- the query.
- Throws:
DataInclusionException
- if an error occurs trying to create the Query.
-
execute
public LdapQueryResult execute(LdapQuery query, Map<String, String> parameterValues) throws DataInclusionExceptionDescription copied from interface:DataSourceFactory
Execute the query with the specified parameter values.- Specified by:
execute
in interfaceDataSourceFactory<LdapQuery,
LdapQueryResult> - Parameters:
query
- The queryparameterValues
- the parameter values as a Map (name -> value).- Returns:
- the query result.
- Throws:
DataInclusionException
- if an error occurs while executing the query
-
execute
public LdapQueryResult execute(LdapQuery query, Map<String, String> parameterValues, int offset, int limit) throws DataInclusionExceptionDescription copied from interface:DataSourceFactory
Execute the query with the specified parameter values.- Specified by:
execute
in interfaceDataSourceFactory<LdapQuery,
LdapQueryResult> - Parameters:
query
- The queryparameterValues
- the parameter values as a Map (name -> value).offset
- The start index of searchlimit
- The max number of result to return- Returns:
- the query result.
- Throws:
DataInclusionException
- if an error occurs while executing the query
-
_getSearchControls
protected SearchControls _getSearchControls(Collection<String> attributes, String scopeStr) throws DataInclusionException Get the LDAP search controls.- Parameters:
attributes
- the attributes to return.scopeStr
- the scope as a String.- Returns:
- the search controls.
- Throws:
DataInclusionException
- If an error occurred
-
_getScope
Get the scope as an integer (handlable by the SearchControls) from the scope string.- Parameters:
scopeStr
- the scope string.- Returns:
- the scope as an integer.
- Throws:
DataInclusionException
- If an error occurred
-