public class LdapUserDirectory extends AbstractLDAPConnector<String,User> implements UserDirectory, Component
Modifier and Type | Field and Description |
---|---|
private String |
_id |
private String |
_label |
protected int |
_pageSize
The LDAP search page size.
|
private Map<String,Object> |
_paramValues |
private String |
_populationId |
protected boolean |
_serverSideSorting
True to sort the results on the server side, false to get the results unsorted.
|
private String |
_udModelId |
protected boolean |
_userEmailIsMandatory
To know if email is a mandatory attribute
|
protected String |
_usersEmailAttribute
Name of the email attribute.
|
protected String |
_usersFirstnameAttribute
Name of the first name attribute.
|
protected String |
_usersLastnameAttribute
Name of the last name attribute.
|
protected String |
_usersLoginAttribute
Name of the login attribute.
|
protected String |
_usersObjectFilter
Filter for limiting the search.
|
protected String |
_usersRelativeDN
Relative DN for users.
|
protected int |
_usersSearchScope
The scope used for search.
|
static String |
PARAM_DATASOURCE_ID
Name of the parameter holding the datasource id
|
static String |
PARAM_SERVER_SIDE_SORTING
True to sort the results on the server side, false to get the results unsorted.
|
static String |
PARAM_USERS_EMAIL_ATTRIBUTE
Name of the email attribute.
|
static String |
PARAM_USERS_EMAIL_IS_MANDATORY
To know if email is a mandatory attribute
|
static String |
PARAM_USERS_FIRSTNAME_ATTRIBUTE
Name of the first name attribute.
|
static String |
PARAM_USERS_LASTNAME_ATTRIBUTE
Name of the last name attribute.
|
static String |
PARAM_USERS_LOGIN_ATTRIBUTE
Name of the login attribute.
|
static String |
PARAM_USERS_OBJECT_FILTER
Filter for limiting the search.
|
static String |
PARAM_USERS_RELATIVE_DN
Relative DN for users.
|
static String |
PARAM_USERS_SEARCH_SCOPE
The scope used for search.
|
__DEFAULT_PAGE_SIZE, _ldapAdminPassword, _ldapAdminRelativeDN, _ldapAliasDerefMode, _ldapAuthenticationMethod, _ldapBaseDN, _ldapFollowReferrals, _ldapUrl, _ldapUseSSL, _pagingSupported
Constructor and Description |
---|
LdapUserDirectory() |
Modifier and Type | Method and Description |
---|---|
protected User |
_createUser(Map<String,Object> attributes)
Create a new user from LDAP attributes
|
protected User |
_entry2User(Map<String,Object> attributes)
Deprecated.
|
protected Map<String,Object> |
_getAttributes(SearchResult entry)
Get attributes from a ldap entry.
|
protected Map<String,Object> |
_getPatternFilter(String pattern)
Get the filter from a pattern.
|
protected SearchControls |
_getSearchConstraint(int maxResults)
Get constraints for a search.
|
protected Control[] |
_getSortControls()
Get the sort control.
|
protected List<User> |
_internalGetUsers(Map<String,Map<String,Object>> entries,
int count,
int offset,
String pattern,
int possibleErrors)
Get the user list.
|
private List<User> |
_users(Map<String,Map<String,Object>> entries,
int count,
int offset,
String pattern,
NamingEnumeration<SearchResult> results,
int possibleErrors) |
boolean |
checkCredentials(String login,
String password)
Authenticate a user with its credentials
|
String |
getId()
A unique identifier
|
String |
getLabel()
Get the label of the CredentialProvider
|
Map<String,Object> |
getParameterValues()
Get the values of parameters (from user directory model)
|
String |
getPopulationId()
Get the id of the population this user directory belongs to.
|
User |
getUser(String login)
Get a particular user by his login.
|
String |
getUserDirectoryModelId()
Get the id of the
UserDirectoryModel extension point |
String |
getUserDN(String login)
Get the distinguished name of an user by his login.
|
Collection<User> |
getUsers()
Get the list of all users of one directory.
|
List<User> |
getUsers(int count,
int offset,
Map<String,Object> parameters)
Get a list of users from a directory given the parameters
|
void |
init(String id,
String udModelId,
Map<String,Object> paramValues,
String label)
Initialize the user's directory with given parameters' values.
|
void |
setPopulationId(String populationId)
Set the value of the id of the population this user directory belong to.
|
_cleanup, _delayedInitialize, _getConfigParameter, _getContextEnv, _getFilter, _getRootContextEnv, _getSearchScope, _hasMoreEntries, _search, _search, _setPagingIfSupported, _testConnectionsPooled, _testPagingSupported, isPagingSupported, service
addObjectInCache, clearCache, dispose, getObjectFromCache, initialize, isCacheEnabled, removeObjectFromCache
getLogger, setLogger
public static final String PARAM_DATASOURCE_ID
public static final String PARAM_USERS_RELATIVE_DN
public static final String PARAM_USERS_OBJECT_FILTER
public static final String PARAM_USERS_SEARCH_SCOPE
public static final String PARAM_USERS_LOGIN_ATTRIBUTE
public static final String PARAM_USERS_FIRSTNAME_ATTRIBUTE
public static final String PARAM_USERS_LASTNAME_ATTRIBUTE
public static final String PARAM_USERS_EMAIL_ATTRIBUTE
public static final String PARAM_USERS_EMAIL_IS_MANDATORY
public static final String PARAM_SERVER_SIDE_SORTING
protected String _usersRelativeDN
protected String _usersObjectFilter
protected int _usersSearchScope
protected String _usersLoginAttribute
protected String _usersFirstnameAttribute
protected String _usersLastnameAttribute
protected String _usersEmailAttribute
protected boolean _userEmailIsMandatory
protected boolean _serverSideSorting
protected int _pageSize
private String _udModelId
private Map<String,Object> _paramValues
private String _populationId
public LdapUserDirectory()
public String getId()
UserDirectory
getId
in interface UserDirectory
public String getLabel()
UserDirectory
getLabel
in interface UserDirectory
public void init(String id, String udModelId, Map<String,Object> paramValues, String label) throws Exception
UserDirectory
init
in interface UserDirectory
id
- The non-null and non-empty unique identifierudModelId
- The id of user directory extension pointparamValues
- The parameters' valueslabel
- The optional labelException
- If an error occurredpublic void setPopulationId(String populationId)
UserDirectory
setPopulationId
in interface UserDirectory
populationId
- The id of the population the user directory belongs to.public String getPopulationId()
UserDirectory
getPopulationId
in interface UserDirectory
public Map<String,Object> getParameterValues()
UserDirectory
getParameterValues
in interface UserDirectory
public String getUserDirectoryModelId()
UserDirectory
UserDirectoryModel
extension pointgetUserDirectoryModelId
in interface UserDirectory
public Collection<User> getUsers()
UserDirectory
getUsers
in interface UserDirectory
User
s, empty if a problem occurs.public List<User> getUsers(int count, int offset, Map<String,Object> parameters)
UserDirectory
getUsers
in interface UserDirectory
count
- The limit of users to retrieveoffset
- The number of result to ignore before starting to collect users.parameters
- A map of additional parameters, see implementation.User
public User getUser(String login)
UserDirectory
getUser
in interface UserDirectory
login
- Login of the user to get. Cannot be null.User
instance or null if the user login does not exist.public boolean checkCredentials(String login, String password)
UserDirectory
checkCredentials
in interface UserDirectory
login
- The login to check. Cannot be null.password
- The password to check.public String getUserDN(String login)
login
- Login of the user.protected User _createUser(Map<String,Object> attributes)
attributes
- the LDAP attributesprotected List<User> _internalGetUsers(Map<String,Map<String,Object>> entries, int count, int offset, String pattern, int possibleErrors)
entries
- Where to store entriescount
- The maximum number of users to sax. Cannot be 0. Can be -1 to all.offset
- The results to ignorepattern
- The pattern to match.possibleErrors
- This number will be added to count to set the max of the request, but count results will still be returned. The difference stands for errors.private List<User> _users(Map<String,Map<String,Object>> entries, int count, int offset, String pattern, NamingEnumeration<SearchResult> results, int possibleErrors)
protected Control[] _getSortControls()
protected Map<String,Object> _getPatternFilter(String pattern)
pattern
- The pattern to match.protected SearchControls _getSearchConstraint(int maxResults)
maxResults
- The maximum number of items that will be retrieve (0
means all)@Deprecated protected User _entry2User(Map<String,Object> attributes)
attributes
- The ldap attributes of the entry to sax.protected Map<String,Object> _getAttributes(SearchResult entry)
entry
- The ldap entry to get attributes from.IllegalArgumentException
- If a needed attribute is missing.